Giá có thể đã giảm nhưng SMA vẫn chưa giảm.
Các giải pháp có thể:
/*backtest start: 2023-12-01 00:00:00 end: 2023-12-31 23:59:59 period: 30m basePeriod: 15m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ // This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © omererkan //@version=5 strategy(title="ATR Channel Breakout") smaLength = input.int(150, title="SMA Length") atrLength = input.int(30, title="ATR Length") ubOffset = input.float(4, title="Upperband Offset", step=0.50) lbOffset = input.float(4, title="Lowerband Offset", step=0.50) smaValue = ta.sma(close, smaLength) atrValue = ta.atr(atrLength) upperBand = smaValue + (ubOffset * atrValue) lowerBand = smaValue - (lbOffset * atrValue) plot(smaValue, title="SMA", color=color.orange) plot(upperBand, title="UB", color=color.green, linewidth=2) plot(lowerBand, title="LB", color=color.red, linewidth=2) enterLong = ta.crossover(close, upperBand) exitLong = ta.crossunder(close, smaValue) enterShort = ta.crossunder(close, lowerBand) exitShort = ta.crossover(close, smaValue) if enterLong strategy.entry("Long", strategy.long) if enterShort strategy.entry("Short", strategy.short) if exitLong strategy.close("Long", "Close Long") if exitShort strategy.close("Short", "Close Short")