スーパートレンドV戦略

作者: リン・ハーンチャオチャン開催日:2023年10月18日 12:35:53
タグ:

img

概要

スーパートレンドV戦略は,移動平均値と標準偏差値に基づいた短期的取引戦略である.スーパートレンド指標を使用して価格傾向方向を決定し,移動平均値によって形成されたサポートとレジスタンスを組み合わせて市場に参入する.一方,標準偏差チャネルを使用して価格の潜在的なサポートとレジスタンスゾーンを予測し,ストップ損失を設定し,利益の価格範囲を設定し,トレンドをフォローし,効率的に脱出する短期的取引戦略を実装する.

戦略の論理

まず,この戦略はスーパートレンド指標を計算する.スーパートレンド指標は,トレンド方向を決定するためにATRと価格の関係を使用する.価格が上昇傾向の上にあるとき,それは上昇傾向である.価格が下落傾向下にあるとき,それは下落傾向である.

価格のEMAとオープン価格のEMAを計算します.価格がEMAを超越し,オープン価格EMAよりも高くなった場合,それは購入信号です.価格がEMAを下回り,オープン価格EMAより低い場合,それは販売信号です.

次に,標準偏差を使用して価格チャネルの上下帯を計算し,スムージング処理を行います.価格が標準偏差の上帯を突破すると,ストップロスの信号です.価格が標準偏差の下帯を突破すると,利益の信号です.

最後に,異なるタイムフレームの移動平均を組み合わせて,トレンド方向を決定し,スーパートレンド指標と共に,安定したトレンド判断を形成します.

戦略 の 利点

  • スーパートレンド指標を使用して,トレンド逆転による損失を回避し,価格トレンドの方向性を決定します.
  • オープン価格と組み合わせた移動平均値は,誤った分解を回避し,エントリータイミングを決定するのに役立ちます.
  • 標準偏差チャネルは,ストップ・ロストと得益の価格の潜在的なサポートとレジスタンスゾーンを予測します.
  • 複数のタイムフレームの組み合わせは,トレンド判断の安定性を向上させる

戦略 の リスク

  • スーパートレンドインジケーターは遅延効果があり,トレンド変化点を逃す可能性があります.
  • 移動平均値のクロスオーバーは遅延効果があり,エントリータイミングが正確ではない可能性があります.
  • 標準偏差チャネルの範囲は,リアルタイムで市場の変動を反映するには,あまりにも固定されている.
  • 複数の時間枠に基づく判断が相互に矛盾する可能性があります

リスク管理

  • センシビリティを向上させるため,スーパートレンドパラメータを適切に短縮します.
  • 移動平均期間の最適化,またはエントリを決定するために他の指標を追加
  • 標準偏差チャネルを動的に調整し,市場に対応する
  • 紛争を処理するための複数のタイムフレームの判断のための明確な論理を定義する

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

  • 最高の組み合わせを見つけるためにスーパートレンドパラメータを最適化
  • 入力を決定するために移動平均値と組み合わせた他の指標を試す
  • 標準偏差チャネルの動的調整を試す
  • 最適なマッチを見つけるために異なるマルチタイムフレームの組み合わせをテストします
  • ストップ・ロスの最適化と,利益の空間を向上させるための利益戦略を取ること

結論

スーパートレンドV戦略は,トレンド,移動平均,標準偏差チャネル,その他の指標の優位性を統合し,安定したトレンド判断,適切なエントリータイミング,価格ゾーンに基づいてストップ損失と利益を引き出すことができる.パラメータ,指標,ストップ損失と利益を引き出すなどの最適化により,戦略の安定性と収益性を向上させることができる.その堅牢な論理と厳格な思考は学び,研究する価値があります.


