Detect MA indicator line cross New comment [Deleted] 2015.03.24 19:51 Hello forum, good day.I´m trying to detect the moment when three MA indicators cross and know in which direction they are going. This is what have so far:input int MA_1_Period = 5; input int MA_2_Period = 10; input int MA_3_Period = 20; double MA_1 = iMA(NULL,0,MA_1_Period,0,MODE_SMA,PRICE_CLOSE,1); double MA_2 = iMA(NULL,0,MA_2_Period,0,MODE_SMA,PRICE_CLOSE,1); double MA_3 = iMA(NULL,0,MA_3_Period,0,MODE_SMA,PRICE_CLOSE,1); double Prev_MA_1 = iMA(NULL,0,MA_1_Period,0,MODE_SMA,PRICE_CLOSE,2); double Prev_MA_2 = iMA(NULL,0,MA_2_Period,0,MODE_SMA,PRICE_CLOSE,2); double Prev_MA_3 = iMA(NULL,0,MA_3_Period,0,MODE_SMA,PRICE_CLOSE,2); if ( MA_1 < Prev_MA_1 && MA_2 < Prev_MA_2 && MA_3 < Prev_MA_3 ) { if ( MA_1 < MA_2 && MA_1 < MA_3 && ( Prev_MA_1 >= Prev_MA_2 || Prev_MA_1 >= Prev_MA_3 ) ) { Print("Crossing Down"); } } if ( MA_1 > Prev_MA_1 && MA_2 > Prev_MA_2 && MA_3 > Prev_MA_3 ) { if ( MA_1 > MA_2 && MA_1 > MA_3 && ( Prev_MA_1 <= Prev_MA_2 || Prev_MA_1 <= Prev_MA_3 ) ) { Print("Crossing Up"); } } Would this be the correct way to do it? Your help will be much appreciated. Best regards and thank you, codeMolecules Bullish/Bearish engulfing; previous bar close in top/bottom 25% of the bar behind it (MQL4) MA of RSI and RSI Indicators in same window Detect trend reversal (MQL4) New comment
Hello forum, good day.
I´m trying to detect the moment when three MA indicators cross and know in which direction they are going. This is what have so far:
Would this be the correct way to do it? Your help will be much appreciated.
Best regards and thank you,
codeMolecules