ボリンジャー・バンド・トレンド・チェイサー

作者: リン・ハーンチャオチャン,日付: 2023-11-22 16:51:27
タグ:

img

概要

この戦略は,トレンド株 (または他のトレンド市場) の低リスク戦略であり,最小限の引き上げを達成することを目指す (例えば,この記事を書いている時点では,AAPLは約1.36%の引き上げ,FBは約1.93%の引き上げ,SPYは0.80%の引き上げであり,すべては収益性を維持している).

原則

この戦略は200日間の移動平均値,カスタムボリンジャーバンド,52期間の重度の移動平均値とADX強度を持つ TSIを使用しています.

買い信号は,移動平均値200以上の取引時に与えられます. + 5個のキャンドルが上方カスタムボリンガー値以上で閉じた + TSIは正値 + ADXは20以上です.

利点

この戦略の利点は,低引き上げと最小リスクです.低リスク運用のほとんどのトレンドストックに適しています.テストデータによると,リターンは高く,AAPLはテスト期間中に最大引き上げが1.36%,FBは最大引き上げが1.93%でした.

ボリンジャー帯,MA線,TSI指標などの複数の技術指標を組み合わせ,トレンドの強さを決定するためにADXを使用することで,トレンドが上昇するときに購入し,トレンド株の中長期上向きの可能性を把握しようとします.この戦略は,単一の指標で判断すると比較して,より正確で信頼性の高い判断と低いリスクのために複数の技術指標を使用します.

また,STI指標が方向を変えるときに損失を間に合うように止め,リスクを効果的に制御することで利益を固定するストップ損失戦略も含まれます.

リスク分析

この戦略が直面する主なリスクは2つあります

  1. ブラック・スワン・イベントリスク ブラック・スワン・イベントは 株価が急落し 損失を止められない可能性があります

  2. トレンド終了リスクです 株がトレンドから整合に移ると 引き下げが大きくなります

リスク1では,より厳格なストップ・ロスのメカニズムを設定したり,手動介入ストップを使用したりできます.リスク2では,取引量指標の増加など,傾向の終わりを検出するために,より多くの判断因子を組み合わせることができます.

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

戦略は,次の側面でも最適化できます.

  1. ストップ・ロスの戦略を追加して,より正確なストップ・ロスのポイントを設定してリスクを制御する.

  2. 移動平均のパラメータを最適化して,異なるパラメータの組み合わせの安定性をテストする.

  3. トレンドの始まりと終わりを より正確に判断するために 勢い指標を増やします

  4. 長期間の操作に適した長時間サイクルパラメータをテストする.

結論

この戦略は,トレンド強度を決定するためにADX,トレンド方向を決定するために TSI指標,ブレークアウトを決定するためにボリンジャー帯,長期トレンドを決定するために移動平均を使用して購入機会を決定する.複数の指標の検証はリスクを効果的に制御することができます.この戦略は,低引き下げと高いリターンを持つトレンド株の長期追跡に適しています.しかし,戦略をより堅牢にするためにリスクのために最適化する必要があります.


