CCI+ダブル移動平均クロスオーバーリトレースメント買い戦略

CCI MA
作成日: 2024-05-24 17:45:49 最終変更日: 2024-05-24 17:45:49
コピー: 3 クリック数: 680
1
フォロー
1617
フォロワー

CCI+ダブル移動平均クロスオーバーリトレースメント買い戦略

概要

CCI+双均線交差逆戻り買取戦略は,順位指数 ((CCI) と双均線交差信号を総合的に利用する量化取引戦略である.この戦略は,双均線金フォークが形成された後に,価格が快線近くに逆戻りし,CCI指数が超売れたときに買取し,死板が形成された後に価格が快線近くに反発し,CCI指数が超売れたときに売る.CCIと双均線交差信号を組み合わせることで,この戦略は,トレンドの機会をよりうまく捉え,同時に,買い出しと出口の際に優越した入場と出場を待って,買い戻りと反発を売り,戦略のリスク収益率を向上させる.

戦略原則

  1. CCI指標の計算は,ユーザが設定したCCIパラメータ (ソースデータ,周期,移動平均タイプ,超買超売値) によって現在のCCI値を計算する.
  2. 判断CCI超買超売,CCIが超買値より大きい場合は背景色を赤色に設定し,超売値より小さい場合は背景色を緑色に設定する。
  3. 快速平均線を計算し,ユーザが設定した快速平均線パラメータ (ソースデータ,周期,移動平均タイプ) によって,それぞれ現在の快速平均線値を計算する.
  4. 金叉死叉を判定する.快線上での慢線を貫通して金叉を形成するときは多頭信号を描画する.快線下での慢線を貫通して死叉を形成するときは空頭信号を描画する.
  5. 取引に関する意思決定:
    • 多頭入場:速線がスローラインの上,前K線の閉盘価格が速線の下,現在のK線が陽線であり,CCIが超売り値より小さいときに多頭買い
    • 空頭入場:速線がスローラインの下にあり,前K線の閉盘価格が速線上にあるとき,現在のK線が陰線であり,CCIが超買値であるとき,空頭売り

戦略的優位性

  1. トレンド・トラッキング: 双均線交差信号によってトレンドの方向を判断し,市場トレンドに順応する.
  2. 逆境入場:トレンドが確立した後に価格が引き戻し買い,または反発販売を待つことで,比較的優良な入場価格を得ることができ,リスクと利益の比率を高めることができる.
  3. 偽信号の軽減:CCI指標と均線交差信号を組み合わせることで,単一の指標から発生する偽信号を効果的に減らすことができます.
  4. パラメータの柔軟性: ユーザは,自分の好みに応じてCCIと平均線のパラメータを柔軟に設定して,戦略のパフォーマンスを最適化できます.

戦略リスク

  1. 振動市場リスク:振動市場では,頻繁に金叉のデッドフォークは,戦略がより多くの損失の取引を生じさせる可能性があります.
  2. パラメータリスク:不適切なパラメータ設定は,戦略の不良なパフォーマンスを引き起こす可能性があり,異なる市場状況下での最適なパラメータの組み合わせを十分に反省し,分析する必要があります.
  3. トレンドリスク: 市場が逆転すると,戦略は出場を遅らせて,より大きな引き戻しリスクを背負う可能性があります.

戦略最適化の方向性

  1. ポジション管理を導入し,現在の市場トレンドの強さと波動率に応じてそれぞれの取引のポジションを動的に調整し,リスクをよりよく制御する.
  2. 入場条件の最適化,例えば取引量指数または他の補助判断指数を加え,入場信号の信頼性を向上させる.
  3. モバイルストップやタイムストップを設定し,単一取引の最大損失を低減するなど,出場条件を最適化します.
  4. 異なる市場と品種ごとにパラメータを最適化し,戦略の適応性と安定性を向上させる.

要約する

CCI+双均線交差回撤買入策は,トレンド追跡と逆転入場の利点を兼ね備えた量化取引策である.双均線によってトレンドの方向を捕捉し,CCI指標を使用して,オーバーバイのオーバーセール区間を識別し,価格の逆戻りと反発を待ちながら,より優越した入場価格を得るために,戦略の収益の可能性とリスク収益率を一定程度向上させることができる.しかし,この戦略は,パラメータ最適化,市場震動,トレンド突破などのリスクにも直面しており,さらなる最適化と改善によって戦略の安定性と収益性を強化する必要があります.戦略の思考は明確で,コード構造は整体で,全体的に実況取引に適しています.

ストラテジーソースコード
/*backtest
start: 2024-04-01 00:00:00
end: 2024-04-30 23:59:59
period: 1h
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/
// © tradedots

//@version=5
strategy("CCI + MA Crossover Pullback Buy Strategy [TradeDots]", overlay=true)


ma(source, length, type) =>
  type == "SMA" ? ta.sma(source[1], length) :
  type == "EMA" ? ta.ema(source[1], length) :
  type == "SMMA (RMA)" ? ta.rma(source[1], length) :
  type == "WMA" ? ta.wma(source[1], length) :
  type == "VWMA" ? ta.vwma(source[1], length) :
  na

//CCI settings
cci_coloring  = input.bool(true, "CCI Background Color", group = "Commodity channel index")
cci_length    = input.int(20,"CCI Length", group = "Commodity channel index")
cci_ma_type   = input.string("EMA","CCI MA Type", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group = "Commodity channel index")
cci_soruce    = input(hlc3, "CCI Source", group = "Commodity channel index")
cci_threshold = input.int(100, "CCI Threshold", group = "Commodity channel index")
cci_ma = ma(cci_soruce, cci_length, cci_ma_type)
cci = (cci_soruce - cci_ma) / (0.015 * ta.dev(cci_soruce, cci_length))

bgcolor(cci > cci_threshold and cci_coloring ? color.new(#f9396a, 80) : cci < -cci_threshold and cci_coloring? color.new(#9cff87, 80) : na, title = "CCI Overbought / Oversold")

//ma crossover settings
input_crossover_labels = input.bool(true, "Show Crossover Labels", group="Moving average")

fastma_type   = input.string("EMA","", inline="fastma", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="Moving average")
fastma_source = input(close, "", inline="fastma", group="Moving average")
fastma_length = input.int(10, "", inline="fastma", minval=1,group="Moving average")
fastma_color  = input(#e2fdff, "", inline="fastma",group="Moving average")
fastma = ma(fastma_source, fastma_length, fastma_type)
fastmaPlot = plot(fastma, color = #b7e4c7, linewidth = 2, title = "Fast MA")

slowma_type   = input.string("EMA","", inline="slowma", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="Moving average")
slowma_source = input(close, "", inline="slowma", group="Moving average")
slowma_length = input.int(30, "", inline="slowma", minval=1,group="Moving average")
slowma_color  = input(#e2fdff, "", inline="slowma",group="Moving average")
slowma = ma(slowma_source, slowma_length, slowma_type)
slowmaPlot = plot(slowma, color = #2d6a4f, linewidth = 2, title = "Slow MA")

bullish_crossover = ta.crossover(fastma, slowma)
bearish_crossover = ta.crossunder(fastma, slowma)

// // strategy
// if bullish_crossover and input_crossover_labels
//     line.new(bar_index, close, bar_index, close * 1.01, extend = extend.both, color = color.new(#9cff87, 30), style = line.style_dotted, width = 3)
//     label.new(bar_index,low, "Bullish Crossover", style = label.style_label_up, color = #9cff87)

// else if bearish_crossover and input_crossover_labels
//     line.new(bar_index, close, bar_index, close * 1.01, extend = extend.both, color = color.new(#f9396a, 30), style = line.style_dotted, width = 3)
//     label.new(bar_index, high, "Bearish Crossover", style = label.style_label_down, color = #f9396a, textcolor = color.white)

if fastma > slowma and close[1] < fastma and close > open and cci < -cci_threshold
    strategy.entry("Long", strategy.long)
    // if strategy.opentrades == 0 or strategy.opentrades.size(strategy.opentrades -1) < 0
    //     label.new(bar_index,low, "🟢 Long", style = label.style_label_up, color = #9cff87)

if fastma < slowma and close[1] > fastma and close < open and cci > cci_threshold
    strategy.entry("Short", strategy.short)
    // if strategy.opentrades == 0 or strategy.opentrades.size(strategy.opentrades -1) > 0
    //     label.new(bar_index, high, "🔴 Short", style = label.style_label_down, color = #f9396a, textcolor = color.white)