Example.... Half of those are from the initial trade, half from the martin order conditions (censored comments cuz they contained expressions that violate forum rules but expressed my inner anger at the time, and now).
Image attached.
Everything seems fine. But EA usually opens multiple trades in the same second... The way I built it is very linear and i can't seem to spot the logical mistake. It is basically a random martingale EA to test stuff out. Any indicator (that's why I called it random, haven't decided myself) can be put in there.
Basic idea is that it has an upper and lower threshold which determines when it is in buy zone and when at sell zone. Once it is in either zone, if trend goes against it (determined by indicator's value, not symbol's price) it opens another trade with the same SL/TP of the initial order. Also it checks whether initial trade still runs so it does not open other ones and once the initial trade is open. After that the criterias about the rest of the trades (that go against the trade are different).
The problem is that it opens multiple trades at times that it shouldn't, or like 3-4 trades within the same second or two. Any idea why this happens?
When you check the signal, you are resetting first_trade to false if there is no signal, therefore it is now free to place another trade
it is normally best practice to monitor and control the item you want controlled, so if you want to limit trades, monitor and control the trades to ensure you don't open more than desired.
At present you are monitoring a signal and trying to control a flag from that to decide if a trade is allowed or not, you are not actually monitoring and controlling the trade situation itself.
When you check the signal, you are resetting first_trade to false if there is no signal, therefore it is now free to place another trade
it is normally best practice to monitor and control the item you want controlled, so if you want to limit trades, monitor and control the trades to ensure you don't open more than desired.
At present you are monitoring a signal and trying to control a flag from that to decide if a trade is allowed or not, you are not actually monitoring and controlling the trade situation itself.
So how you suggest I fix this situation as it's not really a good EA. I don't want to make it restart proof (to recognise past trades etc). I basically only want to make it backtestable. At this point can I patch this easily or do I have to rebuild it the proper way? Also thanks for the tips so far!
So how you suggest I fix this situation as it's not really a good EA. I don't want to make it restart proof (to recognise past trades etc). I basically only want to make it backtestable. At this point can I patch this easily or do I have to rebuild it the proper way? Also thanks for the tips so far!
you could use the freelance section to get somebody to code it properly for you
https://www.mql5.com/en/job
![Trading applications for MetaTrader 5 to order Trading applications for MetaTrader 5 to order](https://c.mql5.com/36/46/trading-applications-for-metatrader__3.png)
- 2021.03.10
- www.mql5.com
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Everything seems fine. But EA usually opens multiple trades in the same second... The way I built it is very linear and i can't seem to spot the logical mistake. It is basically a random martingale EA to test stuff out. Any indicator (that's why I called it random, haven't decided myself) can be put in there.
Basic idea is that it has an upper and lower threshold which determines when it is in buy zone and when at sell zone. Once it is in either zone, if trend goes against it (determined by indicator's value, not symbol's price) it opens another trade with the same SL/TP of the initial order. Also it checks whether initial trade still runs so it does not open other ones and once the initial trade is open. After that the criterias about the rest of the trades (that go against the trade are different).
The problem is that it opens multiple trades at times that it shouldn't, or like 3-4 trades within the same second or two. Any idea why this happens?