二重量取引システム

作者: リン・ハーンチャオチャン開催日:2024年2月26日 14時30分54秒
タグ:

img

この戦略は,CCI指標,RSI指標,および2つの移動平均を複合取引システムに組み合わせます.いくつかのノイズをフィルタリングするためにエントリへの確認を追加するためにRSIクロスオーバーを使用しながら従来のトレンドを捕捉することができます.

戦略原則

この戦略は主にCCI指標を使用してトレンド方向を決定する.CCI値は100以上で上昇市場を示し,-100以下は下落市場を示します.システムはトレンド方向を決定するのに2つの移動平均クロスオーバーを使用します.高速移動平均がスロー移動平均を上回ると,それは購入信号であり,売り信号には逆です.

上昇傾向または下落傾向を決定した後,システムは入力検証として異なるパラメータ長さの2つのRSIのクロスオーバーを使用します.例えば,牛市では,短期RSIが長期RSIを超えると,最終的な購入信号です.このデザインは主にトレンド中に短期的訂正によって引き起こされる間違った取引を避けるためにノイズをフィルターします.

この戦略は,指定された取引セッション中にのみポジションを開き,オバーナイトリスクを避けるため,閉じる15分前にすべてのポジションを積極的に閉じる. ポジションを開いた後,トライリングストップを使用して利益をロックします.

利点分析

  • 傾向判断と指標クロスオーバーを組み合わせることで,傾向を効果的に特定し,正確なエントリのためのノイズをフィルタリングすることができます.
  • リスクを積極的に制御するために後続停止を使用することで,フラッシュクラッシュによる停止を避ける
  • 指定された取引セッション中にのみポジションを開くことで,一夜間ギャップリスクが回避されます.
  • 調整可能なRSIパラメータは,異なる市場環境に柔軟に適応できます

リスク分析

  • CCIは異常な変動市場での不良業績を示している
  • 双重RSIのクロス条件は比較的厳格で,いくつかの機会を逃す可能性があります.
  • トレイリングストップは過剰に主観的であり,パラメータ最適化が必要である
  • 指定された取引セッションは,夜間ニュースの大幅なギャップを見逃す可能性があります.

最適化 の 提案

  • 最適な設定を見つけるために異なるCCIパラメータの組み合わせをテストする
  • RSIクロスオーバー条件を取り除き,CCIに基づいて直接入力する試験
  • バックテストと最適化 トレイリングストップパラメータを最適設定を見つける
  • 強制的なポジション閉じるロジックを取り除き,代わりにポジション中にトレーリングストップで利益を追跡し,利益を最大化します

概要

この戦略は,リスクを制御しながら信号の有効性を確保するために,トレンド決定と指標クロスオーバー検証を包括的に考慮する.パラメータ最適化と論理調整を通じて,戦略は利益機会を拡大し,逃したチャンスを減らす可能性がさらに高い.これは非常に有望な取引コンセプトです.


/*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"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © rwestbrookjr

//@version=5
strategy("EMA with RSI Cross Strategy", overlay=true)

//EMA
fastLen = input(title='Fast EMA Length', defval=9)
slowLen = input(title='Slow EMA Length', defval=20)

fastEMA = ta.ema(close, fastLen)
slowEMA = ta.ema(close, slowLen)

fema = plot(fastEMA, title='FastEMA', color=color.new(color.green, 0), linewidth=1, style=plot.style_line)
sema = plot(slowEMA, title='SlowEMA', color=color.new(color.red, 0), linewidth=1, style=plot.style_line)

fill(fema, sema, color=fastEMA > slowEMA ? color.new(#417505, 50) : color.new(#890101, 50), title='Cloud')

// Bull and Bear Alerts
//Bull = ta.crossover(fastEMA, slowEMA)
Bull = fastEMA > slowEMA
//Bear = ta.crossunder(fastEMA, slowEMA)
Bear = fastEMA < slowEMA

//RSIs
rsiLength1Input = input.int(9, minval=1, title="RSI Length", group="RSI Settings")
rsiSource1Input = input.source(close, "Source", group="RSI Settings")
rsiLength2Input = input.int(20, minval=1, title="RSI Length", group="RSI Settings")
rsiSource2Input = input.source(close, "Source", group="RSI Settings")

up1 = ta.rma(math.max(ta.change(rsiSource1Input), 0), rsiLength1Input)
down1 = ta.rma(-math.min(ta.change(rsiSource1Input), 0), rsiLength1Input)
rsi = down1 == 0 ? 100 : up1 == 0 ? 0 : 100 - (100 / (1 + up1 / down1))
up2 = ta.rma(math.max(ta.change(rsiSource2Input), 0), rsiLength2Input)
down2 = ta.rma(-math.min(ta.change(rsiSource2Input), 0), rsiLength2Input)
rsi2 = down2 == 0 ? 100 : up2 == 0 ? 0 : 100 - (100 / (1 + up2 / down2))

//CCI
cciLength = input.int(20, minval=1)
src = input(hlc3, title="Source")
ma = ta.sma(src, cciLength)
cci = (src - ma) / (0.015 * ta.dev(src, cciLength))

//Trail Stop Setup
trstp = input.float(title="Trail Loss($)", minval = 0.0, step = 0.01, defval = 0.5)

longStop = 0.0, shortStop = 0.0

longStop := if Bull
    stopValue = close - trstp
    math.max(stopValue, longStop[1])
else
    0.0

shortStop := if Bear
    stopValue = close + trstp
    math.min(stopValue, shortStop[1])
else
    999999


//Session Setup
open_session=input(defval="0930-1545")
session = time("1", open_session)
validSession=(na(session) ? 0 : 1)

//Trade Signals
longCondition = Bull and cci > 100 and ta.crossover(rsi,rsi2) and validSession
if (longCondition)
    strategy.entry("Long", strategy.long, 1)
    
//longExit = close > strategy.opentrades.entry_price(0) + 1.5 or close < strategy.opentrades.entry_price(0) - 0.75
longExit = close < longStop or not validSession
if (longExit)
    strategy.close("Long")

shortCondition = Bear and cci < 100 and ta.crossunder(rsi,rsi2) and validSession
if (shortCondition)
    strategy.entry("Short", strategy.short, 1)

//shortExit = close < strategy.opentrades.entry_price(0) - 1.5 or close > strategy.opentrades.entry_price(0) + 0.75
shortExit = close > shortStop or not validSession
if (shortExit)
    strategy.close("Short")


もっと