Download MetaTrader 5
To add comments, please log in or register
Share your knowledge. Become a well-known developer!
Ovo Cz
2950
Ovo Cz 2013.04.03 12:44 

When I work with Bid and Ask, I realized one (only one I know about) broker has different values for the chart and the MQL variables.

The value for Bid differs from the chart by constant of 5 tick (0.5 pip), as well the ask level in the chart is offset from the Ask variable by 5 ticks in the opposite direction.

This behaviour never changed with terminal updates and is still present with the last build of the MT4.

I asked the broker to fix the issue, but they let me know it was MT4 related, and that they could not do anything about it (which I doubt).


See the picture, the Ask&Bid lines are drawn from the MQL, while the chart displays the Bid price differently:

Shifted price. 

 

When using EA to open a new long trade, the price you get is the Bid. It is not the same value that comes from the close of the candle. Some of my EAs work incorrectly, as the chart has been formed by a shifted price.

 

Did you see it before? Does anyone have some more info, how to deal with the problem?

Simon Gniadkowski
Moderator
17963
Simon Gniadkowski 2013.04.03 13:03  
Ovo:

When I work with Bid and Ask, I realized one (only one I know about) broker has different values for the chart and the MQL variables.

The value for Bid differs from the chart by constant of 5 tick (0.5 pip), as well the ask level in the chart is offset from the Ask variable by 5 ticks in the opposite direction.

This behaviour never changed with terminal updates and is still present with the last build of the MT4.

I asked the broker to fix the issue, but they let me know it was MT4 related, and that they could not do anything about it (which I doubt).


See the picture, the Ask&Bid lines are drawn from the MQL, while the chart displays the Bid price differently:

Please take another screen shot with the trading window on top of your chart . . . like this

 

So the Bid can also be seen on the chart. 

Ovo Cz
2950
Ovo Cz 2013.04.03 13:31  

Here you are as requested.

  

Simon Gniadkowski
Moderator
17963
Simon Gniadkowski 2013.04.03 13:53  
Ovo:

Here you are as requested.

OK,  thank you, so it looks like you are reading the correct Bid and Ask, how are you doing this ? using Bid and Ask or MarketInfo()  MODE_BID and MODE_ASK  ?

 

One more request,  can you do the same as you did in your post above but this time on a vanilla EURUSD chart with no Indicators, EA or Script attached please. 

Ovo Cz
2950
Ovo Cz 2013.04.03 14:23  

I can, nevertheless, it is always in the chart and they confirmed they knew it in the e-mail.

When I take a poor MT4 installation from Metaquotes site, and add some live servers to it, I have the same result with this particular broker, while others are correct.

The MODE_BID, MODE_ASK, Bid, Ask, they all use the price which you get with an order, but every displayed regular chart is shifted, and so are the regular .hst files.


Weird, isn't it? 

 

 

Simon Gniadkowski
Moderator
17963
Simon Gniadkowski 2013.04.03 15:20  
Ovo:

Weird, isn't it? 

Extremely . . . .  I wonder if the cause is the same as this for thread:  https://www.mql5.com/en/forum/143082
Ovo Cz
2950
Ovo Cz 2013.04.03 16:38  
RaptorUK:
Extremely . . . .  I wonder if the cause is the same as this for thread:  https://www.mql5.com/en/forum/143082


It seems very probably to be the same issue, even though the shift is the other way round in the other case. 

So whatever the reason is, it is possible to feed the chart data with a different value than the trading price is.

It is at least confusing, in case you are watching as the chart price crosses your limit order by 0.4 pip and no order is filled. The orders are displayed correctly.

 

Now, another coding confusion - which price to use for an offline chart, the Bid or the Close[0]? While Close[0] makes it compatible with the online charts, the Bid makes it compatible with EAs. I am not sure, which is more acceptable. The difference between the Close[0] and Bid is constant that might be used to measure the correction.

troyhen
6
troyhen 2016.09.02 20:59  

I've noticed this with multiple brokers. Some have the bid-ask spreads tighter than the chart and some set them wider. I'm sure there is a reason, but I can only guess, which is that the chart data is coming from a different server than the broker's actual Bids.

Here's a simple equation to find out how much (if any) your broker chart differs from your actual broker bid. I put this in all of my EAs and use bidAdj whenever I need to compare actual prices to the chart data.

    double bidAdj = Close[0] - Bid;

Be careful of the sign. If your broker has narrower spreads than the chart this number will be negative. And if they are wider, it will be positive. Note, this number is to adjust the chart Bid/price only. If you want to know the full chart spread then you should double this number, since I've found that the amount the Bid is off is the same as the amount that the Ask is off, but in the other direction.

Mathematically, you would add bidAdj to convert from (or compare) chart data to actual. Subtract bidAdj to convert from (or compare) actual Bid to chart values.

One more interesting point. During EA testing the chart data is used rather than the brokers actual bid prices. But using this equation results in a 0 difference. Therefore, it's safe to always use this adjustment factor.

Never stop coding!

/
To add comments, please log in or register