I'm looking for nearest top of the price when new top on EMA apeared:
aEMA=EMA(C,5);
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
aTopPosition1=Ref(HHVBars(H,5),-aBarsFromTopEMA1);
PlotShapes(IIf(aBarsFromTopEMA1==0,shapeCircle,Null),colorBlue,0,aTopValue1,0,-aTopPosition1);
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?