Price and Volume resizing

I was trying to see price and volume overlayed but having the posibility to resize them individually, is this possible?

I've searched but found no topic about this

Add a parameter to the volume. eg. chgvol = param("Vol",.1,.1,1,.001)*V;

@juanandres, if I understood your request correctly, here is another way of doing it.

// http://forum.amibroker.com/t/price-and-volume-resizing/5132

//// Parameters ////
areaP =  Param("% chart for Price (top)", 75, 5, 95, 5);
// The areaV Param setting are used only if "Independent Sizing" is ON (YES) 
areaV =  Param("% chart for Volume (bottom)", 25, 5, 95, 5);
independentSizing =  ParamToggle("Independent sizing", "No|Yes", 1);
if (NOT independentSizing) 
   areaV = 100 - areaP; // the rest he chart will be occupied by the Price plot

//// Resizing logic ////
// Visible Prices Range
lowestValP = LowestVisibleValue( L );
highestValP = HighestVisibleValue( H );

// Visible Volume Range
lowestValV = LowestVisibleValue( V ); 
highestValV = HighestVisibleValue( V ); 

factorP = (1.0 / areaP) * 100;
factorV = 100 / areaV;

// Resize Price Area 
pricesSpan = highestValP - lowestValP;
resizedPricesSpan = pricesSpan * factorP; 
// Set a new lowest value to force plot in the upper part of chart
lowestValP = highestValP - resizedPricesSpan;

// Resize Volume Area
volumeSpan = highestValV - lowestValV;
resizedVolumeSpan = volumeSpan * factorV; 
// Set a new highest value to force plot in the bottom part of chart
highestValV = lowestValV + resizedVolumeSpan;


//// Chart Plot ////
// Plot Prices and Volume in the same chart (using independent scales)
SetChartOptions(0, chartShowArrows | chartShowDates);
// Change colors and styles as needed....
SetChartBkColor( colorBlack ); 
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));
Plot( V, "Volume", colorWhite, styleHistogram | styleOwnScale | styleNoTitle, lowestValV, highestValV);
Plot( C, "Close", colorDefault, styleCandle | styleOwnScale | styleNoTitle, lowestValP, highestValP);

Use the Parameter settings to resize the two plots.
If you select "No" for the "Independent sizing" parameter, the Price area value is used to calculate the Volume area (this will disable the potential plots overlapping).

5 Likes

Many thanks Beppe.

I'm used to software like Ninja Trading and Visual Chart where you can plot
the price and the volume in the same screen, (no tab) and they have
individual scales, price scale on te right and volume scale on the left.

Thanks

@juanandres, AmiBroker too has an option to use a styleLeftAxisScale where the plot is using left axis scale (independent from the right axis), but no scale values are displayed to the left.

For similar issues/solution see also this thread.

But personally, I find that keeping indicators in separate panes, in the same chart, is a lot more convenient!

If you are still not familiar with the AmiBroker UI I suggest to read carefully this document and to take a look at this video (an old one but functionality is still the same).

Many thanks for your help Beppe