Order close check

 

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 

 
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.
 
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.
 
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;
 
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 () 

 
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. 

 
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()

Reason: