Reply

How to setup OCO (One-Cancel-Other) rule in EA Wizard.

2 replies

odomike

Subscriber, bbp_participant, community, 32 replies.

Visit profile

10 years ago #112086

Hi,

 

I am trying to create an EA that places pending orders but will delete one order once the other is hit by price. For instance, EA places a buy and sell stop, at a certain time, the buy stop is hit and EA automatically closes the sell stop and keeps managing the buy stop order till close of the trade.

 

I have looked through the THEN rule of pending orders and noticed a parameter there Replace Existing Order: True/False, but this does not exactly do what I want as it is only meant to replace existing pending orders with same magic number (correct me if I am wrong).

 

I have created a simple boolean rule which I believe should be able to handle what I want if integrated into my more complex EA strategy, but I want to make sure that it can handle it. It closes all pending sell stop orders when any of the pending buy orders are hit and vice-versa. I want it to delete the pending orders when the corresponding one in opposite direction is hit. Like … Pending Buy Stop 1 is hit, Close Pending Sell Stop 1. Should I separate everything into different rules or is there a way for me to integrate all into one single rule?

 

Attached is the strategy file for educational purposes. Anyone can modify and improve on it.

 

Mark please check my strategy and tell me if it is correct and possibly post the corrected version for me.

 

Thanks.

 

Michael

0

Mark Fric

Administrator, sq-ultimate, 2 replies.

Visit profile

10 years ago #124219

Hello Michael,

 

I checked the script and simplified it. There’s no need to check for OCO is True 3 times in the condition, I was also not sure about bracketing there.

 

Otherwise the idea is correct. If any of the long pending orders is filled it will cancel the short orders and vice versa.

 

Mark
StrategyQuant architect

0

odomike

Subscriber, bbp_participant, community, 32 replies.

Visit profile

10 years ago #124268

Wow Mark, I didn’t know that I could use just one bracket for multiple rules like that. That for the correction and support. I appreciate lots. Now I have to integrate this into my News Trading EA which I am creating with the help of EA Wizard.

 

Thanks once again.

0

Viewing 2 replies - 1 through 2 (of 2 total)