
トリプルスーパートレンドとストックRSI戦略は,複数の時間枠のトレンドフォローと超買い超売り指標を組み合わせた量化取引戦略である.この戦略は,3つの異なるパラメータセットのスーパートレンド指標を使用して市場傾向を判断し,ストックRSI指標の超買い超売り信号と組み合わせて取引信号を発信する.具体的には,この戦略は,より速い2つのスーパートレンド指標が同時に買入/売却信号を発信すると,ストックRSI指標もこの信号を確認した場合,相応の多出/空出操作が行われます.
三重のスーパートレンドとストックRSI戦略の核心的な論理は,異なるパラメータセットのスーパートレンド指標とストックRSI指標を組み合わせた取引信号のフィルタリングであり,信号の質を向上させ,誤信号率を低下させます.
まず,この戦略は,3つの異なるパラメータのSuperTrend指標を使用して,市場の主要なトレンドを判断する.この3つのSuperTrend指標のパラメータ設定は,異なる時間枠で,速いから遅いまで,異なるレベルのトレンドの変化を捉えるために使用されます.最も速いと二番目に速いSuperTrend指標が同時に買い/売りシグナルを発信すると,このシグナルには一定の信頼性があると予備的に判断します.
次に,戦略はストックRSIを導入し,信号が過度に過買または過売されているかどうかを判断します.ストックRSIは,ランダム指数RSIとランダム指数ストキャスティックの優位性を組み合わせて,市場が過買または過売状態にあるかどうかを効果的に判断します. 最速のスーパートレンドと次期のスーパートレンドがストックRSIと一致する場合は,最終的な買入/売却信号を発信できます.
複数の指標と複数の時間枠を組み合わせることで,三重のスーパートレンドとストックRSI戦略は,市場騒音を効果的にフィルターし,信号の信頼性を高め,誤った取引の発生を減らすことができます.
三重スーパートレンドとストックRSI戦略の最大の利点は,複数の指標と複数の時間枠を効果的に組み合わせることです.これは,以下の利点をもたらします.
誤った取引シグナルを減らす. 三重スーパートレンド指標とストックRSI指標の組み合わせは,単一の指標に存在するノイズ信号と誤った信号を大幅に減らすことができます.
信号比率を上げます.信号周波数が低下しても,信号比率は著しく向上します.
トレンド性市場に適している.多時間枠の波は中長線トレンドを捕捉するのに有利であり,傾向がより顕著な市場環境に適している.
パラメータ最適化によりよりよい効果が得られる. 三重指標は,パラメータ最適化のためのより大きな可能性の余地を提供します.
パーソナルスタイルに合わせてパラメータを調整できます. 戦略を自分の取引スタイルに合わせてパラメータを自由に調整できます.
三重スーパートレンドとストックRSIの戦略にはいくつかのリスクがあり,主に以下のいくつかの側面に焦点を当てています.
信号の頻度が低下する.多層のフィルタリングメカニズムにより,戦略の取引頻度が明らかに低下する.
戦略の保守性は,潜在的機会のいくつかを逃すのを容易にする.
複数の指標がパラメータ依存度を増加させる.指標やパラメータが多ければ多いほど,戦略の最適化も難しくなる.
複数の時間枠を組み合わせることで,戦略のトレンドへの柔軟性も制限されます.
上記のリスクに対して,指標のパラメータを調整し,より多くの補助判断指標を導入することで最適化することができ,リスクを制御しながら,戦略がより高い収益質を得ることができます.
三重スーパートレンドとストックRSIの戦略は,次のいくつかの点でさらに最適化できる:
指標パラメータの組み合わせを調整して,最適なパラメータのマッチを見つけます.より多くの指標パラメータのテストを導入して,最適なパラメータを見つけることができます.
ストップ・ストップ・ストップの戦略を追加し,単一取引のリスクを制御する.これは戦略の安定性を大幅に向上させることができる.
より多くの判断指標を導入し,信号検証を行う.例えば,取引量指標を導入し,複数の角度から判断を行う.
戦略を自動的に最適化し,市場変化に適応するパラメータを調整する機能を追加した.
機械学習アルゴリズムと組み合わせて予測する.AIアルゴリズムを用いて指標信号の予測の正確性.
継続的な最適化によって,三重のスーパートレンドとストック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))