Plotshapes confusion , could not understand

_SECTION_BEGIN("trend indentification");
r = Param("input range",14,10,30,1);
a = ADX(r);
b = a < 20;
d = a >20 AND a < 30;
e = a > 30;
Plot(a,"adx",colorBlue,styleLine|styleNoDraw);
Title = EncodeColor(colorGreen) + "this is a trend identification system : \n" + EncodeColor(colorGreen) +  Name() + "   " +
EncodeColor(colorYellow)+WriteIf(b , " \nsideways", " ") + EncodeColor(colorGreen) +WriteIf(d,"\ntrending"," ") +EncodeColor(colorBlue) + WriteIf(e," \nstrong trend", "  ");

PlotShapes(IIf(d,shapeHollowStar,shapeNone),colorYellow,0,20,0);
PlotShapes(IIf(e,shapeHollowStar,shapeNone),colorGreen,0,20,0);
PlotShapes(IIf(b,shapeHollowStar,shapeNone),colorRed,0,20,0);

Filter =1 ;
AddColumn(a,"adx",1.2);

_SECTION_END();

I hope I have used the code tags properly .

Query:- The code runs fine but i could not relate the line
Plot(a,"adx",colorBlue,styleLine|styleNoDraw);
to plotting shapes lines. If I do not plot the adx , the plotshapes does not show up. What is the relation between the two ?

Plot does set the plotting scale.
So if you do not use Plot then lowest y-value will be zero.
So of course you can just use PlotShapes alone. But then you have to adjust y argument of PlotShapes function -> to value (near) zero.

m = MA( Close, 20); 
Buy = Cross( Close, m );
Sell = Cross( m, Close );
Short = Cover = 0;

PlotShapes( Buy * shapeUpArrow + Sell * shapeDownArrow,
            IIf( Buy, colorGreen, colorRed ), layer = 0,
            y=0, yOffset = IIf(Buy, 10, -10) );

So you can see that I have used y = 0.
And Shapes are plotted at bottom of lower chart pane (by using y-offset you can adjust position further).

18


Now with initializing scale via plot (and using some y assignment other than zero (could be of type number or array)).

m = MA( Close, 20); 
Buy = Cross( Close, m );
Sell = Cross( m, Close );
Short = Cover = 0;

Plot(y=1, "", -1, styleNoDraw);
PlotShapes( Buy * shapeUpArrow + Sell * shapeDownArrow,
            IIf( Buy, colorGreen, colorRed ), layer = 0,
            y, -10 );

25

3 Likes

Thanks a ton !! That was helpful in understanding .