I m stuck with the below code. the highs should be plotted with Green square boxes, but after the first box in green, other boxes color becomes Red. mysteriously if we click on the chart then red boxes at highs becomes green each with one click. what I want is with higher high all the boxes in green . Lows are correctly plotted with all red boxes. pls help.
_SECTION_BEGIN("MA5");
UpTrend=StaticVarGet("StaticUpTrend");
//Plot(C,"",colorBlue,64);
MA5=MA(C,5);
Plot(MA5,"",colorAqua,styleDashed);
//FINDING PEAK
TOP1=(Ref(MA5,-1)>Ref(MA5,0) //RIGHT SIDE
AND Ref(MA5,-1)>Ref(MA5,-2));//LEFT SIDE
MA5_HValue = ValueWhen(TOP1,MA5,1);
UpTrend=IIf(Ref(MA5_HValue,0)>Ref(MA5_HValue,-1),True,
IIf(Ref(MA5_HValue,0)==Ref(MA5_HValue,-1), Ref(UpTrend,-1),False) );
Vcolor1=IIf(UpTrend,colorGreen,colorRed);
PlotShapes(shapeSmallCircle,Vcolor1,0,MA5_HValue,0,0);//Red OR Green
StaticVarSet("StaticUpTrend",UpTrend);
_SECTION_END();