How to assign the all open values to an array variable for the intraday

Hi,
I want to assign the all open values to an array variable. And also know the count of values in the array. My intention is something like below.

Bar_today = BarsSince( Day() != Ref( Day(), -1 ) ) + 1; // Need only intraday
Today_Open_values =(O,Bar_today); // Today_Open_values is an array which contains the all 
                                                             candles open values of Intraday
n= count(Today_Open_values ); // N contains how many values assigned i.e. n= number of candles 
                                                    //formed as of now


How to implement in AFL.

Thanks in advance.

Sorry but your post makes not much sense to me.

To count the number of intra-day bars of each day it's just this

dn = DateNum();
newday = dn != Ref(dn, -1);

//number of intraday bars formed till "now"
todays_barnum = BarsSince( newday ) + 1;

??

Assigning all open values to a variable is just this

All_Open_Values = Open;

Listen... I have a suspicion here... Do you want to calculate the average of all intra-day open prices within a day? Then...

dn = DateNum();
newday = dn != Ref(dn, -1);

//number of intraday bars formed till "now"
todays_barnum = BarsSince( newday ) + 1;

// average of all intraday Open prices
avg_Open = MA(Open, todays_barnum);

Plot( avg_Open, "Avg. open price since new day", colorRed, styleLine );
Plot( C, "Price", colorDefault, styleBar );
2 Likes

You are exactly correct. I am trying to find the stdev. But getting the below error. Please find the attachment.

//avg_Open = MA(Open, todays_barnum);
dn = DateNum();
newday = dn != Ref(dn, -1);
todays_barnum = BarsSince( newday ) + 1;
Std_Open = StDev(Open, todays_barnum);![Ami_Error|690x107](upload://yxLTowTCGL8aT2sKKh0GcCHPcSz.png) 

Then why did you not say exactly that in the first place in first post?
Have you read this one?
If not read then please do it now!

StDev inbuilt function does not allow variable period.
So you have to create custom function, see StdDev calculation.
So that means for AFL.. for example this...
(Note: because of floating point arithmetic it loses precision. So it is not as accurate as inbuilt function).

function vpStDev( array, period ) {
	return sqrt(MA(array^2, period) - MA(array, period)^2); 
}

dn = DateNum();
newday = dn != Ref(dn, -1);
todays_barnum = BarsSince( newday ) + 1;

Std_Open = vpStDev(Open, todays_barnum);
Plot(Std_Open, "Price", colorDefault );

The developer of AB has posted a different version with better accuracy once at old Yahoo board. So look it up here. No, I am not copying it to here since it is login area. If you have no access there then go to amibroker.com support asking for permission.


Also in general "payment" for getting help or copy&posting working code is hitting thanks button below responder's post who has taken (extra) time for you trying to make sense out of your post and getting you going. How do you think actual contributors are getting distinguished from non-contributors? Do you think it would be fair treating both the same? I don't think so.

Besides if a thread is re-solved then hit solution button below the post having solved an issue so other users may easily find solved threads.

5 Likes

Thanks @fxshrat for your great help.