Download MetaTrader 5
To add comments, please log in or register
Install apps from the library right in MetaTrader. It is easy!
fxtrader_
247
fxtrader_ 2015.10.19 09:38 

Hi All,


I'm trying to write a Alert condition as it showing in the image.


I wrote the following code for that condition .


Is it right because I get the alert In the candle 1??? while need it the alert in candle 0




   double MA_0 = iMA(NULL,0,MaPeriod,0,MA_Method,MA_Price,0);// bar 0
   double MA_1 = iMA(NULL,0,MaPeriod,0,MA_Method,MA_Price,1);// bar 1
   double MA_2 = iMA(NULL,0,MaPeriod,0,MA_Method,MA_Price,2);// bar 2

   double CrossDown = Close[2] > MA_2 && Close[1] < MA_1 && Close[0] < Close[1] && Volume[0] ==1;

         static datetime MostRecentBarStart=0;
         if (Time[0] != MostRecentBarStart && CrossDown )
         
         {
                 MostRecentBarStart = Time[0];
                  Alert("Close Down : "+ Symbol(), " ");
         }

whroeder1
13600
whroeder1 2015.10.19 11:14  
 double CrossDown = Close[2] > MA_2 && Close[1] < MA_1 && Close[0] < Close[1] && Volume[0] ==1;
  1. Bars is unreliable (a refresh/reconnect can change number of bars on chart) volume is unreliable (miss ticks) Always use time. New candle - MQL4 forum
  2. You are only looking at the start of a new bar.
fxtrader_
247
fxtrader_ 2015.10.19 12:22  

Ok I will remove that , what about other code is it ok??


Thanks
/
To add comments, please log in or register