Traders and coders are working for free:
- if it is interesting for them personally, or
- if it is interesting for many members on this forum.
Freelance section of the forum should be used in most of the cases.

- 2024.12.18
- www.mql5.com
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
Hi , new to mql5,i conditioned my bot to open only one trade with a loop , but now i want it to open a new trade after the initial one is set to be . so the bot set's the sl to be but then opens inifite trade when the conditions are met again.
i will post the code here. any way that i can repeat the loop? The code to open the trade comes right after this loop function, everything works fine until the bot tries to open the second trade, i know the part where i set isPosOpen = false; is not good.
If you're only sending 2 orders within your code, just get rid of the second loop and isPosOpen, and then condition your second order send upon:
if(PositionsTotal() == 1)
If you're only sending 2 orders within your code, just get rid of the second loop and isPosOpen, and then condition your second order send upon:
well , thanks for your answer but i need more than 2 trades, i need the bot to keep opening trades when the conditions are met , only after the trade before is at be
well , thanks for your answer but i need more than 2 trades, i need the bot to keep opening trades when the conditions are met , only after the trade before is at be
You need to create a frequency and how often to check the signal conditions. Even if your code worked as you suggest, it would open a new trade on every tick that the signal condition was true.
I recommend that you download several ea codes from codebase and learn how those limit new trades to open at new candles, and/or whenever.
- 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 , new to mql5,i conditioned my bot to open only one trade with a loop , but now i want it to open a new trade after the initial one is set to be . so the bot set's the sl to be but then opens inifite trade when the conditions are met again.
i will post the code here. any way that i can repeat the loop? The code to open the trade comes right after this loop function, everything works fine until the bot tries to open the second trade, i know the part where i set isPosOpen = false; is not good.