Topic: Bug that results in different backtest results in MT4
Fellow FSB'ers,
I think I've found a bug, which results in different backtesting in FSB and MT4. My EA opens, adds or reduces the same amount at the beginning of each day. So it's basically continually in the market. But it has a stop loss and a take profit, which closes all open positions. Now, in the FSB a take profit was hit, which closed all open orders (4 "units" long), but in the MT4, it didn't close the 4 open long positions (-> screenshot, blue circle, daily chart)
I went through the backtest, bar by bar, in MT4 in Every Tick and Control Points mode, watching the stop losses and take profits. That's where I found the bug. Generally, with a "continual" EA, when a new position is opened in MT4, the stop losses and take profits of all open positions are adjusted at the opening of the new position. So all open positions now have the same take profit and stop loss. But in FSB, the point in time, where stop losses and take profits are adjusted, is at the end of the current bar, in which the new position was opened (the image can be enlarged). So if a new position is opened at the beginning of the bar, the stop losses and take profits are not immediately updated, so they can still be hit during that bar.
The day with the blue circle in the screenshot, is a bar where a new position is opened at the beginning of the day and the old take profits are hit later in that day (daily chart), as can be seen on the FSB side in the above screenshot. On the MT4 (left) side, the take profit and stop losses are updated too soon (with the opening of the position at the beginning of the day), so the old take profit isn't hit.
Below it is step by step (on the left side, the old take profit is still in place, on the right side, the opening of the new positions changes the take profit immediately, so the old take profit can't be hit anymore)
This results it quite the distortions over a longer period of time. Please fix it.