Close Pending Order When Buy Order or Sell Order Executed

 

Dear all,

I am creating my system to open two pending orders - BuyStop and SellStop

Next, I want it to Close or Delete one of the Stop order when Buy or Sell is executed.

Example:

Case 1: BuyStop and SellStop are Placed

BuyStop is executed - Buy. Then, SellStop should be closed.

Case 2: BuyStop and SellStop are placed

SellStop is executed - Sell. Then, BuyStop should be closed. 

Anyone knows how to code this in MetaEditor?

 

Thanks.  

 
sdas86:

Dear all,

I am creating my system to open two pending orders - BuyStop and SellStop

Next, I want it to Close or Delete one of the Stop order when Buy or Sell is executed.

Example:

Case 1: BuyStop and SellStop are Placed

BuyStop is executed - Buy. Then, SellStop should be closed.

Case 2: BuyStop and SellStop are placed

SellStop is executed - Sell. Then, BuyStop should be closed. 

Anyone knows how to code this in MetaEditor?

 

Thanks.  

 

 

You have to detect the "execution" of your pending order. One way is to check number of orders : count trade orders, count pending orders. When 'trades' increased by 1 and 'pendings' decreased by one, you have your trigger.
Reason: