I am trying to calculate Bid and Ask Volume on Tick interval. When I set Back tester periodicity settings to tick, I am getting tick volume for every tick, from which I can get Ask and Bid volume for every tick.
But when I set the periodicity settings to 5 minutes and explore my below code. The base arrays O,H,L,C are not switching to tick interval instead it is showing the arrays calculated in 5 minutes itself.
TimeFrameExpand( array, interval, mode = expandLast ) - expands time-compressed array from 'interval' time frame to base time frame
(interval' must match the value used in TimeFrameCompress or TimeFrameSet)
Please note that you can only compress data fromshorter interval to longer interval. So when working with 1-minute data you can compress to 2, 3, 4, 5, 6, ....N-minute data. But when working with 15 minute data you can not get 1-minute data bars. In a similar way if you have only EOD data you can not access intraday time frames.
AskV = IIf(C>Ref(C,-1),V,0);
BidV = IIf(C <= Ref(C,-1),V,0);
CAskV = Cum(AskV);
CBidV = Cum(BidV);
EBidV = TimeFrameCompress(CBidV,in5Minute,compressLast);
EAskV = TimeFrameCompress(CAskV,in5Minute,compressLast);
Filter = 1;
Ask = EAskV - Ref(EAskV, -1);
Bid = EBidV - Ref(EBidV, -1);
AddColumn(Ask, "Ask Volume");
AddColumn(Bid, "Bid Volume");```
It takes the entire volume of the 5 minutes candle as Ask or bid volume.
Attaching an image showing that as the first candle C < O it took it as bid and showing it.
But actually there are ask volume ticks and bid volume ticks in that single candle. It has been combined into either ask or bid based on bigger time frame.
As it has solved your issue now ,mark @fxshrat 's post above as the solution ,will be helpful for others to quick jump to solution.
And, while you are at it, why not show some appreciation, click the heart below his post/s.
@fxshrat Thank you for your help! My Intraday Database about 6-month. Now if SELECTED INTERVAL 1-tick then Calculate too slow. I only want to calculate Ask Bid of one day (last day/curent day). How to ignore all day no need cal?