You are counting OrderBuy and OrderSell only by one MagicNumber , make separate parameters for the 2 strategies like OrderBuy , OrderSell , and OrderBuy1 , OrderSell1 , counting each by its magic number .
Catalin Zachiu:
You are counting OrderBuy and OrderSell only by one MagicNumber , make separate parameters for the 2 strategies like OrderBuy , OrderSell , and OrderBuy1 , OrderSell1 , counting each by its magic number .
You are counting OrderBuy and OrderSell only by one MagicNumber , make separate parameters for the 2 strategies like OrderBuy , OrderSell , and OrderBuy1 , OrderSell1 , counting each by its magic number .
Thanks, I kinda get your idea, but I am not quite sure how I should modify it in my codes. Could you elaborate a little? Thanks!
Catalin Zachiu:
You are counting OrderBuy and OrderSell only by one MagicNumber , make separate parameters for the 2 strategies like OrderBuy , OrderSell , and OrderBuy1 , OrderSell1 , counting each by its magic number .
You are counting OrderBuy and OrderSell only by one MagicNumber , make separate parameters for the 2 strategies like OrderBuy , OrderSell , and OrderBuy1 , OrderSell1 , counting each by its magic number .
Hi, I added OrderBuy1 and OrderSell1 as you suggested and changed the codes to
if(Bars > BarsCount) { if((OpenBUY && OrderBuy<1 && ##Insert Buying Strategy 1 here##))OPBUY(); if((OpenBUY && OrderBuy1<1 && ##Insert Buying Strategy 2 here## ) )OPBUY1(); if(OpenSELL && OrderSell<1 && ##Insert Selling Strategy 1 here##)OPSELL(); if((OpenSELL && OrderSell1<1 && ##Insert Selling Strategy 2 here## ))OPSELL1(); BarsCount = Bars; } //--- close position by signal if(CloseBySignal) { if(OrderSell>0 && ##Close orders opened by Selling strategy 1##) CloseSell(); if(OrderSell1>0 && ##Close orders opened by Selling strategy 2## ) CloseSell1(); if(OrderBuy>0 &&( ##Close orders opened by Buying strategy 1## ))CloseBuy(); if(OrderBuy1>0 &&( ##Close orders opened by Buying strategy 2## ))CloseBuy1(); }
I am not sure if this is how you meant it, but the issue persists and that I still can't get it to close my open orders for strategy 2. What am I missing here? Should I modify the codes in CloseBuy1 and CloseSell1? Thanks
@William Roeder @Keith Watford
Sorry to bother you, I know you guys are experts, this should be a piece of cake for you, so I took the liberty to ask you guys, I wonder if you can help me, much appreciated! Apologies if you feel disturbed.


You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi, I am having some technical issues regarding selective order closing in MT4, and I would appreciate the help!
This is what I try to achieve:
I have two different strategies on buy orders and two different strategies on sell orders, and I would set up specific order closing conditions for orders opened by their specific strategies without letting the order closing conditions interfering with each other.
Here is how I attempted to solve this issue:
I set up two Buy commands, two Sell commands and two Close Buy commands and two Close Sell commands, namely OPBUY, OPBUY1, OPSELL, OPSELL1, CloseBuy, CloseBuy1, CloseSell, CloseSell1 in the codes I provide below as well as two different order magic numbers, which are MagicNumber(123) and Magic(321) in the codes. Among them, OPBUY, CloseBuy, OPSELL,CloseSell use MagicNumber whilst OPBUY1, CloseBuy1, OPSELL1,CloseSell1 use Magic.
However, it didn't work out the way I intended. It works fine when I use OPBUY, CloseBuy, OPSELL,CloseSell and MagicNumber for strategy 1, the EA can also open orders by OPBUY1, OPSELL1 and Magic for strategy 2, but it just won't trigger CloseBuy1 and CloseSell1 with Magic which puzzles the hell out of me and leave the open orders of strategy 2 hanging.
Is there anything that I did wrong here? What should I do to circumvent or solve this issue and make my two strategies compatible with each other in one EA?
Below is my codes, and thanks for your help!