Compare signals from 3 different indicators which need to be true within 5 bars of the first becoming true

 
Hi,

I'm trying to compare indicator values from 3 different indicators to generate a signal to place a trade. However I'm not sure to go about it.

What I'm trying to do is to check for:
  1. Any 1 of the 3 indicators to become true. Store this result
  2. Once 1 of them has become true, continue checking for at least 1 of the other 2 to become true. Store this result. Check whether the result in point 1 is still true/or some other condition.
  3. If 2 out of 3 has become true, continue checking for the final indicator to become true. Check whether the result in point 1 and 2 and is still true/or some other condition
  4. Set some variable to a "buy" or "sell", then execute the trade with some other code. Check whether the result in point 1,2,3 is still true/or some other condition
My code below was what I originally came up with but reading it again for the nth time, it does not look right to me. Racking my brains here. I was thinking to have 3 different if statements for any 1 of the 3 being true and store the result into an array/variable somewhere. Any ideas??

Thanks in advance

if(
   (signal1[0] > 0 ||  signal1[1] > 0 ||  signal1[2] > 0 ||  signal1[3] > 0 ||  signal1[4] > 0) &&
   (signal2[0] == 2 || signal2[1] == 2 || signal2[2] == 2 || signal2[3] == 2 || signal2[4] == 2) &&
   (signal3[0] == 1 || signal3[1] == 1 || signal3[2] == 1 || signal3[3] == 1 || signal3[4] == 1)
) 
glSignal = SIGNAL_BUY;

else if(
   (signal1[0] < 0 ||  signal1[1] < 0 ||  signal1[2] < 0 ||  signal1[3] < 0 ||  signal1[4] < 0) &&
   (signal2[0] == 1 || signal2[1] == 1 || signal2[2] == 1 || signal2[3] == 1 || signal2[4] == 1) &&
   (signal3[0] == 2 || signal3[1] == 2 || signal3[2] == 2 || signal3[3] == 2 || signal3[4] == 2)
) 
glSignal = SIGNAL_SELL;

Documentation on MQL5: Integration / MetaTrader for Python / order_calc_margin
Documentation on MQL5: Integration / MetaTrader for Python / order_calc_margin
  • www.mql5.com
order_calc_margin - MetaTrader for Python - Integration - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
Reason: