Download MetaTrader 5

Order close check

To add comments, please log in or register
Publish your article. We will translate it into other languages!
Soumia Ouhammouch
168
Soumia Ouhammouch 2016.07.31 14:54 

Hi,

 I'm newbie to MQL dev and I need help;

 I've built a small EA that open a serie of trades and perding orders, it's a hedge system. I have 2 orders 1 buy and 1 sell open at the same price, I have pending orders above and below those orders.

My goal is to delete pending orders; delete pending below the price when buy is closed by take profit and like that delete pending orders above the price when sell is closed by tale profit.

Simply my pending will assume that the trend is in the same direction of the closed trade.

Can you help me please?

Thanks in advance.

 Med Taha 

Soumia Ouhammouch
168
Soumia Ouhammouch 2016.07.31 14:56  
kayserex:

Hi,

 I'm newbie to MQL dev and I need help;

 I've built a small EA that open a serie of trades and perding orders, it's a hedge system. I have 2 orders 1 buy and 1 sell open at the same price, I have pending orders above and below those orders.

My goal is to delete pending orders; delete pending below the price when buy is closed by take profit and like that delete pending orders above the price when sell is closed by tale profit.

Simply my pending will assume that the trend is in the same direction of the closed trade.

Can you help me please?

Thanks in advance.

 Med Taha 

I've tried with a for loop to check if the first 2 orders still exists by a specific magicnumber but I enter a infinite loop, and when I sort to out from the for loop all orders are deleted before the TP is reached.
Soumia Ouhammouch
168
Soumia Ouhammouch 2016.07.31 14:57  
kayserex:
I've tried with a for loop to check if the first 2 orders still exists by a specific magicnumber but I enter a infinite loop, and when I sort to out from the for loop all orders are deleted before the TP is reached.
The solution would be to enter the loop at each tick, do the check and out, but I don't know how to do that.
Marco vd Heijden
Moderator
4708
Marco vd Heijden 2016.07.31 16:05  
kayserex:
The solution would be to enter the loop at each tick, do the check and out, but I don't know how to do that.
break;
Soumia Ouhammouch
168
Soumia Ouhammouch 2016.07.31 16:10  
kayserex:
The solution would be to enter the loop at each tick, do the check and out, but I don't know how to do that.

Got it by my self :)

I used Ontick () 

Soumia Ouhammouch
168
Soumia Ouhammouch 2016.07.31 16:12  
Marco vd Heijden:

Thanks Marco but I need a continuous check :)

Ontick did the job so it enter the loop on each tick and check if the first pending order in the list is executed then delete the opposit ones.

Thanks again. 

Marco vd Heijden
Moderator
4708
Marco vd Heijden 2016.07.31 18:23  
kayserex:

Thanks Marco but I need a continuous check :)

Ontick did the job so it enter the loop on each tick and check if the first pending order in the list is executed then delete the opposit ones.

Thanks again. 

it will still run on each tick.

if you need a more resolute interval you can also use OnTimer()

To add comments, please log in or register