Invalid Price on a BuyStops of BuyLimit order

 

When I try to create a BuyStops of BuyLimit order which is too close to the current Ask price (even though the price I want to buy at is the correct side of the Ask price) I get an invalid price error.

Is there any way I could detect when this will happen before attempting the order?

 
chris_turner:

When I try to create a BuyStops of BuyLimit order which is too close to the current Ask price (even though the price I want to buy at is the correct side of the Ask price) I get an invalid price error.

Is there any way I could detect when this will happen before attempting the order?

Articles:

The checks a trading robot must pass before publication in the Market
The checks a trading robot must pass before publication in the Market
  • www.mql5.com
Before any product is published in the Market, it must undergo compulsory preliminary checks, as a small error in the expert or indicator logic can cause losses on the trading account. That is why we have developed a series of basic checks to ensure the required quality level of the Market products. If any errors are identified by the Market...
 
chris_turner:

When I try to create a BuyStops of BuyLimit order which is too close to the current Ask price (even though the price I want to buy at is the correct side of the Ask price) I get an invalid price error.

Is there any way I could detect when this will happen before attempting the order?

Interestingly, by posting the question, the mql5 website came up with a suggestion that have me the answer:


https://www.mql5.com/en/articles/2555#modify_in_freeze_level_prohibited

The checks a trading robot must pass before publication in the Market
The checks a trading robot must pass before publication in the Market
  • www.mql5.com
Before any product is published in the Market, it must undergo compulsory preliminary checks, as a small error in the expert or indicator logic can cause losses on the trading account. That is why we have developed a series of basic checks to ensure the required quality level of the Market products. If any errors are identified by the Market...
 

Hi Vladimir,

Sorry I haven't responded properly.  I dropped this for a while but I'm now back working on it.

Your first link helped my solve my problem as I was using the wrong Ask/Bid price when calculating my stop loss and take profit.  The specific documentation that made me realise was:

  • Buying is done at the Ask price — the TakeProfit and StopLoss levels should be compared to the Bid price.
  • Selling is done at the Bid price — the TakeProfit and StopLoss levels should be compared to the Ask price.

Regards

Chris.

Reason: