Do not open a new trade if one is already running with the same currency
-
I'm trying to get my EA to not open any new trade if there is already one trade open, unless this trade is already set to BreakEven or trails its stop in profit.
Example: EA opens trades in EURUSD - trade is not yet BE (or trails in profit) -> do not open any new trade with EUR as main currency or counter currency (same for USD).
If current trade is already BE (or trails in profit) a new trade with both, EUR and USD as main or counter currency, can be opened.Is there a way to handle this?
Greetings, M -
This might work, can't test right now... At the moment it only tests the currency, breakeven condition can be added later
https://fxdreema.com/shared/Q63lqaJ2b -
Thanks @roar
Will test it out tomorrow once the market is open

Just to be sure: i've added currentsym (string) and open_new (bool) - at least i got it to compile
-
Just tried it and got a stack overflow exc, any idea?
-
@mariofxn Hmm, maybe the loop goes mad if there are no trades... Lets put a "no trade" block at the very top, and skip the whole checking process if there are no running trades
-
@roar tried with no trade/order at the very top, still the same
-
@mariofxn When I put just that project to backtest, no errors.. Hope I'll remember to test this tomorrow, live market is just much easier
-
@roar i've tried to put the block elsewhere but it doesnt help.
Would be awesome if you could let me know what you get tomorrow in the live environment.Thanks
-
@mariofxn
https://fxdreema.com/shared/Fo6LLNiCc
I changed the loop filters, seems working now - if GBPUSD trade is open, the bot will not open new EURUSD trades.The breakeven is still not implemented. I can't help with that right now, having a really busy week...
-
@roar awesome, many thanks for the help. Will give it a try soonest
-
@roar works great, thanks a lot.
Maybe you find the time to also check the case where BE is hit, allowing the same symbol to be traded again.
Thanks much in advance
M -
@roar i'm still testing the current one; however i experience a lot of open trades on the same pair (as main- and counter currency)
F.e.: my EA opens a trade in GBPCAD with 1 sec between trades (i'm opening 3 trades at the same time right now)
1 sec later another GBPJPY opens (3x), followed by 3 more EURGBP trades 2 seconds after.I have 0 idea what i can do or where i shall place the loop so that this doesnt happen again, do you have any idea?
Right now, i have the loop at the very top on the onTick page, after that i check all my conditions based on the rules and start buying/selling whichever is applicable.
Any response is highly appreciated and needed.
Regards,
M -
@mariofxn Interesting.. So does the EA open too many trades on the same pair or the different pair? Do you intend to open multiple trades?
Could you share a version of your project so I can troubleshoot? You get the shared link form upper left corner