この取引戦略は,100期指数移動平均値 (EMA100),純未実現利益/損失 (NUPL),相対未実現利益) の3つの指標に基づいています. EMA100との価格のクロスオーバーとNUPLと相対未実現利益のポジティブまたはネガティブ性を決定することによって取引信号を生成します. 価格がEMA100を超えるとロング信号が起動し,NUPLと相対未実現利益の両方が正である.価格がEMA100を下回るとショート信号が起動し,NUPLと相対未実現利益の両方が負である. この戦略は10%の固定ポジションサイズを使用して,10%のストップ損失を設定します.
この取引戦略は,EMA100,NUPL,相対未実現利益という3つの指標を通じて取引信号を生成する.明確な論理,制御可能なリスク,強力な適応性などの利点があります.同時に,偽信号,遅延,パラメータ最適化などのリスクもあります.将来,パラメータ最適化,信号フィルタリング,ダイナミックポジション管理,ロングショート組み合わせを通じて戦略を最適化し改善することができます.
/*backtest start: 2023-06-11 00:00:00 end: 2024-06-16 00:00:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("Scalping Strategy with EMA 100, NUPL, and Relative Unrealized Profit", overlay=true) // Input for EMA period emaPeriod = input.int(100, title="EMA Period", minval=1) ema100 = ta.ema(close, emaPeriod) plot(ema100, color=color.blue, title="EMA 100") // Placeholder function for NUPL (Net Unrealized Profit/Loss) // Replace this with actual NUPL data or calculation NUPL = close * 0.0001 // Dummy calculation // Placeholder function for relative unrealized profit // Replace this with actual relative unrealized profit data or calculation relativeUnrealizedProfit = close * 0.0001 // Dummy calculation // Define conditions for long and short entries longCondition = ta.crossover(close, ema100) and NUPL > 0 and relativeUnrealizedProfit > 0 shortCondition = ta.crossunder(close, ema100) and NUPL < 0 and relativeUnrealizedProfit < 0 // Plot buy and sell signals on the chart plotshape(series=longCondition, location=location.belowbar, color=color.green, style=shape.labelup, title="Buy Signal") plotshape(series=shortCondition, location=location.abovebar, color=color.red, style=shape.labeldown, title="Sell Signal") // Calculate stop loss levels longStopLoss = close * 0.90 shortStopLoss = close * 1.10 // Strategy entry and exit rules if (longCondition) strategy.entry("Long", strategy.long, stop=longStopLoss) if (shortCondition) strategy.entry("Short", strategy.short, stop=shortStopLoss) // Set stop loss levels for active positions if (strategy.position_size > 0) strategy.exit("Exit Long", "Long", stop=longStopLoss) if (strategy.position_size < 0) strategy.exit("Exit Short", "Short", stop=shortStopLoss) // Alerts for long and short entries alertcondition(longCondition, title="Long Entry Alert", message="Long entry signal based on EMA 100, NUPL, and relative unrealized profit") alertcondition(shortCondition, title="Short Entry Alert", message="Short entry signal based on EMA 100, NUPL, and relative unrealized profit") // Visualize the entry conditions plotshape(series=longCondition, location=location.belowbar, color=color.blue, style=shape.cross, title="Long Condition") plotshape(series=shortCondition, location=location.abovebar, color=color.red, style=shape.cross, title="Short Condition")