XShift works just fine, was: XShift in PlotShapes doesn't work

I'm looking for nearest top of the price when new top on EMA apeared:

aTopEMA=IIf( Ref(aEMA,-3)<Ref(aEMA,-2) AND Ref(aEMA,-2)<Ref(aEMA,-1) AND aEMA<Ref(aEMA,-1), 1,0);  //top on EMA
aTopValue=IIf(aTopEMA==1, HHV(H,5), Null);  //value of top of Price
bi = BarIndex();
aBarsFromTopEMA1= bi - ValueWhen( aTopValue, bi, 1 ); 
aTopValue1=Ref(HHV(H,5),-aBarsFromTopEMA1); //value of top of Price near top of EMA

It shows the circle at proper y value however it is located at the position x of top of EMA, not at position x of top of price. It looks like xshift doesn;t work.
When I see the value of aTopPosition1 at top of EMA it shows proper value, but there is no xshift. When I type in any value in number (e.g. -4) for xshift it works fine. Can you help?

xshift has to be a scalar, not an array.

Try this:

aEMA = EMA( C, 20 );
emaRaising = aEMA > Ref( aEMA, -1 );
aTop = Ref( emaRaising, -1 ) AND NOT emaRaising; // falling edge
nearTopPeriod = 5; // loop back period for near top

bi = BarIndex();
idx = IIF( atop, bi - HHVBars( H, nearTopPeriod ), Null );
ridx = Reverse( idx );
idx = bi == Reverse( ValueWhen( NOT IsNull( ridx ), ridx ) ); // barindex with offsets applied to each bar

Plot( C, "", colorDefault, styleCandle );
Plot( aEMA, "", IIf( emaRaising, colorGreen, colorRed ) );
PlotShapes( IIF( idx, shapeCircle, Null ), colorRed, 0, HHV( H, nearTopPeriod ), 0 );

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