Better way of Plotting Volume Histogram

Hello,
With the help of the articles in the forum contributed by respected members, I tried to plot the histogram chart of both Volume and Delivery Volume , how ever when I look at weekly chart it doesn't see to be comprehendable. Is there any better way of presenting the data for easy comprehension of volume? Is it better to plot Total Volume as 100 and take the delivery as % of Total volume to plot the chart? Or Plotting % of Delivery for each histogram?

Volume represents Total Volume of the day and delivery volume representes the quantity of Total volume marked for delivery.

TotalVolume = Volume;	
DeliveryVolume = OpenInt;
DQ = (OI*100)/V;


SetBarFillColor( colorGreen) ;
PlotOHLC(DeliveryVolumeTotalVolume,DeliveryVolume,TotalVolume,"Volume", colorGreen,64 );
GraphLabelDecimals = 2;
SetBarFillColor( colorRed);
PlotOHLC(0,DeliveryVolume,0,DeliveryVolume,"Delivery", colorred,64);
GraphLabelDecimals = 2;

Here is the sample 1. Daily chart. 2.Weekly Chart
Chart Weekly

  1. You do not need PlotOHLC() function
  2. You should use GraphLabelDecimals just one time per AFL
  3. You may use Remap() and styleOwnScale

Set maxPerc of below code to values between 0 to 100.

/// Set maxPerc to values between 0 to 100
/// @link https://forum.amibroker.com/t/better-way-of-plotting-volume-histogram/25809/2
TotalVolume = Volume;	
DeliveryVolume = OpenInt;
DQ = OI/V*100;

GraphLabelDecimals = 2;
Plot(TotalVolume,"Volume", colorGreen,styleHistogram, Null, Null, 0, 0, -60 );

maxPerc = 40;// 0 to 100
Input = DeliveryVolume;
minVal = LowestVisibleValue(Input);
maxVal = HighestVisibleValue(Input);
maxScale = Remap(100, 0, maxPerc, minVal, maxVal); 
Plot(Input, "Delivery", colorRed, styleHistogram | styleOwnScale, 0, maxScale, 0, 1, -60 );

28

7 Likes

You are storing your "Delivery Volume" data in Openinterest field of your database.
Please be aware of the difference in the way these Volume and Openinterest fields behave when your periodicity is higher than the Base Periodicity of your database:
Volume is Accumulated/Aggregated for All the underlying Database records, where as OpenInterest is only for the Last Database Record. Let me explain with the help of an example:

Let's say that the volume for the Seven Days of the week are:
100, 200, 150, 200, 150, 200, 120
and the Delivery Volume for the Seven Days are:
50, 120, 80, 100, 90, 120, 70

When you see weekly charts the Volume will be 1120
and the Delivery Volume will be 70 (Not 630)

As a Solution, you may want to store your Delivery Volume in one of AUX fields and have appropriate setting in File > DataBase Settings > Intraday Settings > Aux1,2 Aggregation mode (Select Sum here)

With Regards

Sanjiv Bansal

4 Likes

Dear Sir,

Thank you for sharing your inputs. I was not aware of this aggregation behavior of Open Interest Field. Is there any way I could change the previous data from Open interest Field to Aux1?

You do not need to copy to Aux field.
You may store cummulated OI since start of week to static var if being on interval smaller than weekly.

Read the comments in the code.

/// Set maxPerc to values between 0 to 100
/// @link https://forum.amibroker.com/t/better-way-of-plotting-volume-histogram/25809/5
TotalVolume = V;	
DeliveryVolume = OpenInt;
//DQ = OI/V*100;

dow = DayOfWeek();
new_week = dow < Ref(dow, -1);
csOI = SumSince(new_week, DeliveryVolume);

gcmb = GetCursorMouseButtons();
LMB_click = gcmb == 9;

erase = ParamTrigger("Erase Static Vars", "CLICK HERE");

if ( Interval() <= inDaily )  {
	Input = DeliveryVolume;
	//
	// Store 'csOI' one time on all bars 
	// if interval being SMALLER inWeekly.
	// Is getting updated every time
	// you set to an interval being
	// SMALLER than weekly AND
	// if left-clicking on chart there.
	// Left-click two times.
	if ( LMB_click ) {		
		SetBarsRequired(sbrAll);
		StaticVarSet("OI_intraWeekly", csOI);
	}	
} else {
	Input = StaticVarGet("OI_intraWeekly");
	if ( erase ) {
		StaticVarRemove("OI_intraWeekly");
	}
}

GraphLabelDecimals = 2;
Plot(TotalVolume,"Volume", colorGreen,styleHistogram, Null, Null, 0, 0, -60 );

maxPerc = 30;// 0 to 100
minVal = LowestVisibleValue(Input);
maxVal = HighestVisibleValue(Input);
maxScale = Remap(100, 0, maxPerc, minVal, maxVal); 
Plot(Input, "Delivery", colorRed, styleHistogram | styleOwnScale, 0, maxScale, 0, 1, -60);
4 Likes

Thank you so much for the help

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