Механическое преследование кроссоверных сигналов MA без оценки рыночных условий и характеристик акций может привести к низкой рентабельности или высоким затратам на транзакции из-за переоценки.
/*backtest start: 2023-12-19 00:00:00 end: 2024-01-18 00:00:00 period: 1h basePeriod: 15m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("Intraday MA Crossover Strategy", overlay=true) // Define MA lengths maLengthShort = input.int(9, title="Short MA Length", minval=1) maLengthLong = input.int(21, title="Long MA Length", minval=1) // Calculate MAs maShort = ta.sma(close, maLengthShort) maLong = ta.sma(close, maLengthLong) // Plot MAs on the chart plot(maShort, color=color.blue, title="Short MA") plot(maLong, color=color.red, title="Long MA") // Generate Buy Signal (Golden Cross: Short MA crosses above Long MA) buySignal = ta.crossover(maShort, maLong) strategy.entry("Buy", strategy.long, when=buySignal) // Generate Sell Signal (Death Cross: Short MA crosses below Long MA) sellSignal = ta.crossunder(maShort, maLong) strategy.entry("Sell", strategy.short, when=sellSignal) // Set stop loss and take profit levels stopLossPercent = input.float(1, title="Stop Loss %", minval=0.1, maxval=5) takeProfitPercent = input.float(1, title="Take Profit %", minval=0.1, maxval=5) strategy.exit("Take Profit/Stop Loss", from_entry="Buy", loss=close * stopLossPercent / 100, profit=close * takeProfitPercent / 100) strategy.exit("Take Profit/Stop Loss", from_entry="Sell", loss=close * stopLossPercent / 100, profit=close * takeProfitPercent / 100)