超トレンドの三重重複戦略

作者: リン・ハーンチャオチャン開催日: 2024-02-26 10:04:18
タグ:

img

概要

これは,三つの重複するスーパートレンド指標に基づいて取引決定を行う戦略です. それはトレンド市場でより大きな方向性の機会を捉えることができます.

戦略の論理

この戦略は,異なるパラメータ設定を持つ3つのスーパートレンド指標,すなわち10日間と3倍倍数を持つスーパートレンド1,14日間と2倍数を持つスーパートレンド2,および20日間と2.5倍数を持つスーパートレンド3を計算するために,ta.supertrend() 関数を使用する.価格が3つのスーパートレンドラインの上を横切るときに購入信号が生成される.価格が3つのスーパートレンドラインを下を横切るときに販売信号が生成される.

スーパートレンド指標は,価格傾向の変化を効果的に追跡するためにATR指標を組み込みます. 3つの重複するスーパートレンドの戦略は,シグナルをより信頼性があり,それによってトレンド市場でより大きな利益を得ることができます.

利点

  1. 三重フィルターメカニズムは,偽信号を回避し,信号品質を改善します.
  2. スーパートレンド自体は 騒音削減能力が良さ
  3. ハイパーパラメータの複数の組み合わせは,より多くの市場環境に適合するように設定できます.
  4. 過去の業績は良好で,リスク比率は高い

リスク

  1. 複数のフィルタリング信号は,いくつかの機会を逃す可能性があります
  2. 市場が違うところではうまくいかない
  3. 3つのセットのハイパーパラメータの組み合わせの最適化が必要です
  4. 集中した取引時間は突然の出来事に敏感です

リスクを減らすために,以下のようなことを考慮することができます:

  1. フィルタリング条件を調整し, SuperTrends を 1 つまたは 2 つ保持してください
  2. ストップ損失戦略を追加
  3. ハイパーパラメータを最適化して,勝率を向上させる

オプティマイゼーションの方向性

  1. 最適なハイパーパラメータを見つけるためにより多くのパラメータ組み合わせをテストする
  2. リアルタイムパラメータ最適化のための機械学習アルゴリズムを追加
  3. 単一の損失を制御するためにストップ損失戦略を追加
  4. 傾向や範囲を特定するための他の指標を組み込む
  5. 取引時間を延長し,単一の時点でのリスクを回避する

結論

この戦略は,トレンド方向を効果的に特定できる3つの重複するスーパートレンドに基づいて決定を下します. 高い信号品質と構成可能なパラメータなどの利点があります. 同時に,一定のリスクもあります. パラメータと出口タイミングは,異なる市場環境に適応するために調整する必要があります. 全体的に,戦略は非常にうまく機能し,さらなる研究と適用に値します.


/*backtest
start: 2024-01-01 00:00:00
end: 2024-01-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy('Combined Supertrend Strategy - Ajit Prasad', overlay=true)

// Function to calculate Supertrend
supertrendFunc(atrLength, factor) =>
    [supertrend, direction] = ta.supertrend(factor, atrLength)
    [supertrend, direction]

// Input parameters for the first Supertrend
atrPeriod1 = input(10, 'ATR Length 1')
factor1 = input(3, 'Factor 1')

// Calculate the first Supertrend
[supertrend1, direction1] = supertrendFunc(atrPeriod1, factor1)

// Input parameters for the second Supertrend
atrPeriod2 = input(14, 'ATR Length 2') // Change values as needed
factor2 = input(2, 'Factor 2') // Change values as needed

// Calculate the second Supertrend
[supertrend2, direction2] = supertrendFunc(atrPeriod2, factor2)

// Input parameters for the third Supertrend
atrPeriod3 = input(20, 'ATR Length 3') // Change values as needed
factor3 = input(2.5, 'Factor 3') // Change values as needed

// Calculate the third Supertrend
[supertrend3, direction3] = supertrendFunc(atrPeriod3, factor3)

// Define market opening and closing times
marketOpenHour = 9
marketOpenMinute = 15
marketCloseHour = 15
marketCloseMinute = 30
exitTimeHour = 15
exitTimeMinute = 10

// Fetch historical close values using security function
histClose = request.security(syminfo.tickerid, "D", close)

// Buy condition
buyCondition = close > supertrend1 and close > supertrend2 and close > supertrend3 and close[1] <= supertrend1[1]

// Sell condition
sellCondition = close < supertrend1 and close < supertrend2 and close < supertrend3 and close[1] >= supertrend1[1]

// Exit conditions
buyExitCondition = close < supertrend1[1] or close < supertrend2[1] or close < supertrend3[1]
sellExitCondition = close > supertrend1[1] or close > supertrend2[1] or close > supertrend3[1]

// Execute orders with market timing
if true
    // Buy condition without 'and not'
    strategy.entry('Buy', strategy.long, when = buyCondition)

    // Sell condition without 'and not'
    strategy.entry('Sell', strategy.short, when = sellCondition)

    // Close conditions
    strategy.close('Buy', when = buyExitCondition )
    strategy.close('Sell', when = sellExitCondition)

// Close all trades at 3:10 pm IST
if true
    strategy.close_all()

// Plot Supertrends
plot(supertrend1, 'Supertrend 1', color=color.new(color.green, 0), style=plot.style_linebr)
plot(supertrend2, 'Supertrend 2', color=color.new(color.red, 0), style=plot.style_linebr)
plot(supertrend3, 'Supertrend 3', color=color.new(color.blue, 0), style=plot.style_linebr)

// Plot labels
plotshape(buyCondition, style=shape.labelup, location=location.belowbar, color=color.new(color.green, 0), size=size.large, text='Buy Signal', textcolor=color.new(color.white, 0))
plotshape(sellCondition, style=shape.labeldown, location=location.abovebar, color=color.new(color.red, 0), size=size.large, text='Sell Signal', textcolor=color.new(color.white, 0))

もっと