How to ensure a pending order is executed ONLY when current spread is within the defined range ?

 

Hi all, 


A pending order was issued at 10am with a target price of X.  At 11am price reached X so the pending order becomes a market order.

Question is how to prevent that if current Spread is above a certain value?


Any idea ?

 
Alireza:

Hi all, 


A pending order was issued at 10am with a target price of X.  At 11am price reached X so the pending order becomes a market order.

Question is how to prevent that if current Spread is above a certain value?


Any idea ?

Yes, don't work with pending orders. If they become triggered, you have no chance to influence at which spread they are executed.

You can only solve that via an EA that checks if the target price has been reached, then checks the spread, and then places the order.

 
Daniel Stein #:

Yes, don't work with pending orders. If they become triggered, you have no chance to influence at which spread they are executed.

You can only solve that via an EA that checks if the target price has been reached, then checks the spread, and then places the order.


Thank you very much Daniel.

 
Alireza: Question is how to prevent that if current Spread is above a certain value?

Don't use pending orders.

There is no need to create pending orders in code.

  1. The pending has the slight advantage, A) you are closer to the top of the queue (filled quicker), B) there's no round trip network delay (filled quicker.)

    Don't worry about it unless you're scalping M1 or trading news.

  2. Humans can't watch the screen 24/7, so they use pending orders; EAs can, so no need for pending orders, have it wait until the market reaches the trigger price and just open an order.

 
William Roeder #:

Don't use pending orders.

There is no need to create pending orders in code.

  1. The pending has the slight advantage, A) you are closer to the top of the queue (filled quicker), B) there's no round trip network delay (filled quicker.)

    Don't worry about it unless you're scalping M1 or trading news.

  2. Humans can't watch the screen 24/7, so they use pending orders; EAs can, so no need for pending orders, have it wait until the market reaches the trigger price and just open an order.

Thank you very much William ,

So I plan to change the EA so it can monitor the current Ask/Bid prices, verifying if they have met the target price, and then reassessing the signal validity before placing the order.

 
Your topic has been moved to the section: Expert Advisors and Automated Trading
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893