//+------------------------------------------------------------------+ //| MA_Envelopes_Alert_V00.mq4 | //| Copyright (c) 2012, FX_Kuraisora | //| http://goldsearch.blog24.fc2.com/| //+------------------------------------------------------------------+ #property copyright "Copyright ゥ 2010, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" #property indicator_chart_window #property indicator_buffers 5 #property indicator_color1 Lime #property indicator_width1 2 #property indicator_style1 0 #property indicator_color2 LightSeaGreen #property indicator_width2 1 #property indicator_style2 2 #property indicator_color3 LightSeaGreen #property indicator_width3 1 #property indicator_style3 2 #property indicator_color4 SeaGreen #property indicator_width4 1 #property indicator_style4 2 #property indicator_color5 SeaGreen #property indicator_width5 1 #property indicator_style5 2 //---- input parameters extern int MA_period = 23; extern int MAMethod = MODE_SMA; extern int MAPrice = PRICE_OPEN; extern int STDPriod = 23;//エンベロープ標準偏差計算期間 extern double STDdouble1 = 1;//INNERエンベロープ標準偏差倍率 extern double STDdouble2 = 2;//OUTERエンベロープ標準偏差倍率 extern bool AlertMode1 = true;//INNERエンベロープAlert発生選択 extern bool AlertMode2 = true;//OUTERエンベロープAlert発生選択 extern color indicator_clr1 = Lime; extern color indicator_clr2 = LightSeaGreen; extern color indicator_clr3 = SeaGreen; extern color indicator_clr4 = White; //---- buffers double MABuffer[]; double STDUL1[]; double STDDL1[]; double STDUL2[]; double STDDL2[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexBuffer(0,MABuffer); SetIndexStyle(0,DRAW_LINE,EMPTY,EMPTY,indicator_clr1); SetIndexBuffer(1,STDUL1); SetIndexStyle(1,DRAW_LINE,EMPTY,EMPTY,indicator_clr2); SetIndexBuffer(2,STDDL1); SetIndexStyle(2,DRAW_LINE,EMPTY,EMPTY,indicator_clr2); SetIndexBuffer(3,STDUL2); SetIndexStyle(3,DRAW_LINE,EMPTY,EMPTY,indicator_clr3); SetIndexBuffer(4,STDDL2); SetIndexStyle(4,DRAW_LINE,EMPTY,EMPTY,indicator_clr3); //---- Prameter check if (MAMethod>3) MAMethod=3; if (STDdouble1>STDdouble2) STDdouble2=STDdouble1+1; //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- ObjectDelete("MAwithPriceTAG"); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); int limit =Bars-counted_bars-1; int i; //---- for(i=limit;i>=0;i--){ MABuffer[i] = iMA(NULL,0,MA_period,0,MAMethod,MAPrice,i); STDUL1[i] = iEnvelopes(NULL, 0, STDPriod, MAMethod, 0,MAPrice, STDdouble1, 1, i); STDDL1[i] = iEnvelopes(NULL, 0, STDPriod, MAMethod, 0,MAPrice, STDdouble1, 2, i); STDUL2[i] = iEnvelopes(NULL, 0, STDPriod, MAMethod, 0,MAPrice, STDdouble2, 1, i); STDDL2[i] = iEnvelopes(NULL, 0, STDPriod, MAMethod, 0,MAPrice, STDdouble2, 2, i); } datetime PB_sift = Time[0] + 3 * Period() * 60; SetPrice("MAwithPriceTAG", PB_sift,MABuffer[0],indicator_clr4,3); //---- if(AlertMode1){ static datetime AlertTime = 0; if((Close[2]<=STDUL1[2] ||Open[1]<=STDUL1[1]) && Close[1]>STDUL1[1] && AlertTime !=Time[0]){ AlertTime =Time[0]; Alert("Inner Envelopes Cross UP "+Symbol()+Period()+" ["+DoubleToStr(Bid,Digits)+"]"); } if((Close[2]>=STDDL1[2] || Open[1]>=STDDL1[1]) && Close[1]STDUL2[1] && AlertTime !=Time[0]){ AlertTime =Time[0]; Alert("Outer Envelopes Cross UP "+Symbol()+Period()+" ["+DoubleToStr(Bid,Digits)+"]"); } if((Close[2]>=STDDL2[2] || Open[1]>=STDDL2[1]) && Close[1]