Find the Highest and Lowest Volume for each month

Is it possible to find out the Highest and Lowest volume for each particular month and plot a rolling chart based on the Difference i.e ( Highestvolume - Lowestvolume) for each month?

I learnt that HHV & LLV give values only for a particular range but not sure of how to get for a particular month.

For example:
For the month of January the highest volume was 100 and the lowest volume was 50. I want to plot a chart based on 50 (100-50)

Thank you

MonthChange = Month() != Ref( Month(), -1 );

HighestVolInMonth = HighestSince( MonthChange, Volume );
LowestVolInMonth = LowestSince( MonthChange, Volume );

Or you could use Time frame functions.

3 Likes

Thank you for the reply. I am having problem with plotting the chart. I don't understand why the chart is not smooth even though when there is only one ratio for each month. please guide.

MonthChange = Month() != Ref( Month(), -1 );

HighestVolInMonth = HighestSince( MonthChange, Volume );
LowestVolInMonth = LowestSince( MonthChange, Volume );

// Explore //
Filter = 1;


AddColumn( LowestVolInMonth, "lowest" );
AddColumn( HighestVolInMonth, "highest" );
AddColumn( HighestVolInMonth/LowestVolInMonth, "Ratio" );

Plot((HighestVolInMonth/LowestVolInMonth),"Ratio",colorAqua,styleLine);

This is the chart in excel for something similar

Chart in Amibroker

Obviously the AFL code calculates on-going highest/lowest (updated daily as month progresses).

Your chart is not doing that. Your chart just shows ONE point per month at last day of month.

If you took data from LAST BAR of the month from LowestVolInMonth and HighestVolInMonth only you would get exactly that.

This was left as exercise FOR YOU TO DO YOURSELF.

2 Likes

Thank you. I tried to find the last day of the month and get the values. please correct me if anything can be improved to get a smooth line.

MthChg = Month() != Ref( Month(), -1 );
mthhigh = HighestSince( MthChg, Aux2 );
mthlow = LowestSince( MthChg, Aux2 );
mthratio = mthhigh / mthlow;

LastDayOfMonth = IIf(Month() != Ref(Month(), 1) , 1, 0);
mthratio2 = ValueWhen(LastDayOfMonth,mthratio);

// Explore //
Filter = 1;
AddColumn( mthlow, "lowest" );
AddColumn( mthhigh, "highest" );
AddColumn( mthratio, "Ratio" );

Plot(mthratio2,"Ratio",colorAqua,styleLine);

https://www.amibroker.com/guide/afl/linearray.html

1 Like

As a newbie and Non-programmer I tired but still can't figure out how to take data from LowestVolInMonth any help is much appreciated in this regard.

Thank you

Did you look at the docs? There is example in the guide how to do that:

https://www.amibroker.com/guide/afl/linearray.html

Also Google is your friend, ready to use solutions are easily searchable, why don't you make basic effort?

https://www.google.com/search?q=afl+linearray+plot

1 Like

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.