Download MetaTrader 5

Identifying Moving Average Candle crossover.

To add comments, please log in or register
Do you want to write a trading robot? Find solution in MQL5 Reference!
salirazataqvi
16
salirazataqvi 2015.12.14 11:43 

Hi All,

 

I want to know that how to identify that Moving Average line has crossed candle. please tell me what method or logic I can use to identify Moving Average Candle crossover. 

Thanks. 

Stuart Browne
5817
Stuart Browne 2015.12.14 11:55  
salirazataqvi:

Hi All,

 

I want to know that how to identify that Moving Average line has crossed candle. please tell me what method or logic I can use to identify Moving Average Candle crossover. 

Thanks. 

Depending on if you want the current live candle or the previous closed candle, pseudo code would be something like:

if ( (close[1] < MA[1] ) && (close[0] > MA[0])  )
 // candle broke above MA

if ( (close[1] > MA[1] ) && (close[0] < MA[0])  )
 // candle fell below MA
salirazataqvi
16
salirazataqvi 2015.12.15 05:34  
Stuart Browne:

Depending on if you want the current live candle or the previous closed candle, pseudo code would be something like:

To add comments, please log in or register