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

作者: リン・ハーンチャオチャン,日付: 2023年10月11日 15:14:54
タグ:

概要

スーパートレンド基本戦略は,スーパートレンド (ATR),RSI,EMA) という3つの強力な指標に基づいた信頼性と収益性の高いアルゴリズム取引戦略である.市場トレンドの方向性と強さを特定し,最適なポイントで市場に参入し,ストップ損失または利益を得ると退場することを目的としている.

戦略の論理

この戦略は,価格が上昇傾向か下落傾向にあるかを判断するためにスーパートレンド指標を使用する.スーパートレンドは平均真の範囲と要素に基づいており,スーパートレンドの上は上昇傾向,下は下落傾向である.

RSIは,過買い/過売り状態を検出するために使用される.50を超えると上昇し,50を下回ると下落する.RSIは誤った信号をフィルタリングする.

EMAは長期的トレンド方向を判断します. EMAの上は上昇傾向,下は下落傾向です.取引の方向性を確認します.

取引シグナルは次のとおりです

ロングエントリー: スーパートレンド上,RSI50上,EMA上価格 ロング エクシット: 価格がスーパートレンド,ストップ・ロスト,またはプロフィート以下に閉じる.

ショートエントリー: スーパートレンドを下回る価格,50を下回るRSI,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をシンプルで実践的なトレンドフォローシステムに統合している.トレンド方向を明確に識別し,偽信号をフィルタリングし,全体的なトレンドを確認する. 明確なエントリー,出口ルール,ストップ損失/利益の設定. 簡単に使用し,信頼性の高い収益性. どの時間枠にも適用できる. パラメータを調整し,逆転ツールを追加し,ストップを強化することでさらに最適化され,より強力な取引システムになる.


/*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')

//

もっと