スーパートレンド基本戦略


作成日: 2023-10-11 15:14:54 最終変更日: 2023-10-11 15:14:54
コピー: 0 クリック数: 907
1
フォロー
1617
フォロワー

概要

スーパートレンドベース戦略は,スーパートレンド指標 ((ATR),相対的に強い指標 ((RSI),指数移動平均線 ((EMA) の3つの強力な指標に基づいた信頼性の高い収益性の高いアルゴリズム取引戦略である.この戦略は,市場トレンドの方向と強さを識別し,最適なエントリーポイントで市場に参入し,ストップポイントまたはストップポイントに達したときに退出することを目的としている.

戦略原則

この戦略は,価格が上昇傾向にあるか下落傾向にあるかを判断するために超トレンド指標を使用する.超トレンド指標は,平均的な実際の波幅と,価格が超トレンドより高い場合,上昇傾向であり,価格が超トレンドより低い場合,下降傾向であるという因子に基づいている.

比較的強い指数は,過熱と過買または過売の状況を検出するために使用されます. RSIが50を超えると,強い市場であり,逆に弱い市場です. RSIは偽の突破をフィルターすることができます.

指数移動平均は,長期トレンドの方向を判断するために使用される.価格がEMAより高いときは上昇傾向で,低ければ下降傾向である.取引の方向を確認するために使用される.

この戦略の取引シグナルは以下の通りです.

多頭入場:価格が超トレンドより高く,RSIが50より高く,価格がEMAより高くなると多頭入場 多頭出場:価格が超トレンド以下で閉じるか,止まるか,停止する

空頭入場:価格が超トレンド以下で,RSIが50以下で,価格がEMA以下で空白
空頭出場:価格が超トレンド以上で閉じるか,止まるか,停止する

ストップ・ロースとストップ・ストップは,入場価格のパーセントとして設定できます.

優位分析

この戦略の利点は以下の通りです.

  1. 3つの指標の組み合わせを使用して,トレンドの方向を確実に判断します.

  2. スーパートレンド指数は,上昇傾向と下降傾向を明確に判断します.

  3. RSIは偽のブレイクをフィルターで過買過売を防ぐことができます.

  4. EMAは,大きなトレンドの方向を特定するために使用できます.

  5. 戦略信号はシンプルで明快で操作が簡単です.

  6. ATRサイクル,RSIパラメータ,EMAサイクルを最適化できる

  7. リスク管理のためのストップ・ストップを設定できます.

  8. 市場環境の変化に合わせて 多額や空白でしか働けない

  9. 任意の時間周期で使用できます.

リスク分析

この戦略の主なリスクは以下の通りです.

  1. 超トレンドの指標は,大きなトレンドが逆転すると遅滞し,損失を引き起こす可能性があります.

  2. ストップ・ロープが小さすぎると,大きな動きを捉えられない可能性があります.

  3. EMAはトレンドの転換点を判断できない

  4. 脱退を判断できない

  5. 変動リスクと時間取引リスクがあります.

対応方法:

  1. 他の指標と組み合わせると 傾向が逆転する

  2. ストップダストのパラメータを最適化

  3. 他の指標と組み合わせると 傾向が逆転する

  4. 逆行指数と組み合わせた

  5. ポジション管理を適切に調整する

最適化の方向

この戦略は以下の点で最適化できます.

  1. ATRサイクルパラメータを最適化して,感度と安定性をバランスさせる

  2. RSIパラメータを最適化し,精度を向上させる

  3. EMAサイクルを最適化して,異なる市場に対応する

  4. MACD,KDなどの他の指標を追加します.

  5. 指標から逸脱する判断の反転

  6. 波の理論と合わさった判断の逆転

  7. 機械学習などのアルゴリズムの動的最適化パラメータ

  8. トラッキングストップ,移動ストップなどの高度なストップアルゴリズムを追加

  9. ポジション管理を最適化し,変動する市場に対応

  10. より複雑な出入り条件の組み合わせをテストする

要約する

スーパートレンドの基本戦略は,スーパートレンド,RSI,EMAの3つの指標を統合して,簡単な実用的なトレンド追跡戦略を形成する.それは,トレンドの方向を明確に識別し,偽信号をフィルターし,大きなトレンドを確認する.同時に,明確な入場出場規則とストップ・ロスの設定があります.この戦略は,操作が簡単で,信頼性の高い利益を得ることができ,任意の時間周期に適用されます.指標の数を最適化し,トレンド判断ツールのパラメータを追加し,ストップ・ロスのアルゴリズムを改良することによって,この戦略をより強力な取引システムに最適化することができます.

ストラテジーソースコード
/*backtest
start: 2023-09-10 00:00:00
end: 2023-10-10 00:00:00
period: 2h
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/
// © JS_TechTrading

//@version=5
// strategy("Supertrend", overlay=true,default_qty_type =strategy.percent_of_equity,default_qty_value = 1,process_orders_on_close = false)

// group string////
var string group_text000="Choose Strategy"
var string group_text0="Supertrend Settings"
var string group_text0000="Ema Settings"
var string group_text00="Rsi Settings"
var string group_text1="Backtest Period"
var string group_text2="Trade Direction"
// var string group_text3="Quantity Settings"
var string group_text4="Sl/Tp Settings"
////////////////////
option_ch=input.string('Pullback',title = "Type Of Strategy",options =['Pullback','Simple'])

//atr period input supertrend 
atrPeriod = input(10, "ATR Length",group = group_text0)
factor = input.float(3.0, "Factor", step = 0.01,group=group_text0)

[supertrend, direction] = ta.supertrend(factor, atrPeriod)

bodyMiddle = plot((open + close) / 2, display=display.none)
upTrend = plot(direction < 0 ? supertrend : na, "Up Trend", color = color.green, style=plot.style_linebr)
downTrend = plot(direction < 0? na : supertrend, "Down Trend", color = color.red, style=plot.style_linebr)

fill(bodyMiddle, upTrend, color.new(color.green, 90), fillgaps=false)
fill(bodyMiddle, downTrend, color.new(color.red, 90), fillgaps=false)

long=direction < 0 ? supertrend : na
short=direction < 0? na : supertrend

longpos=false
shortpos=false

longpos :=long?true :short?false:longpos[1]
shortpos:=short?true:long?false:shortpos[1]

fin_pullbuy= (ta.crossunder(low[1],long) and long and high>high[1])
fin_pullsell=(ta.crossover(high[1],short) and short and low<low[1]) 

//Ema 1
on_ma=input.bool(true,"Ema Condition On/Off",group=group_text0000)
ma_len= input.int(200, minval=1, title="Ema Length",group = group_text0000)
ma_src = input.source(close, title="Ema Source",group = group_text0000)
ma_out = ta.ema(ma_src, ma_len)

ma_buy=on_ma?close>ma_out?true:false:true
ma_sell=on_ma?close<ma_out?true:false:true

// rsi indicator and condition
// Get user input
en_rsi    = input.bool(true,"Rsi Condition On/Off",group = group_text00)
rsiSource = input(title='RSI Source', defval=close,group = group_text00)
rsiLength = input(title='RSI Length', defval=14,group = group_text00)
rsiOverbought = input(title='RSI BUY Level', defval=50,group = group_text00)
rsiOversold   = input(title='RSI SELL Level', defval=50,group = group_text00)

// Get RSI value
rsiValue = ta.rsi(rsiSource, rsiLength)

rsi_buy=en_rsi?rsiValue>=rsiOverbought ?true:false:true
rsi_sell=en_rsi?rsiValue<=rsiOversold?true:false:true

// final condition
buy_cond=option_ch=='Simple'?long and not(longpos[1]) and rsi_buy and ma_buy:option_ch=='Pullback'?fin_pullbuy and rsi_buy and ma_buy:na
sell_cond=option_ch=='Simple'?short and not(shortpos[1]) and rsi_sell and ma_sell:option_ch=='Pullback'?fin_pullsell and rsi_sell and ma_sell:na

//backtest engine
start = input(timestamp('2005-01-01'), title='Start calculations from',group=group_text1)
end=input(timestamp('2045-03-01'), title='End calculations',group=group_text1)
time_cond =true

// Make input option to configure trade direction

tradeDirection = input.string(title='Trade Direction', options=['Long', 'Short', 'Both'], defval='Both',group = group_text2)

// Translate input into trading conditions
longOK  = (tradeDirection == "Long") or (tradeDirection == "Both")
shortOK = (tradeDirection == "Short") or (tradeDirection == "Both")



// strategy start
if buy_cond and longOK and time_cond and strategy.position_size==0
    strategy.entry('long',direction = strategy.long)
if sell_cond and shortOK and time_cond and strategy.position_size==0
    strategy.entry('short',direction =strategy.short)

// fixed percentage based stop loss and take profit 

// User Options to Change Inputs (%)
stopPer = input.float(1.0,step=0.10, title='Stop Loss %',group =group_text4) / 100
takePer = input.float(1.0,step =0.10, title='Take Profit %',group =group_text4) / 100

// Determine where you've entered and in what direction
longStop  = strategy.position_avg_price * (1 - stopPer)
shortStop = strategy.position_avg_price * (1 + stopPer)
shortTake = strategy.position_avg_price * (1 - takePer)
longTake  = strategy.position_avg_price * (1 + takePer)


if strategy.position_size > 0
    strategy.exit(id='Close Long',stop=longStop, limit=longTake)
if strategy.position_size < 0
    strategy.exit(id='Close Short',stop=shortStop, limit=shortTake)

//PLOT FIXED SLTP LINE
plot(strategy.position_size > 0 ? longStop : na, style=plot.style_linebr, color=color.new(color.red, 0), linewidth=1, title='Long Fixed SL')
plot(strategy.position_size < 0 ? shortStop :na, style=plot.style_linebr, color=color.new(color.red, 0), linewidth=1, title='Short Fixed SL')
plot(strategy.position_size > 0 ? longTake : na, style=plot.style_linebr, color=color.new(color.green, 0), linewidth=1, title='Long Take Profit')
plot(strategy.position_size < 0 ? shortTake : na, style=plot.style_linebr, color=color.new(color.green, 0), linewidth=1, title='Short Take Profit')

//