Overlay an indicator and adjust the scale and position

Hey guys!!

As you can see in the pic, we can easily overlay an indicator with different scale with: styleLeftAxisScale, but how can I change the y position of the indicator, in other words, how to change the indicator's vertical position? meaning how to move the indicator up or down?

Try styleOwnScale, and I think the y-axis will be changed when you change the "min" and "max" values.

"minvalue and maxvalue - (used by styleOwnScale plots ONLY) define plot minimum and maximum values (lower and upper boundary for Y axis)"

http://www.amibroker.com/guide/afl/plot.html

As an example, I have max set to 200 or to 100 in the charts below.

3 Likes

@portfoliobuilder gave you the way to move indicator vertically in programmatic way.

If you just wanted to move it up down from the UI (manually), you can simply click and hold down left mouse button in the Y axis area (right side) and drag it up/down using the mouse.
More on that in the manual: http://www.amibroker.com/guide/h_charting.html

1 Like

You could be interested in that.

``````// several zones in a pane
// several zones in one pane : price and indicator

Title = EncodeColor( 4 ) + _DEFAULT_NAME() + ";  " + EncodeColor( 1 ) +
StrFormat( "{{NAME}} - {{INTERVAL}}; {{DATE}}; O=%g, H=%g, L=%g, C=%g (%.1f%%{{VALUES}}",
O, H, L, C, SelectedValue( ROC( C, 1 ) ) );

Plot( C, "Price", colorBlack, styleCandle );
indicator = "RSI";
R = RSI();
PH = 20; // Height of RSI in percent pane height
RSIHeight = 100 / PH * 100;
//Plot(70,"",colorBlack,styleLine|styleOwnScale,0,RSIHeight);
Plot( R, "", 4, 1 | styleOwnScale, 0, RSIHeight );
Plot( 30, "", colorBlack, styleOwnScale | styleLine, 0, RSIHeight );
Plot( 70, "", colorBlack, styleOwnScale | styleLine, 0, RSIHeight );
Plot( 100, "", colorLightGrey, styleArea | styleOwnScale | styleNoLabel, 0, RSIHeight );
``````
4 Likes

For AFL code you need use `[code] ... [/code]` tags to get proper syntax colorization and formatting. See How to use this site

1 Like

Thank you all so much, I’m progressing

Finally I did it, now I can move an indicator across another and adjust the proper scale: slight_smile:

``````// several zones in a pane
// several zones in one pane : price and indicator

Title = EncodeColor( 4 ) + _DEFAULT_NAME() + ";  " + EncodeColor( 1 ) +
StrFormat( "{{NAME}} - {{INTERVAL}}; {{DATE}}; O=%g, H=%g, L=%g, C=%g (%.1f%%{{VALUES}}",
O, H, L, C, SelectedValue( ROC( C, 1 ) ) );

Plot( C, "Price", colorBlack, styleCandle );
indicator = "RSI";

R = RSI();

scalingconstante = Param( "Scte", 110, 50, 200, 5 );

position = Param( "position", 70, 0, 200, 1);
maxi= position;
mini= maxi - scalingconstante;

//Plot(70,"",colorBlack,styleLine|styleOwnScale,0,RSIHeight);
Plot( R, "", 4, 1 | styleOwnScale, mini, maxi );
Plot( 30, "", colorwhite, styleOwnScale | styleLine, mini, maxi );
Plot( 70, "", colorwhite, styleOwnScale | styleLine, mini, maxi );

``````
4 Likes

Hello,

When the candle stick chart is moved to left or right the y axis scale shrinks or stretches on its own to accommodate the chart. I want to stop the y axis scale to automatically shrink or stretch when the chart is moved from left to right.

That is per unit height of y axis must be fixed with fixed number of PIPs or currency value so that even when the chart is moved left or right the candle heights are intact and are not distorted when the chart is moved. And then the chart must be able to be moved up and down by moving the cursor on the y axis.

Is there any setting or afl code for this ?

Hello,
I tried to change your code from RSI to Volume, but I failed, I think its because the volume is not always move from 0 to 100 max. Is there a way to do Price + volume in one chart without using parameter to adjust the volume scale for each stock like you did with RSI? for example, stock with 1.000.000 volume is plotted the same 100 pixel height boundaries with stock with 1.000 volume...

thanks

@sikatgigi if you want to overlay volume and be able to preset the percentage of pane's height it will cover, you can for example use a code similar to this one:

``````Plot( C, "Close", colorDefault, styleCandle );

HPercent = Param("Percentage of pane height", 30, 1, 100, 1);
Plot(V, "Volume", colorBlueGrey, styleHistogram|styleOwnScale, 0, HighestVisibleValue(V)*100/HPercent, 0, 0, 2);
``````

11 Likes

@Milosz

OMG thank you!

you done it just like that, I already tried it for days, with Status("axisminy"); Status("pxchartheight")/50; LastValue( Lowest( Volume ) );

thanks a lot!

1 Like

This was very helpful, thank you. I notice that the Volume value label is not at the same vertical position as the Volume indicator. Is it possible to display the Volume value label at the appropriate vertical position?

1 Like

Just Another enhanced way to Plot Volume, its Average with Price Chart.
Height of price chart and volume is flexible.

``````isVol =   ParamToggle("Show Volume ?","No|Yes",1);
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );

_SECTION_BEGIN("Volume");
PaneHght = Param( "Volume Pane Height (in %)", 15, 1, 100, 1 );
PaneHghtMin = LowestVisibleValue( V);
PaneHghtMax = HighestVisibleValue(V) * 100 / PaneHght;
gxs=Param("GRAPH spaceing",15,5,50,5);
GraphXSpace = gxs;

if (isVol == 1)
{

xcol1= IIf( C > Ref( C, -1 ) AND V > Ref( V, -1 ), colorGreen, IIf( C < Ref( C, -1 ) AND V > Ref( V, -1 ),colorOrange, colorBlue) );
xcol2= IIf( C > Ref( C, -1 ) AND V > Ref( V, -1 ), colorbrightGreen, IIf( C < Ref( C, -1 ) AND V > Ref( V, -1 ),colorpink, colorSkyblue) );

hz=EMA(Volume,5);
Plot( hz, "Vol", colorblue, styledashed |styleOwnScale  ,  PaneHghtMin, PaneHghtMax, 0, 0, 2 );
Plot( Volume, "", xcol1,  styleHistogram | styleOwnScale | styleThick | styleNoTitle , PaneHghtMin, PaneHghtMax, 0, 0, 2 );
Plot( Volume, "", xcol2,  styleArea | styleOwnScale | styleThick | styleNoTitle , PaneHghtMin, PaneHghtMax, 0, 0, 2 );
}
_SECTION_END();
``````

1 Like