EA is skipping some trades during backtesting.

 

Hello, I am new to MQL5 and may be missing something, that is why I need your help. I have simple EA that checks the performance of the indicator and it seems to work fine, but I found that it has ignored indicator conditions and hasn't opened trades several times. Can't seem to find the reason for such behavior. in the screenshot below I have marked two skipped signals with red lines. On other places with similar conditions there is no problem and trades were placed. Can you help me find the reason?  


https://www.mql5.com/en/charts/17771680/eurusd-d1-ftmo-s-r-missing-trades-in-backtesting

Chart EURUSD, D1, 2023.06.19 07:45 UTC, FTMO S.R.O., MetaTrader 5, Demo
Chart EURUSD, D1, 2023.06.19 07:45 UTC, FTMO S.R.O., MetaTrader 5, Demo
  • www.mql5.com
Chart EURUSD, D1, FTMO S.R.O.: Missing trades in backtesting
Files:
 

You should learn to debug your own code.

Either use the built-in debugger in MetaEditor, or track values by printing them out to the Experts log.

Code debugging - Developing programs - MetaEditor Help
  • www.metatrader5.com
MetaEditor has a built-in debugger allowing you to check a program execution step by step (by individual functions). Place breakpoints in the code...
 
Fernando Carreiro #:

You should learn to debug your own code.

Either use the built-in debugger in MetaEditor, or track values by printing them out to the Experts log.

Thank you for your reply. Following your advice I tried to create some sort of tracking for values and discovered something. to get last three bar values of an indicator I've used CopyBuffer function and when I printed values of each bar I noticed that values inside the buffer are not the exactly the same as indicator has given on that date. For example : If Values from indicator for three days were :

DATE 26.07.2022 27.07.2022 28.07.2022 
Indicator value on that date 1,00251 0,99975  0,99810
Buffer[0] 1,00218159 (should be data from 26.07.2022)* small difference but different value  1.00001608 (should be data from 27.07.2022)* not the same as it should be  0,99811960 (should be data from 28.07.2022)
Buffer[1]
1,00498193 (should be data from 25.07.2022) 1,00250768 (should be data from 26.07.2022)*now it is correct value  0,99975155 (should be data from 27.07.2022)* now it is correct as it should be
Buffer[2]
1,00684566 ( should be data from 24.07.2022) 1,00498193( should be data from 25.07.2022)  1,00250768 (should be data from 26.07.2022)

as you can see on the table above on 27th of july indicator gave one value but buffer registered another ( as later I calculated it is interpolated value from 26th and 28th of July) but on the bar of 28th  buffer value representing previous day value is showing what indicator showed on that day correctly. I can't understand why.

 
I think I found the issue with backtesting behaivor it is my fault. Buffer[0] getting values at the market opening first tick, while buffer[1] and buffer[2] are filled with bar close values.
 
Were you able to resolve this mql5 skipping trades? If so, how pls? 
 
If you trade the daily chart you should be aware that at the very beginning of the candle the market is not tradable.

You should see logs of attempts of EA trying opening trades.

If this not happens it can be that indicators you use are repainting past values, updating not only current buffer shift (0) but also previous. I don't think I need to specify how useless are indicators that regulate past chart based on future values :)
 
@harry amos #: Were you able to resolve this mql5 skipping trades? If so, how pls? 

Forum on trading, automated trading systems and testing trading strategies

EA not triggering buy or sell trades

Fernando Carreiro, 2024.11.05 14:17

Help with your code can only be provided if you show all relevant code and explain the issue in detail. Otherwise, you will have to hire a freelance coder to do it for you.