複数の時間枠でのダイナミックストップロスを備えたEMAスクイーズ取引戦略

EMA SQM CMF KC SL TP MTF
作成日: 2024-12-11 15:50:38 最終変更日: 2024-12-11 15:50:38
コピー: 0 クリック数: 435
1
フォロー
1617
フォロワー

複数の時間枠でのダイナミックストップロスを備えたEMAスクイーズ取引戦略

概要

この戦略は,指数移動平均 ((EMA),スクリーズ動量指標 ((SQM) と資金流動指標 ((CMF) を組み合わせた,複数のタイムフレームの分析に基づくダイナミックな取引システムで,取引シグナルを生成します.戦略の核心は,複数のタイムフレームの分析によってトレンドを確認し,ダイナミックなストップローズを使用してリスク管理を最適化することです.この戦略は,自主的に市場変動に応じて取引パラメータを自動的に調整できる自己適応のストップと利益プログラムを採用しています.

戦略原則

戦略は,3つの主要な技術指標の組み合わせを使用して取引機会を識別する. まず,11サイクルと34サイクルEMAによって市場のトレンド方向を決定する. 次に,改良版のSqueeze Momentum指標を使用して,市場圧力と潜在的突破機会を検出する.この指標は,線形回帰方法によって価格偏差を計算する.最後に,改良されたキャピタルフロー指数 ((CMF)) によって取引方向を確認し,価格の動きをサポートする十分な資金があることを確認する.

戦略的優位性

  1. 多次元信号確認:複数の技術指標と時間周期の分析を組み合わせることで,偽信号のリスクを大幅に低減する.
  2. スマートリスク管理:ダイナミック・ストップ・ローズ・システムは,市場の波動に応じて自動的に調整し,利益を保護しながら,早急に出場を避ける.
  3. 適応性:戦略のパラメータは,異なる市場条件に合わせて調整され,良好な適応性を有する.
  4. 完全取引閉環:入場信号から出場管理までの明確なルールがあり,主観的な判断の影響が軽減されます.
  5. 資金流動確認: 資金流動を監視することで価格動向を検証し,取引の信頼性を高めます.

戦略リスク

  1. パラメータ感性:複数の技術指標のパラメータ設定は,注意深く最適化され,不適切なパラメータは,性能の低下を引き起こす可能性があります.
  2. 市場環境依存: 市場環境が激しく波動し,流動性が低い場合,信号の質が影響を受ける可能性があります.
  3. 計算の複雑さ:多時間周期の計算は,実際の取引の効果に影響する信号の遅延を引き起こす可能性があります.
  4. ストップダメージ調整リスク: ダイナミックストップダメージは,特定の市場条件下で過度に激進的または保守的になる可能性があります.
  5. 資金管理要求:戦略は,リスクと利益のバランスをとる合理的な資金管理を必要とします.

戦略最適化の方向性

  1. 波動率自己適応の導入:ATRまたは他の波動率指標に基づいてパラメータを動的に調整して,戦略の適応性を向上させることができる.
  2. シグナルフィルタを最適化: 取引量加重または時間フィルタを追加して信号の質を向上させることができる.
  3. 改善された止損機構:サポート位と抵抗位を組み合わせて止損点の設定を最適化することができる.
  4. 市場環境分析を追加:市場トレンドの強度指標を導入し,異なる市場環境で異なるパラメータ設定を使用する.
  5. 資金管理の改善:ポジション管理アルゴリズムを導入し,信号の強さや市場の変動に応じてポジションの割合を調整する.

要約する

この戦略は,多次元的な技術分析とインテリジェントなリスク管理により,トレーダーに体系化された取引方案を提供している.その核心的な優位性は,トレンド追跡とダイナミックなリスク管理を組み合わせて,利益を保護しながら市場機会を捉えることが可能である.戦略には,最適化が必要な側面があるが,合理的なパラメータ設定とリスク管理により,有効な取引ツールとして機能し続けることができる.トレーダーに,実用化する前に十分なフィードバックとパラメータの最適化を行い,市場経験と組み合わせて,取引システムを段階的に完善することを推奨している.

ストラテジーソースコード
/*backtest
start: 2024-11-10 00:00:00
end: 2024-12-09 08:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy("LL Crypto - SUI", overlay=true)

// Parâmetros de tempo para criptomoedas
fast_ema_len = input.int(11, minval=5, title="Fast EMA")
slow_ema_len = input.int(34, minval=20, title="Slow EMA")
sqm_lengthKC = input.int(20, title="SQM KC Length")
kauf_period = input.int(20, title="Kauf Period")
kauf_mult = input.float(2, title="Kauf Mult factor")
min_profit_sl = input.float(5, minval=0.01, maxval=100.0, title="Min profit to start moving SL [%]")
longest_sl = input.float(10, minval=0.01, maxval=100.0, title="Maximum possible of SL [%]")
sl_step = input.float(0.5, minval=0.0, maxval=1.0, title="Take profit factor")

// Parâmetros adaptados para criptomoedas
CMF_length = input.int(11, minval=1, title="CMF length")
show_plots = input.bool(true, title="Show plots")

// Definir intervalos de tempo para criptomoedas
selected_timeframe = input.string(defval="15", title="Intervalo de Tempo", options=["1", "15", "60"])

lower_resolution = timeframe.period == '1' ? '1' :
                   timeframe.period == '5' ? '15' :
                   timeframe.period == '15' ? '60' :
                   timeframe.period == '60' ? '240' :
                   timeframe.period == '240' ? 'D' :
                   timeframe.period == 'D' ? 'W' : 'M'

sp_close = close[barstate.isrealtime ? 1 : 0]
sp_high = high[barstate.isrealtime ? 1 : 0]
sp_low = low[barstate.isrealtime ? 1 : 0]
sp_volume = volume[barstate.isrealtime ? 1 : 0]

// Calcular Squeeze Momentum ajustado para criptomoedas
sqm_val = ta.linreg(sp_close - math.avg(math.avg(ta.highest(sp_high, sqm_lengthKC), ta.lowest(sp_low, sqm_lengthKC)), ta.sma(sp_close, sqm_lengthKC)), sqm_lengthKC, 0)
close_low = request.security(syminfo.tickerid, lower_resolution, sp_close, lookahead=barmerge.lookahead_on)
high_low = request.security(syminfo.tickerid, lower_resolution, sp_high, lookahead=barmerge.lookahead_on)
low_low = request.security(syminfo.tickerid, lower_resolution, sp_low, lookahead=barmerge.lookahead_on)
sqm_val_low = ta.linreg(close_low - math.avg(math.avg(ta.highest(high_low, sqm_lengthKC), ta.lowest(low_low, sqm_lengthKC)), ta.sma(close_low, sqm_lengthKC)), sqm_lengthKC, 0)

// CMF adaptado para criptomoedas
ad = sp_close == sp_high and sp_close == sp_low or sp_high == sp_low ? 0 : ((2 * sp_close - sp_low - sp_high) / (sp_high - sp_low)) * sp_volume
money_flow = math.sum(ad, CMF_length) / math.sum(sp_volume, CMF_length)

// Condições de entrada para criptomoedas
low_condition_long = (sqm_val_low > sqm_val_low[1])
low_condition_short = (sqm_val_low < sqm_val_low[1])
money_flow_min = (money_flow[4] > money_flow[2]) and (money_flow[3] > money_flow[2]) and (money_flow[2] < money_flow[1]) and (money_flow[2] < money_flow)
money_flow_max = (money_flow[4] < money_flow[2]) and (money_flow[3] < money_flow[2]) and (money_flow[2] > money_flow[1]) and (money_flow[2] > money_flow)
condition_long = ((sqm_val > sqm_val[1])) and money_flow_min and ta.lowest(sqm_val, 5) < 0
condition_short = ((sqm_val < sqm_val[1])) and money_flow_max and ta.highest(sqm_val, 5) > 0
enter_long = low_condition_long and condition_long
enter_short = low_condition_short and condition_short

// Stop conditions
var float current_target_price = na
var float current_sl_price = na
var float current_target_per = na
var float current_profit_per = na

set_targets(isLong, min_profit, current_target_per, current_profit_per) =>
    float target = na
    float sl = na
    if isLong
        target := sp_close * (1.0 + current_target_per)
        sl := sp_close * (1.0 - (longest_sl / 100.0))
    else
        target := sp_close * (1.0 - current_target_per)
        sl := sp_close * (1.0 + (longest_sl / 100.0))
    [target, sl]

target_reached(isLong, min_profit, current_target_per, current_profit_per) =>
    float target = na
    float sl = na
    float profit_per = na
    float target_per = na
    if current_profit_per == na
        profit_per := (min_profit * sl_step) / 100.0
    else
        profit_per := current_profit_per + ((min_profit * sl_step) / 100.0)
    target_per := current_target_per + (min_profit / 100.0)
    if isLong
        target := strategy.position_avg_price * (1.0 + target_per)
        sl := strategy.position_avg_price * (1.0 + profit_per)
    else
        target := strategy.position_avg_price * (1.0 - target_per)
        sl := strategy.position_avg_price * (1.0 - profit_per)
    [target, sl, profit_per, target_per]

hl_diff = ta.sma(sp_high - sp_low, kauf_period)
stop_condition_long = 0.0
new_stop_condition_long = sp_low - (hl_diff * kauf_mult)
if (strategy.position_size > 0)
    if (sp_close > current_target_price)
        [target, sl, profit_per, target_per] = target_reached(true, min_profit_sl, current_target_per, current_profit_per)
        current_target_price := target
        current_sl_price := sl
        current_profit_per := profit_per
        current_target_per := target_per
    stop_condition_long := math.max(stop_condition_long[1], current_sl_price)
else
    stop_condition_long := new_stop_condition_long

stop_condition_short = 99999999.9
new_stop_condition_short = sp_high + (hl_diff * kauf_mult)
if (strategy.position_size < 0)
    if (sp_close < current_target_price)
        [target, sl, profit_per, target_per] = target_reached(false, min_profit_sl, current_target_per, current_profit_per)
        current_target_price := target
        current_sl_price := sl
        current_profit_per := profit_per
        current_target_per := target_per
    stop_condition_short := math.min(stop_condition_short[1], current_sl_price)
else
    stop_condition_short := new_stop_condition_short

// Submit entry orders
if (enter_long and (strategy.position_size <= 0))
    if (strategy.position_size < 0)
        strategy.close(id="SHORT")
    current_target_per := (min_profit_sl / 100.0)
    current_profit_per := na
    [target, sl] = set_targets(true, min_profit_sl, current_target_per, current_profit_per)
    current_target_price := target
    current_sl_price := sl
    strategy.entry(id="LONG", direction=strategy.long)

    if show_plots
        label.new(bar_index, sp_high, text="LONG\nSL: " + str.tostring(stop_condition_long), style=label.style_label_down, color=color.green)





if (enter_short and (strategy.position_size >= 0))
    if (strategy.position_size > 0)
        strategy.close(id="LONG")
    current_target_per := (min_profit_sl / 100.0)
    current_profit_per := na
    [target, sl] = set_targets(false, min_profit_sl, current_target_per, current_profit_per)
    current_target_price := target
    current_sl_price := sl
    strategy.entry(id="SHORT", direction=strategy.short)
    if show_plots
        label.new(bar_index, sp_high, text="SHORT\nSL: " + str.tostring(stop_condition_short), style=label.style_label_down, color=color.red)

if (strategy.position_size > 0)
    strategy.exit(id="EXIT LONG", stop=stop_condition_long)

if (strategy.position_size < 0)
    strategy.exit(id="EXIT SHORT", stop=stop_condition_short)

// Plot anchor trend
plotshape(low_condition_long, style=shape.triangleup, location=location.abovebar, color=color.green)
plotshape(low_condition_short, style=shape.triangledown, location=location.abovebar, color=color.red)

plotshape(condition_long, style=shape.triangleup, location=location.belowbar, color=color.green)
plotshape(condition_short, style=shape.triangledown, location=location.belowbar, color=color.red)

plotshape(enter_long, style=shape.triangleup, location=location.bottom, color=color.green)
plotshape(enter_short, style=shape.triangledown, location=location.bottom, color=color.red)

// Plot emas
plot(ta.ema(close, 20), color=color.blue, title="20 EMA")
plot(ta.ema(close, 50), color=color.orange, title="50 EMA")
plot(ta.sma(close, 200), color=color.red, title="MA 200")

// Plot stop loss values for confirmation
plot(series=(strategy.position_size > 0) and show_plots ? stop_condition_long : na, color=color.green, style=plot.style_linebr, title="Long Stop")
plot(series=(strategy.position_size < 0) and show_plots ? stop_condition_short : na, color=color.green, style=plot.style_linebr, title="Short Stop")
plot(series=(strategy.position_size < 0) and show_plots ? current_target_price : na, color=color.yellow, style=plot.style_linebr, title="Short TP")
plot(series=(strategy.position_size > 0) and show_plots ? current_target_price : na, color=color.yellow, style=plot.style_linebr, title="Long TP")