//+------------------------------------------------------------------+ //| T3MA_ALARM.mq4 | //| Copyright © 2011, Martingeil | //| fx.09@mail.ru | //+------------------------------------------------------------------+ //исправленный Martingeil, теперь можно в тестере увидеть его стрелки. #property copyright "Copyright © 2011, Martingeil" #property link "fx.09@mail.ru" //---- indicator settings #property indicator_chart_window #property indicator_buffers 2 #property indicator_color1 Blue #property indicator_color2 Red //---- indicator parameters extern int period = 4; //12 extern int shift = 0; //сдвиг по бару extern bool UseSound=true; extern bool AlertSound=true; extern string SoundFileBuy ="alert2.wav"; extern string SoundFileSell="email.wav"; extern bool SendMailPossible = false; extern int SIGNAL_BAR = 1; extern int ArrOtstup = 5; bool SoundBuy = False; bool SoundSell = False; //---- indicator buffers double BufferUp[],BufferDn[]; int q,st; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { IndicatorBuffers(2); //---- drawing settings SetIndexStyle(0,DRAW_ARROW,2); SetIndexArrow(0,233); SetIndexStyle(1,DRAW_ARROW,2); SetIndexArrow(1,234); SetIndexBuffer(0,BufferUp);//стрелка синяя верх SetIndexBuffer(1,BufferDn);//стрелка красная вниз //---- name for DataWindow and indicator subwindow label IndicatorShortName("T3MA-ALARM ("+period+")"); //---- initialization done if(Digits==3 || Digits==5) q=10; else q=1; st=ArrOtstup*q; return(0);} int deinit() { Comment(""); ObjectDelete("low"); ObjectDelete("high"); return(0); } //+----------------------------------------------------------------------+ //| Moving Average of Oscillator | //+----------------------------------------------------------------------+ int start() { //---- ArraySetAsSeries -------------------------------------------------- double Ma[500],MaOn[500]; double y0[500],y1[500],y2[500]; int i,limit=ArraySize(Ma); ArraySetAsSeries(Ma,true); //---- IndicatorCounted -------------------------------------------------- int counted_bars=IndicatorCounted(); int limit1=Bars-counted_bars; if (limit1>1){limit1=Bars-period-1;} //---- EMA --------------------------------------------------------------- for(i=limit1; i>=0; i--) Ma[i] =iMA(NULL,0,period,0,MODE_EMA,PRICE_CLOSE,i); for(i=limit1; i>=0; i--) MaOn[i]=iMAOnArray(Ma,limit,period,0,MODE_EMA,i); for(i=limit1; i>=0; i--) { y0[i+shift]=MaOn[i+shift]; y1[i+1+shift]=MaOn[i+1+shift]; y2[i+2+shift]=MaOn[i+2+shift]; if(y0[i+shift]-y1[i+1+shift]<0 && y1[i+1+shift]-y2[i+2+shift]>0){BufferDn[i+1]=High[i+1]+st*Point;} if(y0[i+shift]-y1[i+1+shift]>0 && y1[i+1+shift]-y2[i+2+shift]<0){BufferUp[i+1]=Low[i+1]-st*Point;} //---- Signal Trend Up || Dn --------------------------------------------- if(y0[i]-y1[i+1]>0) Comment ("\n SWAPLONG = ",MarketInfo(Symbol(),MODE_SWAPLONG), " SWAPSHORT = ",MarketInfo(Symbol(),MODE_SWAPSHORT),"\n BUY TREND ",DoubleToStr(Close[i],Digits)); else if(y0[i]-y1[i+1]<0) Comment ("\n SWAPLONG = ",MarketInfo(Symbol(),MODE_SWAPLONG), " SWAPSHORT = ",MarketInfo(Symbol(),MODE_SWAPSHORT),"\n SELL TREND ",DoubleToStr(Close[i],Digits)); } //+------------------------------------------------------------------+ string message = StringConcatenate("T3MA_ALARM (", Symbol(), ", ", Period(), ") - BUY!!!" ,"-" ,TimeToStr(TimeLocal(),TIME_SECONDS)); string message2 = StringConcatenate("T3MA_ALARM (", Symbol(), ", ", Period(), ") - SELL!!!","-" ,TimeToStr(TimeLocal(),TIME_SECONDS)); if (BufferUp[SIGNAL_BAR] != EMPTY_VALUE && BufferUp[SIGNAL_BAR] != 0 && SoundBuy) { SoundBuy = False; if (UseSound) PlaySound (SoundFileBuy); if(AlertSound){ Alert(message); if (SendMailPossible) SendMail(Symbol(),message); } } if (!SoundBuy && (BufferUp[SIGNAL_BAR] == EMPTY_VALUE || BufferUp[SIGNAL_BAR] == 0)) SoundBuy = True; if (BufferDn[SIGNAL_BAR] != EMPTY_VALUE && BufferDn[SIGNAL_BAR] != 0 && SoundSell) { SoundSell = False; if (UseSound) PlaySound (SoundFileSell); if(AlertSound){ Alert(message2); if (SendMailPossible) SendMail(Symbol(),message2); } } if (!SoundSell && (BufferDn[SIGNAL_BAR] == EMPTY_VALUE || BufferDn[SIGNAL_BAR] == 0)) SoundSell = True; //+------------------------------------------------------------------+ //---- done return(0);} //+---------------------------------------------------------------------+