I created a EA using Expert Advisor (generate), when i use backtest everything works fine, tp and sl works perfectly, but when i use the EA in the real market everything stops working. The EA opens a position and adds tp and sl but before the trade ends it starts another one but this time it does not add tp and sl, it keeps opening new positions but without respecting the sl and tp or adding them.
Is there someway to fix this? I would like the EA to do only one trade at a time, add and respect tp and sl, and again, it does everything it is supposed to do using backtest, but in real market everything is a mess.
I did not wrote the code, just used the Expert Advisor(generate).
Using backtest, this is how it looks.
This is real market
Without going deeper, a "patch" that might work, if you just want to prevent it from starting another trade while one is ongoing, is to add the highlighted line below:
void OnTick() { if (PositionsTotal()==0) ExtExpert.OnTick(); }
Without going deeper, a "patch" that might work, if you just want to prevent it from starting another trade while one is ongoing, is to add the highlighted line below:

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I created a EA using Expert Advisor (generate), when i use backtest everything works fine, tp and sl works perfectly, but when i use the EA in the real market everything stops working. The EA opens a position and adds tp and sl but before the trade ends it starts another one but this time it does not add tp and sl, it keeps opening new positions but without respecting the sl and tp or adding them.
Is there someway to fix this? I would like the EA to do only one trade at a time, add and respect tp and sl, and again, it does everything it is supposed to do using backtest, but in real market everything is a mess.
I did not wrote the code, just used the Expert Advisor(generate).
Using backtest, this is how it looks.
This is real market