Workaround or bug in fxdreema loop?
-
Backtest in MT4 and I think there is a bug in my code. Can someone please take a look.
After Stop Loss, EA suppose to count the loss money -46.95 and calculate the recovery lot size for next order. It is working fine when there is only 1 Stop Loss order.
However, when there are 2 stop loss orders closed, the ea during backtest only calculate the loss for 1 order and use the lot size for next 2 orders.
order #32 after SL -46.95 should open buy order 0.11/0.12 but instead it open order with lot size 0.04
order #33 after SL -16.95 should open buy order 0.04 which is correct
-
@edmundtan You are using the same variable for buys and sells and I don't see when or where are theu reinitialized. Additionally, you are using a 'For each trade' block immediately below the block doing exactly the same: both take the most recent trade. You can remove the 'For each trade' block.
-
Thanks. I have fixed it with your advice.
-
@edmundtan You're welcome.