//+------------------------------------------------------------------+ //| AO-AC_Cross_Alert_Limit(AM)Sintetic.mq4 | //| Andrey Matvievskiy | //+------------------------------------------------------------------+ #property copyright "Andrey Matvievskiy" #property indicator_chart_window #property indicator_buffers 4 #property indicator_color1 Blue #property indicator_color2 Red #property indicator_width1 3 #property indicator_width2 3 #property indicator_color3 Blue #property indicator_color4 Red #property indicator_width3 0 #property indicator_width4 0 extern bool SoundON=false; extern bool EmailON=false; //---- input parameters extern int AO_PeriodMA1 = 34; extern int AO_PeriodMA2 = 5; extern int AO_TypeMA1 = 0; extern int AO_TypeMA2 = 0; extern int AO_PriceMA1 = 4; extern int AO_PriceMA2 = 4; extern int AO_TF1 = 0; extern int AO_TF2 = 0; extern int AO_Shift1 = 0; extern int AO_Shift2 = 0; extern int AC_PeriodMA1 = 34; extern int AC_PeriodMA2 = 5; extern int AC_PeriodMA3 = 5; extern int AC_TypeMA1 = 0; extern int AC_TypeMA2 = 0; extern int AC_TypeMA3 = 0; extern int AC_PriceMA1 = 4; extern int AC_PriceMA2 = 4; extern int AO_AC_TF1 = 0; extern int AO_AC_TF2 = 0; extern int AO_AC_Shift1 = 0; extern int AO_AC_Shift2 = 0; extern int AO_AC_Shift3 = 0; extern int CountedBars = 300; double CrossUp1[]; double CrossDown1[]; double CrossUp2[]; double CrossDown2[]; int flagval1 = 0; int flagval2 = 0; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0, DRAW_ARROW, EMPTY); SetIndexArrow(0, 241); SetIndexBuffer(0, CrossUp1); SetIndexStyle(1, DRAW_ARROW, EMPTY); SetIndexArrow(1, 242); SetIndexBuffer(1, CrossDown1); SetIndexStyle(2, DRAW_ARROW, EMPTY); SetIndexArrow(2, 241); SetIndexBuffer(2, CrossUp2); SetIndexStyle(3, DRAW_ARROW, EMPTY); SetIndexArrow(3, 242); SetIndexBuffer(3, CrossDown2); SetIndexLabel(0,"AO+"); SetIndexLabel(1,"AO-"); SetIndexLabel(2,"AC+"); SetIndexLabel(3,"AC-"); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int limit, i, counter; double tmp=0; double X, Y, Z, A, B, C; double Range, AvgRange; int counted_bars=IndicatorCounted(); //---- check for possible errors if(counted_bars<0) return(-1); //---- last counted bar will be recounted if(counted_bars>0) counted_bars--; limit=CountedBars; for(i = 1; i <= limit; i++) { counter=i; Range=0; AvgRange=0; for (counter=i ;counter<=i+9;counter++) { AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]); } Range=AvgRange/10; X = iCustom(NULL, 0, "AO(AM)", AO_PeriodMA1, AO_PeriodMA2, AO_TypeMA1, AO_TypeMA2, AO_PriceMA1, AO_PriceMA2, AO_TF1, AO_TF2, AO_Shift1, AO_Shift2,0,i); Y = iCustom(NULL, 0, "AO(AM)", AO_PeriodMA1, AO_PeriodMA2, AO_TypeMA1, AO_TypeMA2, AO_PriceMA1, AO_PriceMA2, AO_TF1, AO_TF2, AO_Shift1, AO_Shift2,0,i+1); Z = iCustom(NULL, 0, "AO(AM)", AO_PeriodMA1, AO_PeriodMA2, AO_TypeMA1, AO_TypeMA2, AO_PriceMA1, AO_PriceMA2, AO_TF1, AO_TF2, AO_Shift1, AO_Shift2,0,i+2); A = iCustom(NULL, 0, "AC(AM)", AC_PeriodMA1, AC_PeriodMA2, AC_PeriodMA3, AC_TypeMA1, AC_TypeMA2, AC_TypeMA3, AC_PriceMA1, AC_PriceMA2, AO_AC_TF1, AO_AC_TF2, AO_AC_Shift1, AO_AC_Shift2, AO_AC_Shift3,0,i); B = iCustom(NULL, 0, "AC(AM)", AC_PeriodMA1, AC_PeriodMA2, AC_PeriodMA3, AC_TypeMA1, AC_TypeMA2, AC_TypeMA3, AC_PriceMA1, AC_PriceMA2, AO_AC_TF1, AO_AC_TF2, AO_AC_Shift1, AO_AC_Shift2, AO_AC_Shift3,0,i+1); C = iCustom(NULL, 0, "AC(AM)", AC_PeriodMA1, AC_PeriodMA2, AC_PeriodMA3, AC_TypeMA1, AC_TypeMA2, AC_TypeMA3, AC_PriceMA1, AC_PriceMA2, AO_AC_TF1, AO_AC_TF2, AO_AC_Shift1, AO_AC_Shift2, AO_AC_Shift3,0,i+2); CrossUp1[i] = 0; CrossDown1[i] = 0; CrossUp2[i] = 0; CrossDown2[i] = 0; if ((YY)) { if (i == 1 && flagval1==0) { flagval1=1; flagval2=0; if (SoundON) Alert("AO UP =",Ask,"\n Bid=",Bid,"\n Time=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period()); if (EmailON) SendMail("AO UP","AO UP ="+DoubleToStr(Ask,4)+", Bid="+DoubleToStr(Bid,4)+", Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period()); } CrossUp1[i] = Low[i] - Range*0.5; } if ((Y>X) && (Z