// Downloaded From https://www.WiseStockTrader.com _SECTION_BEGIN("Peak & Valley"); // E.M.Pottasch 09/06/10 nbar = Param("nbar",2,1,5,1); PHigh = H > Ref(HHV(H,nbar),-1) AND Ref(HHV(H,nbar),nbar) < H; PHighPrice0 = ValueWhen(PHigh,H); PHighPrice1 = IIf(PHighPrice0 AND BarsSince(PHigh) > nbar,PHighPrice0,Null); PHighPrice2 = IIf(PHighPrice0 AND BarsSince(PHigh) <= nbar,PHighPrice0,Null); PLow = L < Ref(LLV(L,nbar),-1) AND Ref(LLV(L,nbar),nbar) > L; PLowPrice0 = ValueWhen(PLow,L); PLowPrice1 = IIf(PLowPrice0 AND BarsSince(Plow) > nbar,PLowPrice0,Null); PLowPrice2 = IIf(PLowPrice0 AND BarsSince(Plow) <= nbar,PLowPrice0,Null); GraphXSpace = 5; SetChartOptions(0, chartShowDates); Plot(C,"\nLast",colorWhite,styleCandle); Plot(PHighPrice1,"\nPHighPrice",colorOrange,styleThick); Plot(PHighPrice2,"",colorOrange,styleDots | styleNoLine); Plot(PLowPrice1,"\nPLowPrice",colorBrightGreen,styleThick); Plot(PLowPrice2,"",colorBrightGreen,styleDots | styleNoLine); Buy=H>PHighPrice0; Sell=L