Bid Ask Bar History Data

 


I am trying to program a strategy in MQL5 that requires the following history data:


   Bid bar history data required:      Open   High   Low   Close   Volume 

   Ask bar history data required:      Open   High   Low   Close   Volume


By history I mean a few bars previous to the current bar.

If anyone knows of a code which can get that information, and is willing to share it, I would be most grateful.




 
MathQuant:

I am trying to program a strategy in MQL5 that requires the following history data:


By history I mean a few bars previous to the current bar.

If anyone knows of a code which can get that information, and is willing to share it, I would be most grateful.

You can start by taking a look at this article: https://www.mql5.com/en/articles/60.
Creating Tick Indicators in MQL5
Creating Tick Indicators in MQL5
  • 2010.04.23
  • Denis Zyatkevich
  • www.mql5.com
In this article, we will consider the creation of two indicators: the tick indicator, which plots the tick chart of the price and tick candle indicator, which plot candles with the specified number of ticks. Each of the indicators writes the incoming prices into a file, and uses the saved data after the restart of the indicator (these data also can be used by the other programs)
 
Malacarne:
You can start by taking a look at this article: https://www.mql5.com/en/articles/60.


Thanks Malacarne, I will look again at that article more closely.

 
MathQuant:


I am trying to program a strategy in MQL5 that requires the following history data:


   Bid bar history data required:      Open   High   Low   Close   Volume 

   Ask bar history data required:      Open   High   Low   Close   Volume


By history I mean a few bars previous to the current bar.

If anyone knows of a code which can get that information, and is willing to share it, I would be most grateful.

You have to use CopyXXX function to get history data : CopyHigh(), CopyLow(), etc...
 

For the ask bar you will have "build" your own bar, using the ask tick prices.

Volume information is a bit diffcult, as the volume is just exchanged where the seller gets the bid price and the buyer pays the ask price

(and the difference between bid and ask, the spread, is for the "work" of the broker(-s) ).

So in my opinion from a single trade you have no way to say if it is a sell or buy volume, in other words the volume is just exchanged and the amount is identical for both sides.

Which of both parties has entered or left the market one cannot determine from the tick data feed.

So one has to look at the volumes in the context of price and time, and here I would split the volume between the ask and bid price.

 
angevoyageur:
You have to use CopyXXX function to get history data : CopyHigh(), CopyLow(), etc...

Thanks

 
ugo58:

For the ask bar you will have "build" your own bar, using the ask tick prices.

Volume information is a bit diffcult, as the volume is just exchanged where the seller gets the bid price and the buyer pays the ask price

(and the difference between bid and ask, the spread, is for the "work" of the broker(-s) ).

So in my opinion from a single trade you have no way to say if it is a sell or buy volume, in other words the volume is just exchanged and the amount is identical for both sides.

Which of both parties has entered or left the market one cannot determine from the tick data feed.

So one has to look at the volumes in the context of price and time, and here I would split the volume between the ask and bid price.


Thanks, I think you are right about building my own ask bars.

Regarding volume, if the broker is also the market maker, then it is possible for the broker to know whether the deal was initiated by a buyer or a seller.  In which case Bid Volume and Ask Volume can be meaningfully reported.  Check out the link in this post    https://www.mql5.com/en/forum/1678#comment_147023

MetaQuotes should seriously consider adding Ask Bar Charts to MT5.

 
MathQuant:


Thanks, I think you are right about building my own ask bars.

Regarding volume, if the broker is also the market maker, then it is possible for the broker to know whether the deal was initiated by a buyer or a seller.  In which case Bid Volume and Ask Volume can be meaningfully reported.  Check out the link in this post    https://www.mql5.com/en/forum/1678#comment_147023

I think MetaQuotes should seriously consider adding Ask Bar Charts to MT5.

Have you seen this poll ?
 
Malacarne:
Have you seen this poll ?


Yes, I added a reply a few days ago.