/*backtest
start: 2023-01-01 00:00:00
end: 2023-11-21 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/
// © gary_trades
//This script has been designed to be used on trending stocks as a low risk trade with minimal drawdown, utilising 200 Moving Average, Custom Bollinger Band, TSI with weighted moving average and ADX strength. 
//Backtest dates are set to 2010 - 2020 and all other filters (moving average, ADX, TSI , Bollinger Band) are not locked so they can be user amended if desired. 
//Buy signal is given when trading above the 200 moving average + 5 candles have closed above the upper custom Bollinger + the TSI is positive + ADX is above 20.
//As back testing proved that this traded better only in tends then some Sell/Short conditions have been removed and this focueses on  Long orders.
//Only requires 2 additional lines of code to add shorting orders.
//Close for either long or short trades is signaled once the TSI crosses in the opposite direction indicating change in trend strength or if stop loss is trggered.
//Further optimization could be achieved by adding a stop loss.
//NOTE: This only shows the lower indicators however for visualization you can use my script "CUSTOM BOLLINGER WITH SMA", which is the upper indicators in this stratergy.
//------------
//@version=4
strategy(shorttitle="Trend Chaser", title="ADX_TSI_Bol Band Trend Chaser", overlay=false, pyramiding=0,
 currency=currency.USD, default_qty_type=strategy.percent_of_equity, default_qty_value=10,
 initial_capital=10000, commission_value=0.1)
//------------
//Custom Bollinger Band
length = input(20, minval=1)
src = input(close, title="Source")
mult = input(0.382, minval=0.001, maxval=50, title="StdDev")
basis = sma(src, length)
dev = mult * stdev(src, length)
upper = basis + dev
lower = basis - dev
offset = input(0, "Offset", type = input.integer, minval = -500, maxval = 500)
plot(basis, "Basis", color=color.gray, offset = offset, display=display.none)
p1 = plot(upper, "Upper", color=color.gray, offset = offset, display=display.none)
p2 = plot(lower, "Lower", color=color.gray, offset = offset, display=display.none)
fill(p1, p2, title = "Background", color=#787B86, transp=85)
//------------
//Moving Average
MAlen = input(200, minval=1, title="Length")
MAout = sma(src, MAlen)
plot(MAout, color=color.black, title="MA", offset=offset, linewidth=2, display=display.none)
//------------
//True Strength WMA
TSlong = input(title="Long Length", type=input.integer, defval=25)
TSshort = input(title="Short Length", type=input.integer, defval=13)
TSsignal = input(title="Signal Length", type=input.integer, defval=52)
double_smooth(src, TSlong, TSshort) =>
    fist_smooth = wma(src, TSlong)
    wma(fist_smooth, TSshort)
price = close     
pc = change(price)
double_smoothed_pc = double_smooth(pc, TSlong, TSshort)
double_smoothed_abs_pc = double_smooth(abs(pc), TSlong, TSshort)
tsi_value = 100 * (double_smoothed_pc / double_smoothed_abs_pc)
tsi2 = wma(tsi_value, TSsignal)
plot(tsi_value, color=color.blue)
plot(wma(tsi_value, TSsignal), color=color.red)
hline(0, title="Zero")
//------------
//ADX
adxlen = input(13, title="ADX Smoothing")
dilen = input(13, title="DI Length")
keyLevel = input(20, title="Keylevel for ADX")
dirmov(len) =>
	up = change(high)
	down = -change(low)
	plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
    minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
	truerange = rma(tr, len)
	plus = fixnan(100 * rma(plusDM, len) / truerange)
	minus = fixnan(100 * rma(minusDM, len) / truerange)
	[plus, minus]

adx(dilen, adxlen) =>
	[plus, minus] = dirmov(dilen)
	sum = plus + minus
	adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)

sig = adx(dilen, adxlen)

plot(sig, color=color.black, title="ADX", style=plot.style_histogram, transp=40)
plot(20, color=color.green, title="ADX Keyline", linewidth=1)
//------------
//Identify Triggers

//Back Test Range
start = timestamp("America/New_York", 2010, 1, 1, 9,30)
end = timestamp("America/New_York", 2030, 7, 1, 0, 0)

//Custom Bollinger Band
Long1 = close > upper[5] and close[5] > upper [6]
Short1 = close < lower[5] and close[5] < lower [6]

//Moving Average
Long2 = close >= MAout[1]
Short2 = close <= MAout[1]

//True Strength WMA
Long3 = tsi_value > tsi2  
Short3 = tsi_value < tsi2

//ADX
ADXkey = adx(dilen, adxlen) > 20 and adx(dilen, adxlen) < 100

//Buy
Buy = Long1 and Long2 and Long3 and ADXkey
CloseLong = crossunder(tsi_value,tsi2)

//Short
Sell = Short1 and Short2 and Short3 and ADXkey
CloseShort = crossover(tsi_value,tsi2)
//------------
//Entry and Exit
if time >= start and time <= end
    strategy.entry("Long", true, when = Buy)

strategy.close("Long", when = CloseLong)


もっと