I would like to fetch ZScore of OpenInt in order to standardize the OI. ZScore Calculation requires Average of OI and StDev of OI of total bars till the current time.

Since AVG is not a function in amibroker, I am confused on its usage to the above stated purpose. Also the case with StDev of OI.

Kindly suggest on how to fetch zscore value of OpenInt.
Thanks in advance.

I have run the analysis part only to see wrong data. I have used excel to generate formula based Zscore for OI and compared to AB generated OI Zscore both are very much different.

Attached is a reference image to showcase Zscore generated using Excel ( on the left side ) ad Ami..

What could have gone wrong considering input data of OI is same for both but different output.. Any Idea?

I am sorry but I cannot notice anything if you just share screenshots.
It is up to you to share all the data, settings and formula. My formula code was to give you an idea of how one can move from some static code to a Time Series based dynamic one and AB is very capable of doing such stuff.
Also in your first post you do not say if it is daily aggregate or intraday etc and whether one should reset everyday or not.

Obviously you have set some from to range other than All Quotes! So there are bars of before 19/02/21 9:15 taken into account.

x = Close;
period = Cum(Status("barinrange"))-1;
mean = MA(x,period);
stdv = StDev(x,period);// is STDEV.P in EXCEL!!!!!
ZScore = ( x - mean ) / (stdv+1e-9);
// exploration
format = 1.2;
Filter = NOT IsNull(Zscore);// skip first bar of array
AddColumn( x, "X", format );
AddColumn( mean, "Mean", format );
AddColumn( stdv, "StDev", format );
AddColumn( zscore, "Z-Score", 1.3 );
AddColumn( period, "Count", 1);

Additonal note: since AB 6.19 array period has to be <= current barindex for functions such as Sum, MA, StDev.

AFL: variable period Sum() now returns NULL if range is greater than current bar index (previously returned partial sum)

Besides AB default StDev works like Excel's StDev.P function. So you should compare apples to apples.
If you want to compare to Excel default StDev then you have to set AB Stdev'sthird argument to FALSE.

So if you follow these then results between AB and Excel are same ones:

BTW you were not careful in your last picture. Instead of 61475 you have used 64475 in your calculation on the right.

This went into a loop of results while performing analysis. After the last candle of the day it started again frim the day start. It went on displaying continuity of results...

If counter restarts at new day then you used this one

period = BarsSince(DateNum()!=Ref(DateNum(),-1))+1;

I even wrote what that line does:

In my previous post I meant to use either one or the other depending on how you want to count. I clearly wrote "if ... then...". So I don't think it is too hard to understand.
And quite frankly you should learn to tell what you actually want, because no one know what you actually want to count from where to where! So far you just posted useless pictures.

You should post entire reproducible code plus analysis settings plus results!

I was just curious to know the z-score values of Volume, open Interest as they usually have higher scales compared to any other indicators. As a result I sought some help from the forum to plot the z-score values and in the process, I tried to compare it with Excel generated Z-scores just to ensure correct data being populated.

I really had no intention to to use it for any exploration but it was only to ascertain the accuracy of data points for plotting Zscore. If I may caused any sort of confusion or inconvenience while communicating clearly , I really apologize.

Your suggestions always helped me to achieve what I have intended to. Thanks a lot for being very helpful and most importantly, you never backed away from taking time to give some explanation on the mistakes while making suggestions. Very thankful for all your help.

I am extremely sorry for my poor communication in my earlier mentions. You have been kind and helpful on my request. Thanks a lot for all your efforts. Will surely append my way of communication way forward.

Thanks again for your time and valuable suggestions.