Kindly refer to the below image:
NewDay = Status("firstbarinrange") OR Day() != Ref(Day(), -1);
BarsSince_NewDay = BarsSince(NewDay) + 1;
SumDays = Sum(NewDay, BarsSince_NewDay);
Filter = 1;
AddColumn(NewDay, "New Day");
AddColumn(BarsSince_NewDay, "Bars Since New Day");
AddColumn(SumDays, "Sum Days");
The Sum Function is not giving any results on the first day and am not sure of the reason, if any of the seniors could help on this please.
You should be using SumSince() function instead http://www.amibroker.com/f?sumsince
Using the Sum in a way you do (variable period) is significantly less efficient.
Noted Dr. Tomasz, thank you!
As for the reason why it shows
NULL (Emtpy) for first day:
There has been change in Sum/MA functions in AB 6.03.
So since it returns
NULL in first element in your example the sum for the whole day becomes
To start accumulating values from the beginning of the array, you could use the Cum() function instead of Sum() or SumSince():
CumDays = Cum(NewDay);
This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.