how to code a Volume Delta indicator

0 votes

Hello, I've asked a similar question before (here) but since then I've been improving my ideas and would like to revisit the issue.

My goal is to develop a VOLUME DELTA indicator that can be used for history and real time data. It should be able to evaluate if a new trade was either a buy aggression or a sell aggression by comparing the trade price with both best bid and ask prices at the exact same moment. Since Amibroker doesn't have bid and ask history capabilities and that any development made on history data should be good to be used in real time, I came to the conclusion that I'd need to calculate past values using a script outside Amibroker and then load the indicator's final values into Amibroker tick by tick (so that each trade in the history have its corresponding indicator value). For real time feed I'd need to check live bid and ask data and write the values to the indicator history database. My questions:

1) What's the least resource-heavy method to store the indicator values for future use that enables me to update it on every single trade? I will use this indicator for backtest so speed is important. I've had bad experiences on other platforms reading TXT files, which turned to be a very slow process due to hard disk read times and searching times within the file

2) Is Amibroker able to read at the same time the trade price (market order) and best bid/ask prices (limit orders) from the times & trades? I cannot wait a microsecond as bid/ask prices are very volatile, because HFTs change them all the time. The ideal solution would be to gather trade price and best bid and ask prices at the same moment using a single function call, so I can guarantee that I'm reading the feed only once not risking to include any new information that could distort the result (such as a new bid or ask price). For instance, using GetRTData(''fieldname'') would yield me 3 distinct function calls (last; bid; ask), so my perspective is that in between these calls one of the variables could have been changed in real time. Another concern is the time elapsed between the identification that a new trade has happened and the return of the values from the function. Often HFTs change bid/ask prices according to trades, so it takes more time for my platform to identify a new trade and send the commands than it takes for the HFTs to change the bid and ask prices (as they're hosted on the exchange servers and hardware coded). Which takes us to #3 below...

3) On Amibroker, how do I know when a new information has been written on the times & trades? Is Amibroker able to identify a new limit order, or does it just identify a new market order? Where no level 2 information is available, a new "tick" is just a new trade, but in this case I might need to identify a change in the order book, which means that a new limit order has been either registered or cancelled. Are there functions to read the live times and trades? Is the Amibroker times and trades complete with all limit orders (bid and ask prices)?

I appreciate your suggestions.

Thank you,

asked Jun 20, 2017 in AFL Code Wizard by Eduardo
edited Jun 20, 2017

1 Answer

0 votes

Quote: "Since Amibroker doesn't have bid and ask history capabilities..."

That one is a completely incorrect assumption of yours.

Other than that your post is much too long for this quick and short Q&A site.

You have to go to AmiBroker forum here for more detailed Q&As.

answered Jun 20, 2017 by fxshrat (1,200 points)
I have moved the question to the forum as suggested by you.

Even if Amibroker has bid-ask historic pricing capabilities, I still need a detailed enough timestamp on each of the 3 prices (trade, bid, ask) to be able to sort which comes first to interpret them correctly. We're talking about a 6 case resolution after the second, that's on HFT territory.

I don't think that the real time data feed has such resolution, so in reality my view is that I'd need to check on the times & trades - which is my #3 point and to what I have no clue on how to proceed or which functions to use to read it.
AB supports milli/microsecond! If your source doesn't provide that then it is the source's problem!
I never said Amibroker couldn't support microsecond, however the  CME official times and sales itself  doesn't have anything below the second resolution (
What's that got to do with Amibroker?

I have already told you that AB is able to store bid ask (yes,  historical too)  as well as it supports subseconds.

All you need is proper data vendor.
Thank you for your constructive comments.

It's my mistake for not having made this clear: regardless of Amibrokers ability to work with bid-ask history, the way data vendors store past bid-ask information is to have it embedded in the times & trades history. That works just fine for me, as I can rebuild the historic volume delta outside Amibroker.