/*backtest
start: 2022-10-11 00:00:00
end: 2023-10-17 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// © theCrypster 2020

//@version=4
strategy(title = "Super trend V Strategy version", overlay = true, pyramiding=1,initial_capital = 1000, default_qty_type= strategy.percent_of_equity, default_qty_value = 100, calc_on_order_fills=false, slippage=0,commission_type=strategy.commission.percent,commission_value=0.075)
strat_dir_input = input(title="Strategy Direction", defval="long", options=["long", "short", "all"])
strat_dir_value = strat_dir_input == "long" ? strategy.direction.long : strat_dir_input == "short" ? strategy.direction.short : strategy.direction.all
strategy.risk.allow_entry_in(strat_dir_value)
hilow = ((high - low)*100)
openclose = ((close - open)*100)
vol = (volume / hilow)
spreadvol = (openclose * vol)
VPT = spreadvol + cum(spreadvol)
window_len = 28

v_len = 14
price_spread = stdev(high-low, window_len)

v =  spreadvol + cum(spreadvol)
smooth = sma(v, v_len)
v_spread = stdev(v - smooth, window_len)
shadow = (v - smooth) / v_spread * price_spread

out = shadow > 0 ? high + shadow : low + shadow
//
src = out
src1=open
src2=low
src3=high
tf =input(720)
len = timeframe.isintraday and timeframe.multiplier >= 1 ? 
   tf / timeframe.multiplier * 7 : 
   timeframe.isintraday and timeframe.multiplier < 60 ? 
   60 / timeframe.multiplier * 24 * 7 : 7

c = ema(src, len)
plot(c,color=color.red)
o = ema(src1,len)
plot(o,color=color.blue)
//h = ema(src3,len)
//l=ema(src2,len)
//
col=c > o? color.lime : color.orange
vis = true
vl = c
ll = o
m1 = plot(vl, color=col, linewidth=1, transp=60)
m2 = plot(vis ? ll : na,  color=col, linewidth=2, transp=80)

fill(m1, m2,  color=col, transp=70)
//

vpt=ema(out,len)

// INPUTS //
st_mult   = input(1,   title = 'SuperTrend Multiplier', minval = 0, maxval = 100, step = 0.01)
st_period = input(10, title = 'SuperTrend Period',     minval = 1)

// CALCULATIONS //
up_lev = vpt - (st_mult * atr(st_period))
dn_lev = vpt + (st_mult * atr(st_period))

up_trend   = 0.0
up_trend   := close[1] > up_trend[1]   ? max(up_lev, up_trend[1])   : up_lev

down_trend = 0.0
down_trend := close[1] < down_trend[1] ? min(dn_lev, down_trend[1]) : dn_lev

// Calculate trend var
trend = 0
trend := close > down_trend[1] ? 1: close < up_trend[1] ? -1 : nz(trend[1], 1)

// Calculate SuperTrend Line
st_line = trend ==1 ? up_trend : down_trend

// Plotting
plot(st_line[1], color = trend == 1 ? color.green : color.red , style = plot.style_cross, linewidth = 2, title = "SuperTrend")
buy=crossover( close, st_line) and close>o
sell=crossunder(close, st_line) and close<o
//plotshape(crossover( close, st_line), location = location.belowbar, color = color.green,size=size.tiny)
//plotshape(crossunder(close, st_line), location = location.abovebar, color = color.red,size=size.tiny)
plotshape(buy, title="buy", text="Buy", color=color.green, style=shape.labelup, location=location.belowbar, size=size.small, textcolor=color.white, transp=0)  //plot for buy icon
plotshape(sell, title="sell", text="Sell", color=color.red, style=shape.labeldown, location=location.abovebar, size=size.small, textcolor=color.white, transp=0)  //plot for sell icon


//
multiplier = input(title="TP VWAP Deviation", type=input.float, defval=2, minval=1)
src5 = vwap
len5 = input(title="TP length", defval=150, minval=1)
offset = 0

calcSlope(src5, len5) =>
    sumX = 0.0
    sumY = 0.0
    sumXSqr = 0.0
    sumXY = 0.0
    for i = 1 to len5
        val = src5[len5-i]
        per = i + 1.0
        sumX := sumX + per
        sumY := sumY + val
        sumXSqr := sumXSqr + per * per
        sumXY := sumXY + val * per
        
        
    slope = (len5 * sumXY - sumX * sumY) / (len5 * sumXSqr - sumX * sumX)
    average = sumY / len5
    intercept = average - slope * sumX / len5 + slope
    [slope, average, intercept]

var float tmp = na
[s, a, i] = calcSlope(src5, len5)

vwap1=(i + s * (len5 - offset))
sdev = stdev(vwap, len5)
dev = multiplier * sdev
top=vwap1+dev
bott=vwap1-dev

//
z1 = vwap1 + dev
x1 = vwap1 - dev

low1 = crossover(close, x1)  
high1 = crossunder(close, z1) 

plotshape(low1, title="low", text="TP", color=color.red, style=shape.labelup, location=location.belowbar, size=size.small, textcolor=color.white, transp=0)  //plot for buy icon
plotshape(high1, title="high", text="TP", color=color.green, style=shape.labeldown, location=location.abovebar, size=size.small, textcolor=color.white, transp=0)  //plot for sell icon



//
// Testing Start dates
testStartYear = input(2016, "Backtest Start Year")
testStartMonth = input(1, "Backtest Start Month")
testStartDay = input(1, "Backtest Start Day")
testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,0,0)
//Stop date if you want to use a specific range of dates
testStopYear = input(2030, "Backtest Stop Year")
testStopMonth = input(12, "Backtest Stop Month")
testStopDay = input(30, "Backtest Stop Day")
testPeriodStop = timestamp(testStopYear,testStopMonth,testStopDay,0,0)


testPeriod() =>
    time >= testPeriodStart and time <= testPeriodStop ? true : false

l = buy
s1 = sell
        
if l and testPeriod()
    strategy.entry("buy", strategy.long)
if s1 and testPeriod()
    strategy.entry("sell", strategy.short)



もっと