Scripts: Open two Market orders in opposite directions

 

Open two Market orders in opposite directions:

This simple script opens two Market orders in two opposite directions. The essence of this is when trading news, price often breaks out in one direction. So ideally executing this script shortly before the news release would imply that if a breakout occurs in one direction one of the market orders (the one in the wrong direction) will be closed by the price triggering the stop loss, while the order will be left open to accumulate profits.

It should be noted that this is not always this case, however the above example is just an illustration where one might require a script like this.

Whats more? This script is %100 compatible with ECN accounts that do not allow the stop levels alongside OrderSend function.

Author: Chidera Anakpe

Open two Market orders in opposite directions
Open two Market orders in opposite directions
  • www.mql5.com
This simple script opens two Market orders in two opposite directions. The essence of this is when trading news, price often breaks out in one direction. So ideally executing this script shortly before the news release would imply that if a breakout occurs in one direction one of the market orders (the one in the wrong direction) will be closed...
 

Hi Chidera Anakpe

This code didn't run , I put it in Script folder and run it, But didn't work

Could you pleas solve the problem

Thank in advance.

 
ahmedEdan:

Hi Chidera Anakpe

This code didn't run , I put it in Script folder and run it, But didn't work

Could you pleas solve the problem

Thank in advance.

What error did you get when you tried to run the script?
 

I have tried it and it just opened positions without tp and sl that was set. This is on FBS demo acc last two :


 
macosd:

I have tried it and it just opened positions without tp and sl that was set. This is on FBS demo acc last two :


You probably entered values that are not allowed by your broker. Check the experts log for more details

 
this is not working
 
allanforex:
this is not working

Use the updated version (V1.1), it has better error handling capabilities.

Reason: