トリプル・スーパートレンドとストック・RSI戦略

作者: リン・ハーンチャオチャン, 日付: 2023-12-06 14:29:00
タグ:

img

概要

トリプルスーパートレンドとストックRSI戦略は,スーパートレンド指標のマルチタイムフレームトレンドフォローとストックRSI指標のオーバーバイト/オーバーセールシグナルを組み合わせる定量的な取引戦略である.この戦略は,市場トレンドを決定するために異なるパラメータ設定を持つ3つのスーパートレンド指標を使用し,ストックRSI信号を組み合わせて取引信号をフィルターする.特に,2つの高速なスーパートレンド指標が同時購入/販売信号を与える場合,ストックRSI指標が確認した場合,対応するロング/ショートポジションが取られる.

戦略の論理

トリプルスーパートレンドとストックRSI戦略の基本的な論理は,異なるパラメータを持つスーパートレンド指標とストックRSI指標を組み合わせて,シグナル品質を改善し,偽信号を減らすため,トレードシグナルフィルタリングを行うことです.

まず,戦略は主要な市場トレンドを決定するために,異なるパラメータ設定を持つ3つのスーパートレンド指標を採用する. 3つのスーパートレンド指標は,異なるレベルのトレンド変化を把握するために,高速から遅いタイムフレームまでのパラメータを持っています. 最も高速で2番目に速いスーパートレンド指標が同時購入/販売信号を与える場合,我々は信号が一定の信頼性を持っているという予備的な判断を下します.

2つ目は,STOCH RSIインジケーターが導入され,シグナルが発生するときに市場が極端に過買いまたは過売れているかどうかを判断する.STOCH RSIインジケーターは,RSIとストカスタスティックインジケーターの強みを組み合わせ,過買い/過売れた市場状況に関する効果的な判断を可能にします.最も速いと2番目に速いスーパートレンド信号がSTOCH RSI信号に一致すると,最終的な買い/売る信号が起動できます.

多数の指標とタイムフレームを組み合わせることで トリプルスーパートレンドとストックRSI戦略は 市場のノイズを効果的にフィルタリングし,信号の信頼性を向上させ,不正な取引を減らすことができます

戦略 の 利点

トリプルスーパートレンドとストックRSI戦略の最大の利点は,複数の指標とタイムフレームを効果的に組み合わせることで,以下の利点をもたらします.

  1. 誤った取引信号を減らす.スーパートレンドとストックRSIの3つの指標の組み合わせは,個々の指標に伴うノイズと誤った信号を大幅に減少させることができます.

  2. 収益性の高い信号比率を向上させる. 信号周波数が低下しているにもかかわらず,収益性の高い信号の比率は著しく改善している.

  3. トレンド市場に適しています.マルチタイムフレームフィルタリングは,中長期のトレンドを把握し,トレンド市場環境に適しています.

  4. 性能向上のための楽な最適化.三重指標はパラメータ最適化のためのより広い可能性を可能にします.

  5. 個人的取引スタイルに対応するカスタマイズ可能なパラメータ.パラメータは,自分の取引スタイルにより適するように自由に調整できます.

戦略 の リスク

トリプル・スーパートレンドとストック・RSIの戦略にはいくつかのリスクもあります.

  1. シグナル周波数が低下する.多層フィルターメカニズムは戦略の取引頻度を大幅に低下させる.

  2. 保守的な性質により 戦略は 収益性の高い機会を 逃す可能性があります

  3. パラメータ依存度が高まる.より多くの指標は最適化に困難を伴う.

  4. 複数のタイムフレームの組み合わせは,戦略のトレンドフォローの柔軟性を制限します.

これらのリスクに対処するために,指標パラメータの調整や追加の指標の導入などの最適化措置が採用され,収益性の質を向上させながらリスク管理を強化することができる.

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

トリプルスーパートレンドとストックRSI戦略のさらなる最適化にはまだ余地があります.

  1. 最適な組み合わせのための指標パラメータを調整します. 最適なものを発見するためにより多くのパラメータをテストすることができます.

  2. ストップ・ロスト/テイク・プロフィートを導入してリスク管理を改善します.これは戦略の安定性を大幅に向上させることができます.

  3. 信号検証のためのより多くの指標,例えば音量指標を組み込む.

  4. 変化する市場動態に応じてパラメータを自動最適化するための適応能力を構築します

  5. 性能予測のための機械学習アルゴリズムを組み合わせ 信号の精度を評価します

継続的な最適化により トリプルスーパートレンドとストックRSI戦略は安定で効率的な取引システムへと進化し,かなりのアルファを提供することができます.

結論

トリプルスーパートレンドとストックRSI戦略は,マルチタイムフレーム分析と過剰購入/過剰売却判断をユニークなトレンドフォローティング戦略に成功裏に組み合わせます.トレンドフォローとインジケーターフィルタリングの双重の利点を維持し,誤った信号を減少させながら収益性の高い信号を改善します.リスクと最適化スペースはまだ存在していますが,パラメータチューニングと戦略最適化によって収益性と安定性がさらに向上できます.全体として,トリプルスーパートレンドとストックRSI戦略は高品質の定量的な取引戦略選択を提供します.


/*backtest
start: 2022-11-29 00:00:00
end: 2023-04-17 00:00:00
period: 1d
basePeriod: 1h
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/
// © M3RZI

//@version=4
strategy("3x Supertrend and Stoch RSI", overlay = true, max_bars_back = 1000)

//INPUTS
STATRLENGTH1 = input(10, title = "Fast Supertrend ATR Length", type = input.integer, group = "SUPERTREND SETTINGS")
STATRMULT1 = input(1, title = "Fast Supertrend ATR Multiplier", type = input.float, group = "SUPERTREND SETTINGS")
STATRLENGTH2 = input(11, title = "Medium Supertrend ATR Length", type = input.integer, group = "SUPERTREND SETTINGS")
STATRMULT2 = input(2, title = "Medium Supertrend ATR Multiplier", type = input.float, group = "SUPERTREND SETTINGS")
STATRLENGTH3 = input(12, title = "Slow Supertrend ATR Length", type = input.integer, group = "SUPERTREND SETTINGS")
STATRMULT3 = input(3, title = "Slow Supertrend ATR Multiplier", type = input.float, group = "SUPERTREND SETTINGS")

stochK = input(3, title = "K (Stochastic Fast)", type = input.integer, group = "STOCHASTIC RSI SETTINGS")
stochD = input(3, title = "D (Signal Line)", type = input.integer, group = "STOCHASTIC RSI SETTINGS")
rsiLength = input(14, title = "RSI Length", type = input.integer, group = "STOCHASTIC RSI SETTINGS")
stochLength = input(14, title = "Stochastic Length", type = input.integer, group = "STOCHASTIC RSI SETTINGS")
rsiSource = input(close, title = "RSI Source", type = input.source, group = "STOCHASTIC RSI SETTINGS")
stochRestrictions = input(false, title = "Restrict crosses to overbought/oversold territory", type = input.bool, group = "STOCHASTIC RSI SETTINGS")
overboughtLine = input(80, title = "Stochastic  RSI Upper Band", type = input.integer, group = "STOCHASTIC RSI SETTINGS")
oversoldLine = input(20, title = "Stochastic RSI Lower Band", type = input.integer, group = "STOCHASTIC RSI SETTINGS")

EMALength  = input(200, title = "EMA Length", type = input.integer, group = "EMA SETTINGS")

SLStrategy = input("ATR Based", title = "Stop Loss Strategy", options = ["ATR Based"],type = input.string, group = "POSITION EXIT SETTINGS")
SLATRLength = input(14, title = "Stop Loss ATR Length", type = input.integer, group = "POSITION EXIT SETTINGS")
SLATRMult = input(2.7, title = "Stop Loss ATR Multiplier", type = input.float, group = "POSITION EXIT SETTINGS")
TPStrategy = input("ATR Based", title = "Take Profit Strategy", options = ["ATR Based"],type = input.string, group = "POSITION EXIT SETTINGS")
TPATRLength = input(14, title = "Take Profit ATR Length", type = input.integer, group = "POSITION EXIT SETTINGS")
TPATRMult = input(1.6, title = "Take Profit ATR Multiplier", type = input.float, group = "POSITION EXIT SETTINGS")

//SUPERTRENDS
[superTrend1,dir1] = supertrend(STATRMULT1,STATRLENGTH1)
[superTrend2,dir2] = supertrend(STATRMULT2,STATRLENGTH2)
[superTrend3,dir3] = supertrend(STATRMULT3,STATRLENGTH3)

directionST1 = dir1 == 1 and dir1[1] == 1 ? false : dir1 == -1 and dir1[1] == -1 ? true : na
directionST2 = dir2 == 1 and dir2[1] == 1 ? false : dir2 == -1 and dir2[1] == -1 ? true : na
directionST3 = dir3 == 1 and dir3[1] == 1 ? false : dir3 == -1 and dir3[1] == -1 ? true : na

//STOCH RSI
rsi = rsi(rsiSource, rsiLength)
k = sma(stoch(rsi, rsi, rsi, stochLength), stochK)
d = sma(k, stochD)

//EMA
ema = ema(close,EMALength)

//CONDITIONS LONG AND SHORT

var long = false
var longCondition = false
var short = false
var shortCondition = false
var drawing = false
var TP = 0.0
var SL = 0.0
var middle = 0.0
var initial = 0

stopSize = atr(SLATRLength) * SLATRMult
profitSize = atr(TPATRLength) * TPATRMult
longStop = close - stopSize
longProfit = close + profitSize
current = close
shortStop = close + stopSize
shortProfit = close - profitSize
barInitial = bar_index

if  stochRestrictions
    longCondition := close > ema and ((directionST1 == true and directionST2 == true)  or (directionST2 == true and directionST3 == true)) and crossover(k,d) and k < oversoldLine and not long and not drawing
    shortCondition := close < ema and ((directionST1 == false and directionST2 == false)  or (directionST2 == false and directionST3 == false)) and crossunder(k,d) and k > overboughtLine and not short and not drawing
else
    longCondition := close > ema and ((directionST1 == true and directionST2 == true)  or (directionST2 == true and directionST3 == true)) and crossover(k,d) and not long and not drawing
    shortCondition := close < ema and ((directionST1 == false and directionST2 == false)  or (directionST2 == false and directionST3 == false)) and crossunder(k,d) and not short and not drawing

if longCondition
    long := true
    short := false
    drawing := true
    TP := longProfit
    middle := current
    SL := longStop
    initial := barInitial
    strategy.entry("Long", strategy.long, 10)
    strategy.exit("Long exit","Long", limit = TP, stop = SL)
    alert("Long signal Supertrend \n Profit:"+tostring(TP)+"\Curret price:"+tostring(close)+"\Stop:"+tostring(SL),alert.freq_once_per_bar_close)
    //label.new(bar_index,low,text = "Long\nTP:"+tostring(TP)+"\nSL:"+tostring(SL)+"\nAbierto:"+tostring(current), yloc = yloc.belowbar, textcolor = color.white, color = color.green, size = size.small,  style = label.style_label_up)

if shortCondition
    short := true
    long := false
    drawing := true
    TP := shortProfit
    middle := current
    SL := shortStop
    initial := barInitial
    strategy.entry("Short", strategy.short, 10)
    strategy.exit("Short exit","Short",limit = TP , stop = SL)
    alert("Short signal Supertrend \n Profit:"+tostring(TP)+"\Curret price:"+tostring(close)+"\Stop:"+tostring(SL),alert.freq_once_per_bar_close)
    //label.new(bar_index,high,text = "Short\nTP:"+tostring(TP)+"\nSL:"+tostring(SL)+"\nAbierto:"+tostring(current), yloc = yloc.abovebar, textcolor = color.white, color = color.red, size = size.small,  style = label.style_label_down)

if long and (high[1] >= TP or low[1] <= SL)
    drawing := false
    long := false
    if high[1] >= TP
        label.new(bar_index[int((bar_index - initial)/2)],TP, text = "Win (Long)", textcolor = color.white, color = color.green, size = size.small, style = label.style_label_down)
    else
        label.new(bar_index[int((bar_index - initial)/2)],SL, text = "Lose (Long)", textcolor = color.white, color = color.red, size = size.small, style = label.style_label_up)

if short and (low[1] <= TP or high[1] >= SL)
    drawing :=  false
    short := false
    if low[1] <= TP
        label.new(bar_index[int((bar_index - initial)/2)],TP, text = "Win (short)", textcolor = color.white, color = color.green, size = size.small, style = label.style_label_up)
    else
        label.new(bar_index[int((bar_index - initial)/2)],SL, text = "Lose (short)", textcolor = color.white, color = color.red, size = size.small, style = label.style_label_down)

//STRATEGY
//strategy.entry("buy", strategy.long, 10, when = longCondition)
//strategy.exit("bracket", "buy",  10, limit = TP, stop = SL)
//strategy.entry("short", strategy.long, 10, when = shortCondition)
//strategy.exit("bracket", "short",  10, limit = TP, stop = SL)

//DRAWING
plotshape(longCondition, title = "Long Signal", location=location.belowbar, style=shape.labelup, color=color.green, textcolor=color.white, size=size.small, text="Long")
plotshape(shortCondition, title = "Short Signal", location=location.abovebar, style=shape.labeldown, color=color.red, textcolor=color.white, size=size.small, text="Short")
profitLine = plot(drawing and drawing[1] ? TP : na, title = "Take profit", color = color.green, style = plot.style_linebr)
currentLine =plot(drawing and drawing[1]  ? middle : na, title = "Middle Line", color = color.white, style = plot.style_linebr)
lossLine = plot(drawing and drawing[1]  ? SL : na, title = "Stop Loss", color = color.red, style = plot.style_linebr)
fill(currentLine,profitLine, title = "Profit Background" ,color = color.new(color.green,75))
fill(currentLine,lossLine, title = "Loss Background" ,color = color.new(color.red,75))
plot(superTrend1, title = "Fast Supertrend", color = dir1 == 1 and dir1[1] == 1 ? color.red : dir1 == -1 and dir1[1] == -1 ? color.green : na)
plot(superTrend2, title = "Medium Supertrend", color = dir2 == 1 and dir2[1] == 1 ? color.red : dir2 == -1 and dir2[1] == -1 ? color.green : na)
plot(superTrend3, title = "Slow Supertrend", color = dir3 == 1 and dir3[1] == 1 ? color.red : dir3 == -1 and dir3[1] == -1 ? color.green : na)
plot(ema, title = "EMA",color = color.yellow)
//plot(k, color = color.blue)
//plot(d, color = color.orange)
//h1 = hline(80)
//h2 = hline(20)
//fill(h1,h2, color = color.new(color.purple,60))




もっと