ATR ストップ・ロスト イチモク・キジュン 脱出戦略

作者: リン・ハーンチャオチャン, 日付: 2023-09-14 20:06:11
タグ:

この記事では,ストップ・ロスのためにATRとエントリーのためにKijun-Senブレイクを使用する定量的な取引戦略を詳細に説明し,取引リスクを制御するためにWilliams %R指標を使用して追加の信号検証を行います.

I. 戦略の論理

この戦略の主な指標は以下の通りである.

  1. ATRはストップ・ロスの指標として動的に市場変動を反映しています

  2. イチモク・キジュン・セン線で 傾向の方向を決定し 入力信号を出す

  3. 誤った入力を避けるため 追加の信号の検証のためにWilliams %R

具体的な貿易論理は

価格がキジュン-セン線を下に突破して,その上に戻るとロングポジションを取ります.価格が線上を突破して,その下に戻るとショートポジションを取ります.これはトレンドをフォローすることができます.

同時に,Williams %R が方向に同意しているかどうかを確認します.そうでない場合は,入力をスキップします.これは偽信号をフィルターします.

ストップ・ロスは各エントリで計算されたレベルに設定する.ATRは市場の変動を動的に反映し,合理的なストップ・ロスのサイズを可能にします.

ストップ・ロストやテイク・プロフィートが起動すると ポジションを利益のために閉じます

戦略の利点

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

まず,ATRストップロスは,市場の変動に応じてリスク制御を設定し,大きな損失を効果的に回避します.

2つ目は,Williams %R 検証のキジュン-センエントリが信号の質を向上させる

最後に,ストップ・ロストとテイク・プロフィートの設定は,各取引のリスク・リターンを定義します.

III.潜在的な弱点

しかし,次のリスクも考慮されるべきです.

まず,Kijun-Senの信号は,トレンド移行時に遅れて,間に合わずに反応する可能性があります.

2つ目に ストップ・ロスは過度に強硬に設定されれば 早期に停止される危険があります

最後に,不適切なパラメータ最適化も 過適性問題につながる可能性があります.

IV.要約

この記事では,ストップ・ロスのためのATRとエントリー・シグナルのためのKijun-Senを使用した定量的な取引戦略を説明しています.動的ストップとシグナルフィルタリングを通じて効果的なリスク制御を達成できます.しかし,トレンド移行やストップ・ロスの無効化などのリスクは予防する必要があります.全体として,シンプルで効果的なトレンドフォロー方法を提供します.


/*backtest
start: 2023-09-06 00:00:00
end: 2023-09-13 00:00:00
period: 15m
basePeriod: 5m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
// strategy("NNFX ft. ATR, Kijun-Sen, %R","NNFX-2",true,pyramiding=1,calc_on_order_fills=true,calc_on_every_tick=true,initial_capital = 1000, currency="USD",slippage=5,commission_type=strategy.commission.cash_per_contract,commission_value=0.000035)
strategy.initial_capital = 50000    
//INDICATOR---------------------------------------------------------------------    
    //Average True Range (1. RISK)
atr_period = input(14, "Average True Range Period")
atr = atr(atr_period)

    //Ichimoku Cloud - Kijun Sen (2. BASELINE)
ks_period = input(20, "Kijun Sen Period")
kijun_sen = (highest(high,ks_period) + lowest(low,ks_period))/2
base_long = open < kijun_sen and close > kijun_sen
base_short = open > kijun_sen and close < kijun_sen

    //Williams Percent Range (3. Confirmation#1)
use_wpr = input(true,"Use W%R?")
wpr_len = input(1, "Williams % Range Period")
wpr = -100*(highest(high,wpr_len) - close)/(highest(high,wpr_len) - lowest(low,wpr_len))
wpr_up = input(-25, "%R Upper Level")
wpr_low = input(-75, "%R Lower Level")
conf1_long = wpr >= wpr_up
conf1_short = wpr <= wpr_low
if(use_wpr == false)
    conf1_long := true
    conf1_short := true
//TRADE LOGIC-------------------------------------------------------------------
    //Long Entry
    //if -> WPR crosses below -39 AND MACD line is less than signal line
l_en = base_long and conf1_long
    //Long Exit
    //if -> WPR crosses above -14
l_ex = close < kijun_sen
    //Short Entry
    //if -> WPR crosses above -39 AND MACD line is greater than signal line
s_en = base_short and conf1_short
    //Short Exit
    //if -> WPR crosses under -14
s_ex = close > kijun_sen
    
//MONEY MANAGEMENT--------------------------------------------------------------
balance = strategy.netprofit + strategy.initial_capital //current balance
floating = strategy.openprofit          //floating profit/loss
isTwoDigit = input(false,"Is this a 2 digit pair? (JPY, XAU, XPD...")
risk = input(5,"Risk %")/100           //risk % per trade
equity_protector = input(30,"Equity Protection %")/100  //equity protection %
stop = atr*100000*input(1.5,"Average True Range multiplier")    //Stop level
if(isTwoDigit)
    stop := stop/100
target = input(150, "Target TP in Points")  //TP level
    //Calculate current DD and determine if stopout is necessary
equity_stopout = false
if(floating<0 and abs(floating/balance)>equity_protector)
    equity_stopout := true
    
    //Calculate the size of the next trade
temp01 = balance * risk     //Risk in USD
temp02 = temp01/stop        //Risk in lots
temp03 = temp02*100000      //Convert to contracts
size = temp03 - temp03%1000 //Normalize to 1000s (Trade size)
if(size < 1000)
    size := 1000            //Set min. lot size

//TRADE EXECUTION---------------------------------------------------------------
strategy.close_all(equity_stopout)      //Close all trades w/equity protector
is_open = strategy.opentrades > 0

if(true)
    strategy.entry("l_en",true,oca_name="a",when=l_en and not is_open)  //Long entry
    strategy.entry("s_en",false,oca_name="a",when=s_en and not is_open) //Short entry
    
    strategy.exit("S/L","l_en",loss=stop, profit=target)      //Long exit (stop loss)
    strategy.close("l_en",when=l_ex)            //Long exit (exit condition)
    strategy.exit("S/L","s_en",loss=stop, profit=target)      //Short exit (stop loss)
    strategy.close("s_en",when=s_ex)            //Short exit (exit condition)
    
//PLOTTING----------------------------------------------------------------------
plot(kijun_sen,"Kijun-Sen",color.blue,2)

もっと