Identifying Moving Average Candle crossover.

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. 

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
Stuart Browne:

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