Download MetaTrader 5

MA alert is not working properly. Can you help please???

To add comments, please log in or register
Examine the Top MetaTrader 5 signals. Choose the best one and subscribe to it!
junforex
6
junforex 2015.04.02 18:20 

Hi all, 

I'm trying to get alert once 20SMA and 50SMA meet or crossover each other

and I modified existing code and applied it. I can get a "BUY" alert correctly, but "SELL" alert is not working. 

I attached current my code here. Could you anyone help me why "SELL" alert is not triggered? 

 

//+------------------------------------------------------------------+

//| Custom indicator iteration function                              |

//+------------------------------------------------------------------+

int start()

  {

   int counted_bars=IndicatorCounted();

   int limit=Bars-counted_bars;

   if (limit<0) limit=0;

   

   // define MAs values

   for (int i=limit; i>=0; i--)

      {

       Fast[i]=iMA(NULL, 0, Fast_MA_Period, Fast_MA_Shift, Fast_MA_Method, Fast_MA_Apply, i);

       Slow[i]=iMA(NULL, 0, Slow_MA_Period, Slow_MA_Shift, Slow_MA_Method, Slow_MA_Apply, i);

      }


   // Alert

      {

       // buy alert

       if ((New_Candle() && Fast[0] > Slow[0] && Fast[1] <= Slow[1]))

         {

          if (ScreenAlert) Alert("BUY - "+Symbol()," | ",TimeToStr(CurTime(),TIME_DATE)," | ",TimeHour(CurTime()),":",TimeMinute(CurTime())," | Period=",Period());

          if (PushAlert) SendNotification("BUY -"+Symbol());

         }

       // sell alert

       if ((New_Candle() && Fast[0] < Slow[0] && Fast[1] >= Slow[1]))

         {

          if (ScreenAlert) Alert("SELL - "+Symbol()," | ",TimeToStr(CurTime(),TIME_DATE)," | ",TimeHour(CurTime()),":",TimeMinute(CurTime())," | Period=",Period());

          if (PushAlert) SendNotification("SELL - "+Symbol());

         }

      }

   

   return(0);

  }

To add comments, please log in or register