//B_HigherHighs //code by Ed Pottasch // if you want this inside a portfolio type system SetBarsRequired(10000,10000); SetOption("MaxOpenPositions", 10 ); SetOption("UsePrevBarEquityForPosSizing",True); SetOption("PriceBoundChecking", False); PositionSize = -10; SetTradeDelays(0,0,0,0); // delay of exit with respect to entry in bars sellDelay = Optimize("sellDelay", 1, 1, 50, 1); // buy signal when H exceeds H of past 220 bars Buy = H > Ref(HHV(H,220),-1); // entry at the open of the bar following the signal bar Buy = Ref(Buy,-1); BuyPrice = O; // remove excessive signals from initial signal Buy = ExRemSpan(Buy, sellDelay); // sell sellDelay bars after entry at the open Sell = BarsSince(Buy) == sellDelay; SellPrice = O; SetChartOptions(0, chartShowDates); GraphXSpace = 5; Plot(C,"C",1,64); PlotShapes(IIf(Buy,shapeUpArrow,0),colorGreen, layer = 0, yposition = BuyPrice, offset = 0 ); PlotShapes(IIf(Sell,shapeDownArrow,0),colorRed, layer = 0, yposition = SellPrice, offset = 0 ); PositionScore = 1/Ref(RSI(sellDelay),-1);