볼링거 밴드 트렌드 체이저

저자:차오장, 날짜: 2023-11-22 16:51:27
태그:

img

전반적인 설명

이 전략의 아이디어는 트렌딩 주식 (또는 다른 트렌딩 시장) 에 대한 낮은 위험 전략으로 최소한의 마이너드 다운을 달성하는 것을 목표로합니다 (예를 들어, 작성 시 AAPL는 ~1.36% 마이너드 다운, FB는 ~1.93% 마이너드 다운, SPY는 0.80% 마이너드 다운이며 모두 수익성 유지).

원칙

이 전략은 200일 이동평균, 맞춤 볼링거 밴드, 52시기의 가중화 이동평균과 ADX 강도를 이용합니다.

구매 신호는 200 이동 평균 이상 거래 + 5 개의 촛불이 상위 사용자 정의 볼링거 이상 닫혔을 때 + TSI가 긍정적 인 + ADX가 20 이상인 경우 제공됩니다.

장점

이 전략의 장점은 낮은 마감과 최소한의 위험입니다. 그것은 낮은 위험 운영과 대부분의 트렌딩 주식에 적합합니다. 테스트 데이터에 따르면 수익률은 높으며 AAPL은 테스트 기간 동안 최대 마감률 1.36%, FB는 최대 마감률 1.93%를 기록했습니다.

볼링거 밴드, MA 라인, TSI 지표와 같은 여러 기술적 지표를 결합하고 ADX를 사용하여 트렌드의 강도를 결정함으로써, 트렌드가 상승할 때 구매하여 트렌딩 주식의 중장기 상승 잠재력을 파악하려고합니다. 단일 지표로 판단하는 것과 비교하면이 전략은 더 정확하고 신뢰할 수있는 판단과 낮은 위험을 위해 여러 기술적 지표를 사용합니다.

또한 스톱 로스 전략은 TSI 지표가 방향을 변경할 때 적시에 손실을 중지하여 수익을 차단하여 위험을 효과적으로 제어합니다.

위험 분석

이 전략에 직면한 주요 위험은 두 가지입니다.

  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)


더 많은