모멘텀 지표 돌파 거래 전략


생성 날짜: 2023-09-18 21:28:22 마지막으로 수정됨: 2023-09-18 21:28:22
복사: 0 클릭수: 691
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

개요

이 전략은 동력 지표인 부린 반을 이용하여 부린 반을 깨는 거래를 하고, 가격의 부린 반을 깨고 하향 경로에 올라가는지를 판단하여 구매/판매 신호를 발산한다.

원칙

이 전략은 주로 브린 밴드 지표에 기반하여 트렌드 방향을 판단한다. 브린 밴드는 이동 평균과 그 표준 차이를 구성하는 밴드 모양의 영역이다. 브린 밴드 중간선은 n 일 이동 평균이며, 상반선은 중간선 + 2 배 표준 차이를 나타내고, 하반선은 중간선 -2 배 표준 차이를 나타낸다. 가격이 상반선에 가까워지면 과매가 되고, 하반선에 가까워지면 과매가 된다.

구체적으로, 전략은 먼저 n 일 동안의 최고 가격, 최저 가격을 계산하고 중간 가격을 계산합니다 (((최고 가격 + 최저 가격) / 2). 그리고는 종점 가격과 중간 가격의 거리가 중화 된 이동 평균을 계산하여 브린 밴드 중간선을 구성합니다. 중간선은 각 2배의 표준 차이를 추가하여 위아래 경로를 구성합니다.

종전 가격이 상도를 돌파하면 상승세를 보이고, 하도를 돌파하면 하향세를 나타낸다. 상도를 돌파할 때 더 많이 하고, 하도를 돌파할 때 공백을 한다.

또한, 전략은 반전 상장 메커니즘을 도입했다. 가격이 부린을 뚫고 궤도에 올랐을 때, MACD가 하락하면 역시장 연산이 이루어진다.

장점

  1. 브린 띠를 사용하여 트렌드 방향을 판단하고, 트렌드 추적 능력을 갖는다.

  2. 상반대 포지션 설계는 상반대 이윤을 얻을 수 있다.

  3. 브린 밴드 주기, 표준 차의 배수 등의 파라미터를 사용자 정의할 수 있으며, 서로 다른 주기에서의 거래에 적합하다.

  4. 리스크를 줄이기 위해 포지션을 닫을 수 있습니다.

위험과 대책

  1. 브린 띠는 종종 높은 변동성 주식에서 사용되며, 긴 주기 리소스 또는 지수와 같은 품종에는 적합하지 않을 수 있다. 다양한 주기 변수의 효과를 테스트 할 수 있다.

  2. 돌파 신호는 가짜 돌파가 발생할 수 있다. 다른 요소와 결합하여 필터링 신호가 가능하다.

  3. 역대시장은 손실을 더욱 확대할 수 있다. 역대시장 모듈을 폐쇄할 수 있다.

  4. 철회 가능성이 크다. 위치 규모를 적절히 조정할 수 있다.

최적화 방향

  1. 트렌드 필터링을 추가하여 불확실한 방향의 흔들림 시장을 피하는 것을 고려할 수 있습니다.

  2. 브린띠 표준차이배수를 테스트하여 더 적합한 변수를 찾아볼 수 있다.

  3. 단편적 손실을 통제하기 위해 Stop Loss 전략을 도입할 수 있다.

  4. 포지션 개시 및 추가 논리를 최적화하여 거래 신호를 더 명확하게 할 수 있습니다.

요약하다

이 전략은 브린을 기본 지표로 하여 가격 트렌드 돌파구를 판단하여 거래한다. 간단한 매개 변수 설정을 사용하여 기본 트렌드 추적 전략을 구현할 수 있다. 그러나 특정 가짜 돌파구 위험이 존재하고 다른 지표와 함께 필터링이 필요합니다. 매개 변수 설정을 추가적으로 최적화하고, 손실 전략을 제어 할 수 있다.

Overview

This strategy uses Bollinger Bands momentum indicator for breakout trading, mainly judging if price breaks through the upper or lower Bollinger Bands for trading signals.

Principles

The strategy is primarily based on Bollinger Bands indicator to determine trend direction. Bollinger Bands consist of a middle band based on a moving average and upper/lower bands defined by standard deviations. The middle band is a n-period moving average, the upper band is middle band + 2 standard deviations, and the lower band is middle band - 2 standard deviations. When price approaches the upper band it indicates overbought conditions, and when it approaches the lower band it signals oversold conditions.

Specifically, the strategy first calculates the highest high and lowest low over last n periods, and the middle price ((highest high + lowest low)/2). It then calculates the distance between close price and middle price, uses exponential moving average of the distance to form the middle band, and adds/subtracts 2 times standard deviation above and below to form the upper and lower bands.

When close price breaks through the upper band, it signals an uptrend; when it breaks the lower band, it signals a downtrend. The strategy goes long when the upper band is broken, and goes short when the lower band is broken.

In addition, the strategy incorporates a counter-trend mechanism. When price breaks the upper band but MACD is falling, it will take a counter-trend short position.

Advantages

  1. Using Bollinger Bands to determine trend direction provides certain trend following capability.

  2. Counter-trend design allows profiting from reversals.

  3. Customizable parameters like period and standard deviation multiples make it adaptable to different trading horizons.

  4. Disable counter-trend trading to reduce risk.

Risks and Mitigations

  1. Bollinger Bands work best for high volatility stocks, may not be suitable for stable commodities or indices. Can test different period parameters.

  2. Breakout signals may have false breakouts. Can add filters with other indicators.

  3. Counter-trend trading can further increase losses. Can disable counter-trend module.

  4. Drawdowns may be significant. Can adjust position sizing.

Enhancement Opportunities

  1. Consider adding trend filter to avoid whipsaw in non-directional markets.

  2. Test different standard deviation multiples to find optimal parameters.

  3. Incorporate stop loss to control single trade loss.

  4. Optimize entry and add-on logic for clearer trading signals.

Summary

The strategy uses Bollinger Bands as the primary indicator and trades based on trend breakouts. With simple parameters it provides basic trend following capabilities. But false breakout risks exist, requiring additional filters. Parameters, stop loss and risk controls can be enhanced. Overall it serves as a reasonable baseline breakout strategy.

전략 소스 코드
/*backtest
start: 2023-08-18 00:00:00
end: 2023-09-17 00:00:00
period: 4h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//Noro
//2018

//@version=2
strategy("Noro's Bands Scalper Strategy v1.6", shorttitle = "Scalper str 1.6", overlay = true, default_qty_type = strategy.percent_of_equity, default_qty_value = 100.0, pyramiding = 0)

//Settings
needlong = input(true, defval = true, title = "Long")
needshort = input(true, defval = true, title = "Short")
takepercent = input(0, defval = 0, minval = 0, maxval = 1000, title = "take, %")
needbe = input(true, defval = true, title = "Bands Entry")
needct = input(false, defval = false, title = "Counter-trend entry")
bodylen = input(10, defval = 10, minval = 0, maxval = 50, title = "Body length")
trb = input(1, defval = 1, minval = 1, maxval = 5, title = "Trend bars")
len = input(20, defval = 20, minval = 2, maxval = 200, title = "Period")
needbb = input(true, defval = true, title = "Show Bands")
needbg = input(true, defval = true, title = "Show Background")
fromyear = input(1900, defval = 1900, minval = 1900, maxval = 2100, title = "From Year")
toyear = input(2100, defval = 2100, minval = 1900, maxval = 2100, title = "To Year")
frommonth = input(01, defval = 01, minval = 01, maxval = 12, title = "From Month")
tomonth = input(12, defval = 12, minval = 01, maxval = 12, title = "To Month")
src = close

//PriceChannel 1
lasthigh = highest(src, len)
lastlow = lowest(src, len)
center = (lasthigh + lastlow) / 2

//Distance
dist = abs(src - center)
distsma = sma(dist, len)
hd = center + distsma
ld = center - distsma
hd2 = center + distsma * 2
ld2 = center - distsma * 2

//Trend
chd = close > hd
cld = close < ld
uptrend = trb == 1 and chd ? 1 : trb == 2 and chd and chd[1] ? 1 : trb == 3 and chd and chd[1] and chd[2] ? 1 : trb == 4 and chd and chd[1] and chd[2] and chd[3] ? 1 : trb == 5 and chd and chd[1] and chd[2] and chd[3] and chd[4] ? 1 : 0
dntrend = trb == 1 and cld ? 1 : trb == 2 and cld and cld[1] ? 1 : trb == 3 and cld and cld[1] and cld[2] ? 1 : trb == 4 and cld and cld[1] and cld[2] and cld[3] ? 1 : trb == 5 and cld and cld[1] and cld[2] and cld[3] and cld[4] ? 1 : 0
trend = dntrend == 1 and high < center ? -1 : uptrend == 1 and low > center ? 1 : trend[1]

//trend = close < ld and high < center ? -1 : close > hd and low > center ? 1 : trend[1]

//Lines
colo = needbb == false ? na : black
plot(hd2, color = colo, linewidth = 1, transp = 0, title = "High band 2")
plot(hd, color = colo, linewidth = 1, transp = 0, title = "High band 1")
plot(center, color = colo, linewidth = 1, transp = 0, title = "center")
plot(ld, color = colo, linewidth = 1, transp = 0, title = "Low band 1")
plot(ld2, color = colo, linewidth = 1, transp = 0, title = "Low band 2")

//Background
col = needbg == false ? na : trend == 1 ? lime : red
bgcolor(col, transp = 80)

//Body
body = abs(close - open)
smabody = ema(body, 30) / 10 * bodylen

//Signals
bar = close > open ? 1 : close < open ? -1 : 0
up7 = trend == 1 and ((bar == -1 and bar[1] == -1) or (body > smabody and bar == -1)) ? 1 : 0
dn7 = trend == 1 and ((bar == 1 and bar[1] == 1) or (close > hd and needbe == true)) and close > strategy.position_avg_price * (100 + takepercent) / 100 ? 1 : 0
up8 = trend == -1 and ((bar == -1 and bar[1] == -1) or (close < ld2 and needbe == true)) and close < strategy.position_avg_price * (100 - takepercent) / 100 ? 1 : 0
dn8 = trend == -1 and ((bar == 1 and bar[1] == 1) or (body > smabody and bar == 1)) ? 1 : 0

if up7 == 1 or up8 == 1 
    strategy.entry("Long", strategy.long, needlong == false ? 0 : trend == -1 and needct == false ? 0 : na, when=(time > timestamp(fromyear, frommonth, 01, 00, 00) and time < timestamp(toyear, tomonth, 31, 00, 00)))

if dn7 == 1 or dn8 == 1
    strategy.entry("Short", strategy.short, needshort == false ? 0 : trend == 1 and needct == false ? 0 : na, when=(time > timestamp(fromyear, frommonth, 01, 00, 00) and time < timestamp(toyear, tomonth, 31, 00, 00)))
    
if time > timestamp(toyear, tomonth, 31, 00, 00)
    strategy.close_all()