`//@version=5 Strategy("4:4 S1", Overlay=true) // 指标输入 fairValueGap = input(0.5, "Lux Algo 公允价值缺口") cciLevel = input(100, "CCI Level") cci = ta.cci(close, 20) regressionLength = input(20, "回归长度") supertrendLength = input(10, "超级趋势长度") stopLoss = input(4, "止损(点)") takeProfit = input( 4, "止盈 (点)") // 计算指标 fairValue = ta.sma(close, 20) + fairValueGap supertrendUp = ta.sma(high, supertrendLength) + fairValueGap supertrendDown = ta.sma(low, supertrendLength) - fairValueGap regressionMA = ta.linreg(close, regressionLength, 0) // 定义长入场条件 longEntry = close > (fairValue) and close > supertrendUp and (regressionMA) > 0 and ta.cci(close, 20) > -100 和 ta.cci(close, 20) > -100 and ta. cci(收盘价, 20) < 100 // Define Short Entry Condition shortEntry = close < (fairValue) and close < (supertrendDown) and (regressionMA) < 0 and ta.cci(close, 20) > -100 和 ta.cci(收盘价, 20) < 100 // Execute Trades if longEntry strategy.entry("Long", strategy.long) if shortEntry strategy.entry("Short", strategy.short) // Set Stop Loss and Take Profit stopLossPips = ta.valuewhen(longEntry, close, 0) - stopLoss * syminfo.mintick takeProfitPips = ta.valuewhen(longEntry, close, 0) + takeProfit * syminfo.mintick strategy.exit("Stop Loss/Take Profit", "Long", stop=stopLossPips, limit=takeProfitPips) strategy.exit("Stop Loss/Take Profit", "Short", stop=stopLossPips, limit=takeProfitPips) plotshape(longEntry, location=location.belowbar, size=size.normal, color=color.green, style=shape.triangleup) plotshape(shortEntry, location=location.abovebar, size=size.normal, color=color.red, style=shape.triangledown)``