// Fahodi Volatility Contraction Strategy // Generated from stocks.basem.ai //@version=5 strategy("Fahodi Vol Contraction", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=5) bbLen = input.int(20, "BB Length") bbMult = input.float(2.0, "BB Multiplier") kcLen = input.int(20, "Keltner Length") kcMult = input.float(1.5, "Keltner Multiplier") atrLen = input.int(14, "ATR Length") momentumLen = input.int(12, "Momentum Length") [bbMid, bbUp, bbLow] = ta.bb(close, bbLen, bbMult) atr = ta.atr(atrLen) kcMid = ta.sma(close, kcLen) kcUp = kcMid + atr * kcMult kcLow = kcMid - atr * kcMult sqzOn = bbLow > kcLow and bbUp < kcUp sqzOff = not sqzOn mom = ta.linreg(close - ta.sma(close, momentumLen), momentumLen, 0) // Entry: squeeze fires (was on, now off) with positive momentum longCondition = sqzOff and sqzOn[1] and mom > 0 shortCondition = sqzOff and sqzOn[1] and mom < 0 if longCondition strategy.entry("Sqz Long", strategy.long) strategy.exit("Sqz Exit", "Sqz Long", stop=close - atr * 2) plotshape(sqzOn, style=shape.diamond, location=location.belowbar, color=color.red, size=size.tiny) plotshape(sqzOff and sqzOn[1], style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small)