I need help for an EA ?

 
How can I write this EA :

1 - Open 1 StopBuy 0.01 at Price + 20 and 1 StopSell 0.01 at Price -20, TP 20.
2 - If one order executed, cancel other.
3 - If executed order is a buy order, reverse sell 1 StopSell double (0.02) at entryprice -20 or opposite if sell order.
4 - and each time a stop order is executed reverse double 20 points far, till TP is executed.Then close all open orders for this pair.

Thanks for help.

Jo
 
How can I write this EA :

1 - Open 1 StopBuy 0.01 at Price + 20 and 1 StopSell 0.01 at Price -20, TP 20.
2 - If one order executed, cancel other.
3 - If executed order is a buy order, reverse sell 1 StopSell double (0.02) at entryprice -20 or opposite if sell order.
4 - and each time a stop order is executed reverse double 20 points far, till TP is executed.Then close all open orders for this pair.

Thanks for help.

Jo

You can find a good start in OCO orders script http://www.mqlservice.com/download/scripts/OCO.mq4
 
Thanks Michal for your help.
I have downloaded the script and tried it, after putting 20 in Buy Take Profit and Sell Take Profit, with BuyLots and SellLots at 1 and 0.1. Of course face is smiling.

But I have "Error 4107 Invalid price parameter for trade function" or "Error 4109 trade is not allowed in the Expert Properties"

Can you help for that ?

Also have you ideas to code points 3 and 4 of my question ?

Again thank you for your interest.

Jo
 
Thanks Michal for your help.
I have downloaded the script and tried it, after putting 20 in Buy Take Profit and Sell Take Profit, with BuyLots and SellLots at 1 and 0.1. Of course face is smiling.

But I have "Error 4107 Invalid price parameter for trade function" or "Error 4109 trade is not allowed in the Expert Properties"

Can you help for that ?

Also have you ideas to code points 3 and 4 of my question ?

Again thank you for your interest.

Jo

This is a script and should be put in experts/scripts directory. The reason for it is that I want to run it only once.
You don't get smiling face for scripts, but should see blinking label.

Perhaps, you should read heder of the OCO.mq4. You need to enable trades in Tools->Options->Experts.