I need help with piece of code.

 
Hi! 
I have a MT5 EA that open/close orders at first closed candle reversion. I need to modify it to open/close orders at second closed candle.

The original code is:

//---
      FastMAPrevious = iClose(_Symbol,0,2);
      FastMACurrent  = iClose(_Symbol,0,1);
      SlowMAPrevious = iOpen(_Symbol,0,2);
      SlowMACurrent  = iOpen(_Symbol,0,1);
     }
   else
     {
      FastMAPrevious = iClose(_Symbol,0,1);
      FastMACurrent  = iClose(_Symbol,0,0);
      SlowMAPrevious = iOpen(_Symbol,0,1);
      SlowMACurrent  = iOpen(_Symbol,0,0);
     }
//--- CONDITION CHECK
   if(!ReverseCondition)
     {
      //--- BUY CONDITION   
      BuyCondition=(FastMAPrevious<SlowMAPrevious && FastMACurrent > SlowMACurrent);
      //--- SELL CONDITION   
      SellCondition=(FastMAPrevious>SlowMAPrevious && FastMACurrent<SlowMACurrent);
     }
   else
     {
      //--- BUY CONDITION   
      SellCondition=(FastMAPrevious<SlowMAPrevious && FastMACurrent>SlowMACurrent);
      //--- SELL CONDITION   
      BuyCondition=(FastMAPrevious>SlowMAPrevious && FastMACurrent<SlowMACurrent );
     }

Can anyone help me?
 
ZeduTrader:vI have a MT5 EA that open/close orders at first closed candle reversion. I need to modify it to open/close orders at second closed candle.
  1. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor

  2. FastMAPrevious = iClose(_Symbol,0,2);
    FastMACurrent  = iClose(_Symbol,0,1);
    SlowMAPrevious = iOpen(_Symbol,0,2);
    SlowMACurrent  = iOpen(_Symbol,0,1);
    1) your code is not a moving average (MA) 2) is not a fast or slow.

  3. Your posted code does not open/close any orders.
 
William Roeder:
  1. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor

  2. 1) your code is not a moving average (MA) 2) is not a fast or slow.

  3. Your posted code does not open/close any orders.
Yes! It was an MA cross code, but not now. Just the name remained MA. Not consider it.

This EA is workink very well and open/close order at reversal candle. I just want to modify it to open after close of second candle.
 
ZeduTrader:
Yes! It was an MA cross code, but not now. Just the name remained MA. Not consider it.

This EA is workink very well and open/close order at reversal candle. I just want to modify it to open after close of second candle.

Set a GLOBAL FLAG and open/close later after close of second candle, then CLEAR the flag.

Reason: