Simple OCO - FINALLY!

Hey guys, I’ve been wandering all around the internet to find a simple automated Order Cancel Order EA. I haven’t found any so, I decided to learn some MQL4 and finally made it my own.

It’s a simple TWO TICKET OCO EA.

Works only for pending orders. For example, you have two pending orders that you want one of them to get cancelled as soon as the other one gets triggered.

It is pair independent, meaning that it doesn’t care if you mix two pairs to cancel each other.

How does it work?

Once you run it, you have to input two ticket numbers.

Example:

  1. NZD/JPY ---- BUYLIMIT (6555355) —Ticket_1
  2. NZD/JPY ---- SELLLIMIT (6555358) —Ticket_2

That’s it, you let the EA run, once one of the orders get’s triggered, the other gets cancelled.

Works with BUYSTOP & SELLSTOP orders as well.

I suggest you test it a few times on DEMO account just in case it has any bugs.
And make sure you ticket ‘Allow Live Trading’ on the EA’s COMMON TAB MENU.

I hope you enjoy it. Feel free to ask.

If you have any ideas how to make it better, please tell me.

Have fun. :smiley:

Download Link: https://rapidshare.com/files/1894315802/OCO_Simple.rar

a direct link to download. I will look at this I set up a lot of break out trades with pending orders this might be helpful if I will be away from my computer. Thanks

OCO_Simple.zip (806 Bytes)

I hope it helps Shr1k. Just let me know if it works please. I found out lately that for some reason, some scripts that I made, only worked on my computer! - Why did this happen? - I don’t have any clue! - I hope the situation for the EA is not the same. Orders sending and deleting is a bit tricky on MQL4.

If it doesn’t work, I have an older version I made last week.

Have fun.

Any follow-up on this?
I’ve downloaded the zip-file, but wanted to hear from you guys if there is anything new about it before testing it myself.

Cheers,
O.

Probably happened because the build for your computer was older or newer than the other machines. This is well known especially with build 403 and newer. Just a matter of updating to the newest build or recompiling in some cases.

Hi GicaEric,

thank you for this code!
Do you still use it, as it seems that the pending order gets a new ticketnumber when it is triggered.
And the old two Ticket_1 and Ticket_2 do not change, you can select them but the order_type will be still pending.

Kind regards