This is just a supposition, but it seems like your code is not properly coded to be event driven, and instead maybe using timing loops with the use of the sleep() function.
It is obviously something wrong in your code. However, if you need help with your code you will need to show it.
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
- www.mql5.com
Hey, thank you for your response Fernando.
No sleep functions at all in the code. The logic is: on close of the M15 candle if certain conditions are met, the code decides to send an sell/buy stop order, and on every tick the code checks if there is a certain condition and if so, removes the order completely or removes the order and sets a flag to put a new order on the current M15 candle close.
When going fast, the code does not remove the order and send another order on the close of the candle - and then 2 positions are executed instead of one, or instead of none depends on the situation. When going slower, everything works perfectly and the orders are deleted and managed correctly.
The on_tick function behaves differently in the strategy tester? It seems to be some kind of race condition or something.
If you have an idea on what can I check, I will be very happy for ideas. Later today I will share the relevant parts of the code for help.
This is just a supposition, but it seems like your code is not properly coded to be event driven, and instead maybe using timing loops with the use of the sleep() function.
It is obviously something wrong in your code. However, if you need help with your code you will need to show it.
0xEmil #: No sleep functions at all in the code. The logic is: on close of the M15 candle if certain conditions are met, the code decides to send an sell/buy stop order, and on every tick the code checks if there is a certain condition and if so, removes the order completely or removes the order and sets a flag to put a new order on the current M15 candle close. When going fast, the code does not remove the order and send another order on the close of the candle - and then 2 positions are executed instead of one, or instead of none depends on the situation. When going slower, everything works perfectly and the orders are deleted and managed correctly. The on_tick function behaves differently in the strategy tester? It seems to be some kind of race condition or something. If you have an idea on what can I check, I will be very happy for ideas. Later today I will share the relevant parts of the code for help.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hey all,
hopefully the subject is clear enough, but nonetheless I will try to explain the best I can.
I've written a EA to trade my custom strategy, and when testing it on a whole year (without visualization) iv'e noticed that there are some weird entries one after another that should not be possible.
I've selected the same dates when the wrong trades were executed, and gone into backtesting but with visualization on (meaning, I can see the chart and control the speed of forward movement) - and i've noticed that when the tester is on full speed the the wrong (extra one) order is sent and executed and when I'm going half speed on the same dates the order does not executed and is removed on time. I've yet to determine the exact reason this happening.
I wanted to know if any of you happen to experience it, and what can I check? When running the code "live" on demo account, everything seems to be alright, but I need to backtest years of data to ensure that the edge exists.
Extra info:
1. I know for sure that my code is not efficient at all, as it is the POC code - so I'm planning to make it FAR better, execution wise. So maybe it will help.
2. I'm using the last couple of years data from a IC-market demo account.
3. If needed I can provide a video proof of me going full speed and getting the "extra" trade and then going half speed and seeing the order removed on time.
This is the first EA that i've written, so I don't know if the strategy tester if flawed or it's just my shitty code.
Thank you.