Lookback = 20;
HighLookback = HHV(Close, Lookback);
AvgVolumeLookback = MA(Volume, Lookback);
Buy1 = Close > Ref(HighLookback, -1);
Vol1 = Volume > AvgVolumeLookback;
Buy2 = Ref(Close, -1) > Ref(HighLookback, -2);
Vol2 = Ref(Volume, -1) > Ref(AvgVolumeLookback, -1);
// Some volume filter for active scrip
Buy = Buy1 AND Vol1 AND Buy2 AND Vol2;
//Sell = Sell1 AND Vol1 AND Sell2 AND Vol2;
//Buy = ExRem(Buy, Sell);
//Sell = ExRem(Sell, Buy);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
PlotShapes(Buy * shapeUpArrow, colorLime, 0, Low, -25);