Order executed at a price out of candle range

 

Hi everyone!

Today at ICmarkets we sent few orders at 00:10 for market execution, in a real account. The problem is that the executed price is way out of the range of the candle. That means, it is supposed that a candle range should contain all executed prices during its time interval. Have you had a similar problem? 

Since my strategy uses historical data for walkforward optimization, such historical data should replicate past market operations.

I am attaching one example, with GBPUSD.

Thank you very much for any clue on how do deal with that.

Best regards!


Files:
GBPUSD.jpg  45 kb
 

you need to avoid placing orders between hours 22:00 and 02:00

spreads very high in that times 

or you may add some codes include max allowed spread but it is less reliable more than time filter

I am doing that with my expert

 
Wise advice 
 
You buy at the Ask and sell at the Bid.
  1. Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid / OrderClosePrice reaches it. Using the Ask±n, makes your SL shorter and your TP longer, by the spread. Don't you want the specified amount used in either direction?

  2. Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask / OrderClosePrice reaches it. To trigger at a specific Bid price, add the average spread.
              MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25

  3. The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (control+O) → charts → Show ask line.)
    Most brokers with variable spread widen considerably at end of day (5 PM ET) ± 30 minutes. My GBPJPY (OANDA) shows average spread = 26 points, but average maximum spread = 134.
 

Hi guys!

Thank you for the replies. But the point was not that. I know that when I send a market order it will be executed at bid (sell orders) or ask (buy orders) prices, and maybe some slippage according to book volume. 

The point here is that even after my buy order being executed, the high price of the candle did not change at all, as it was suposed to do. Please, take a look at the picture attached at my previous message. That picture was took after my order execution, not before.

Further, since EAs are optimized using past historical data provided by the broker, it is expected that such historical data to contain all order executions, at least from that broker. Otherwise any optimized EA may fail miserably using the trained parameter set.

 
geovanyb:

Hi guys!

Thank you for the replies. But the point was not that. I know that when I send a market order it will be executed at bid (sell orders) or ask (buy orders) prices, and maybe some slippage according to book volume. 

The point here is that even after my buy order being executed, the high price of the candle did not change at all, as it was suposed to do. Please, take a look at the picture attached at my previous message. That picture was took after my order execution, not before.

Further, since EAs are optimized using past historical data provided by the broker, it is expected that such historical data to contain all order executions, at least from that broker. Otherwise any optimized EA may fail miserably using the trained parameter set.

Your Buy will have been executed at the Ask price. Your chart and the candle only show the Bid price so your candle will not update to reflect the price of your order, because the Ask is not part of the candle prices.

 
geovanyb:
The candles are drawen by the Bid price , BUY was executed at Ask price , which was way higher , in your trained parameter set I think you used a smaller Spread input , so a maximum Spread limit must be implemented into the EA to avoid such situations .
 
Paul Anscombe:

Your Buy will have been executed at the Ask price. Your chart and the candle only show the Bid price so your candle will not update to reflect the price of your order, because the Ask is not part of the candle prices.

Oh God! You sure? That was not my understanding (until today) about what candles should represent. If historical candles only show executions at bid prices it is a real problem for training EAs, since in MT5 OHLC historical rates are used to simulate ticks in the "most accurate" testing mode

Just to exemplify what I am saying, I attached a picture below showing the historical data I downloaded from the broker using the CopyRates function. It is showing my order execution as well as candles. Historical data are the same we see at MT5 chart, and it also does not include my executed order price. 

So, considering this and the above comments, even in optimizing EAs, we should avoid time intervals with supposed low spreads. I say "supposed" just because during testing BID and ASK prices are generated from OHLC prices, and they do not correspond to reality, and any spread verification is useless.

Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Running MQL5 Program Properties
Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Running MQL5 Program Properties
  • www.mql5.com
A purchased licensed version allows at least 5 activations. The number of activations is specified by seller. Seller may increase the allowed number of activations
 
geovanyb: Oh God! You sure?
What part of #3 was unclear to you?
 
William Roeder:
What part of #3 was unclear to you?
Yes, it is cristal clear. The problem is how reliable is EA optimization using historical rates. I edited my previous message including historical rates obtained from the same broker.
 
They are just as reliable as live trading. Charts show Bid prices. You buy at the Ask. Nothing is wrong.
Reason: