Download MetaTrader 5

Order close check

To add comments, please log in or register
Soumia Ouhammouch
179
Soumia Ouhammouch  

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
179
Soumia Ouhammouch  
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
179
Soumia Ouhammouch  
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
5673
Marco vd Heijden  
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
179
Soumia Ouhammouch  
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
179
Soumia Ouhammouch  
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
5673
Marco vd Heijden  
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