Skip to content

Trade server return code

10015 TRADE_RETCODE_INVALID_PRICE

Invalid price: the order price is not valid for the symbol

What it means

The price in the request is not one the server accepts for this order. A price has to be a multiple of the symbol's tick size (SYMBOL_TRADE_TICK_SIZE, "Minimal price change"), have the symbol's number of digits, and fit the order type.

Common causes

  • A pending order price computed with arithmetic (an ATR multiple, a midpoint) and not rounded to the tick size.
  • Index and metal CFDs whose tick size is larger than one point, for example 0.25 or 0.5 while the price shows two digits.
  • A pending order on the wrong side of the market: a buy limit above the Ask or a buy stop below it.
  • A market order on Instant execution sent with the wrong side of the quote (the Bid for a buy).

A real scenario

An EA places breakout buy stops on an index CFD a fixed fraction of the daily range above the high. The computed price, for example 18234.37, has two decimals like the quote, but the symbol only trades in steps of 0.25, so every order is refused with 10015. Rounding to the tick size gave 18234.25 and the orders were accepted.

How to fix it

  1. Round every computed price to the tick size, then normalise it to SYMBOL_DIGITS.
  2. Check the side of a pending order against the current Bid and Ask before sending it.
  3. Use the Ask for buys and the Bid for sells, read just before the request.

Fixed MQL5 code

MQL5
#include <Trade/Trade.mqh>
CTrade trade;


double RoundToTick(const string symbol, const double price)
{
   double tick = SymbolInfoDouble(symbol, SYMBOL_TRADE_TICK_SIZE);
   int digits  = (int)SymbolInfoInteger(symbol, SYMBOL_DIGITS);
   if(tick <= 0.0)
      return NormalizeDouble(price, digits);
   return NormalizeDouble(MathRound(price / tick) * tick, digits);
}

bool PlaceBuyLimit(const double lots, double price)
{
   MqlTick t;
   if(!SymbolInfoTick(_Symbol, t))
      return false;
   price = RoundToTick(_Symbol, price);
   if(price >= t.ask)
   {
      Print("A buy limit must be below the Ask: use a buy stop for a price above it");
      return false;
   }
   return trade.BuyLimit(lots, price, _Symbol);
}

A focused example for MetaTrader 5: adapt names, magic number and limits to your EA, and test it on a demo account first.

EA Doctor rules that catch it

Sources

Get your EA fixed

Still failing with 10015? Send us the EA and the journal lines: we find the cause in the code and fix it. Or check it yourself first with the EA Doctor.