Hi,
I am trying to highlight Pivot Highs and Pivot Lows on the chart. For which i am using this simple code:
And the output is this: (Pls read below the pic)
--------------------------------------------------
-- PROBLEM ---
Many times there are 2 or more consecutive Pivot Highs
or 2 or more consecutive Pivot Lows
-- NEEDED ---
1. Pivot High and Pivot Low should alternate.
2.
PivH -
If there are two consecutive Pivot Hs then the one which is Bigger should be highlighted with Red dot and the smaller one should be dropped off / not considered any more.
PivL -
If there are two consecutive Pivot Ls then the one which is Smaller should be highlighted with Green dot and the Bigger one should be dropped off / not considered any more.
--------------------------------------------------
I am not a techie but keep trying to code. And below is what i came up with to solve the issue. Although, my solution is INCOMPLETE and could be raw or outright incorrect.
Hence, i request for help.
Could someone please help me complete this code ?
Would be grateful for your help.
Regards.
I am trying to highlight Pivot Highs and Pivot Lows on the chart. For which i am using this simple code:
PHP:
pivh = H > Ref(H,-1) AND H > Ref(H,-2) AND H > Ref(H,-3) AND H > Ref(H,1) AND H > Ref(H,2) ;
pivl = L < Ref(L,-1) AND L < Ref(L,-2) AND L < Ref(L,-3) AND L < Ref(L,1) AND L < Ref(L,2) ;
PlotShapes(IIf(pivh, shapeSmallCircle, shapeNone),ParamColor("Normal Up Arrow Color",colorWhite), 0,H, Offset=12);
PlotShapes(IIf(pivl, shapeSmallCircle, shapeNone),ParamColor("Normal Dn Arrow Color",colorYellow), 0,L, Offset=-12);
--------------------------------------------------
-- PROBLEM ---
Many times there are 2 or more consecutive Pivot Highs
or 2 or more consecutive Pivot Lows
-- NEEDED ---
1. Pivot High and Pivot Low should alternate.
2.
PivH -
If there are two consecutive Pivot Hs then the one which is Bigger should be highlighted with Red dot and the smaller one should be dropped off / not considered any more.
PivL -
If there are two consecutive Pivot Ls then the one which is Smaller should be highlighted with Green dot and the Bigger one should be dropped off / not considered any more.
--------------------------------------------------
I am not a techie but keep trying to code. And below is what i came up with to solve the issue. Although, my solution is INCOMPLETE and could be raw or outright incorrect.
PHP:
x = 0;
pivh = H > Ref(H,-1) AND H > Ref(H,-2) AND H > Ref(H,-3) AND H > Ref(H,1) AND H > Ref(H,2) ;
pivl = L < Ref(L,-1) AND L < Ref(L,-2) AND L < Ref(L,-3) AND L < Ref(L,1) AND L < Ref(L,2) ;
a = pivh;
b = pivl;
a=Flip(a,b);
b=Flip(b,a);
x = IIf(a,x=1,IIf(b,x= -1,0));
pivhnew = IIf(pivh AND (Ref(x,-1) == 1), ValueWhen(
PlotShapes(IIf(pivh, shapeSmallCircle, shapeNone),ParamColor("Normal Up Arrow Color",colorWhite), 0,H, Offset=12);
PlotShapes(IIf(pivl, shapeSmallCircle, shapeNone),ParamColor("Normal Dn Arrow Color",colorYellow), 0,L, Offset=-12);
Could someone please help me complete this code ?
Would be grateful for your help.
Regards.
Last edited: