# Sequential precedence of indicators in an EA ? Who can help ?

Hi to you all in the forum,

I am now experimenting and studying mql5 for several months and despite a lot of research I could not find an example for my problem.

The trading idea is that a buy signal occurs if one of two moving average signals are positive and the RSI has first fallen below 30, then risen above 60 and then fallen to below 45 again before it rises to 50 or above.

The problem is to determine that the RSI conditions have to be fulfilled one after the other in a sequential precedence. Has anyone of you an idea how to solve this problem? I have copied my EA for you so that you can see my coding. Thanks a lot !

Andre

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

//|                                                       André .mq5 |

//|                                             https://www.mql5.com |

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

string signal;

string EURUSD;

int zaehler;

extern int MagicNumber = 55557;

int ticket;

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

//| Expert initialization function                                   |

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

int OnInit()

{

//---

//---

return(INIT_SUCCEEDED);

}

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

//| Expert deinitialization function                                 |

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

void OnDeinit(const int reason)

{

//---

}

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

//| Expert tick function                                             |

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

void OnTick()

{

//---

}

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

//---

//| expert start function                                            |

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

int start()

{

//----

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

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

double ma = iMA(EURUSD,0,135,0,MODE_SMA,PRICE_CLOSE,1);

double mat1 = (iMA(EURUSD,0,135,0,MODE_SMA,PRICE_CLOSE,0))/(iMA(NULL,0,135,1,MODE_SMA,PRICE_CLOSE,1));

double mat30 = (iMA(EURUSD,0,135,30,MODE_SMA,PRICE_CLOSE,0))/(iMA(NULL,0,135,31,MODE_SMA,PRICE_CLOSE,1));

double r30 = iRSI(EURUSD,30,18,PRICE_CLOSE,0);

double r60 = iRSI(EURUSD,0,18,PRICE_CLOSE,0);

double r45 = iRSI(EURUSD,0,18,PRICE_CLOSE,0);

double r50 = iRSI(EURUSD,0,18,PRICE_CLOSE,0);

int r30min = iLowest(r30,0,3,100,25);

int r60max = iHighest(r60,0,3,80,10);

int r40min = iLowest(r45,0,3,20,1);

if(mat1 > 0 || mat30 > 0 && r30min <= 30 && r60max >= 60 && r40min <= 45 && r50 > 50)

{

signal = "long";

}

else   {

}

return(0);

} 