이동평균을 이용한 사이클 판단에 기초한 모멘텀 브레이크 전략

저자:차오장, 2024-01-23 14:51:27
태그:

img

전반적인 설명

이 전략은 다른 기간의 EMA 라인을 계산하여 시장의 현재 사이클 단계를 결정하고, ATR을 사용하여 높은 확률의 트렌드를 따르는 거래에 대한 모멘텀 브레이크업 신호를 생성합니다.

전략 논리

  1. 5일, 20일 및 40일 EMA 라인 3개를 계산합니다.
  2. 시장이 현재 6개의 주기의 단계 중 어느 단계에 있는지 결정하기 위해 EMA 라인을 비교하십시오.
    • 5일 > 20일 > 40일 1주기
    • 20일 > 5일 > 40일 2주기 ...
  3. 사이클 결정 후, ATR 지표를 계산하고, ATR 곱셈을 분산 기준으로 설정합니다.
  4. 구매 신호는 가격이 이전 바의 ATR 트레일링 스톱보다 높을 때 생성됩니다.
  5. 판매 신호는 가격이 이전 바의 ATR 트레일링 스톱 아래로 떨어지면 생성됩니다.
  6. 이러한 판단 조합을 통해 높은 확률의 트렌드를 따르는 거래를 달성 할 수 있습니다.

장점

  1. 사이클 판단은 신호 신뢰성을 높인다

    서로 다른 EMA 라인의 상대적 위치를 판단함으로써, 부적절한 사이클에서 잘못된 신호를 피하는 시장의 현재 사이클 단계를 효과적으로 결정할 수 있습니다.

  2. ATR 파업 필터 거짓 신호

    ATR는 시장의 변동성을 효과적으로 표현할 수 있습니다. 브레이크아웃 기준으로 ATR 곱셈을 설정하면 많은 잘못된 브레이크아웃 신호를 필터링할 수 있습니다.

  3. 결합된 판단은 높은 확률의 거래 기회를 형성합니다.

    순환 판단과 ATR 브레이크의 유기적인 조합은 훨씬 더 높은 확률을 가진 신호를 생성하고, 따라서 거래의 수익성도 증가시킵니다.

위험성

  1. 어려운 매개 변수 최적화

    여러 매개 변수와 함께 최적화 어려움이 높습니다. 잘못된 매개 변수 설정은 전략 성능에 영향을 줄 수 있습니다.

  2. 낙후가 존재합니다.

    급변하는 시장에서 EMA와 ATR 모두 어느 정도 뒤쳐져 있어 잘못된 신호를 발산하거나 기회를 놓칠 수 있습니다.

  3. 엄격한 스톱 손실 필요

    어떤 기술 지표도 잘못된 신호를 완전히 피할 수 없습니다. 위험 통제를 위해 엄격한 스톱 손실이 필요합니다.

최적화 방향

  1. 추가 매개 변수 최적화

    더 광범위한 역사적 데이터를 통해 최적의 매개 변수 조합을 찾아보세요.

  2. 적응력을 높여

    적응력을 향상시키기 위해 시장 변동성에 따라 ATR 매개 변수를 자동으로 조정하는 것을 고려하십시오.

  3. 다른 지표를 포함

    변동성과 부피와 같은 다른 지표를 포함시키면 판단을 돕고 신호 품질을 향상시킬 수 있습니다.

결론

이 전략은 EMA와 함께 주기를 결정하고 ATR와 함께 추진력 브레이크아웃 기준을 설정하여 높은 확률의 트렌드를 따르는 거래를 달성합니다. 사이클 판단, 잘못된 신호 필터링 및 신호 품질 개선과 같은 장점이 있습니다. 그러나 어려운 매개 변수 최적화 및 지연과 같은 위험이 있습니다. 매개 변수, 적응성 등에 대한 추가 최적화는 전략을 향상시킬 수 있습니다.


/*backtest
start: 2024-01-15 00:00:00
end: 2024-01-22 00:00:00
period: 15m
basePeriod: 5m
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/
// © kgynofomo

//@version=5
strategy(title="[Salavi] | Andy Advance Pro Strategy",overlay = true)

ema_short = ta.ema(close,5)
ema_middle = ta.ema(close,20)
ema_long = ta.ema(close,40)

cycle_1 = ema_short>ema_middle and ema_middle>ema_long
cycle_2 = ema_middle>ema_short and ema_short>ema_long
cycle_3 = ema_middle>ema_long and ema_long>ema_short
cycle_4 = ema_long>ema_middle and ema_middle>ema_short
cycle_5 = ema_long>ema_short and ema_short>ema_middle
cycle_6 = ema_short>ema_long and ema_long>ema_middle

bull_cycle = cycle_1 or cycle_2 or cycle_3
bear_cycle = cycle_4 or cycle_5 or cycle_6
// label.new("cycle_1")
// bgcolor(color=cycle_1?color.rgb(82, 255, 148, 60):na)
// bgcolor(color=cycle_2?color.rgb(82, 255, 148, 70):na)
// bgcolor(color=cycle_3?color.rgb(82, 255, 148, 80):na)
// bgcolor(color=cycle_4?color.rgb(255, 82, 82, 80):na)
// bgcolor(color=cycle_5?color.rgb(255, 82, 82, 70):na)
// bgcolor(color=cycle_6?color.rgb(255, 82, 82, 60):na)

// Inputs
a = input(2, title='Key Vaule. \'This changes the sensitivity\'')
c = input(7, title='ATR Period')
h = false

xATR = ta.atr(c)
nLoss = a * xATR

src = h ? request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close, lookahead=barmerge.lookahead_off) : close

xATRTrailingStop = 0.0
iff_1 = src > nz(xATRTrailingStop[1], 0) ? src - nLoss : src + nLoss
iff_2 = src < nz(xATRTrailingStop[1], 0) and src[1] < nz(xATRTrailingStop[1], 0) ? math.min(nz(xATRTrailingStop[1]), src + nLoss) : iff_1
xATRTrailingStop := src > nz(xATRTrailingStop[1], 0) and src[1] > nz(xATRTrailingStop[1], 0) ? math.max(nz(xATRTrailingStop[1]), src - nLoss) : iff_2

pos = 0
iff_3 = src[1] > nz(xATRTrailingStop[1], 0) and src < nz(xATRTrailingStop[1], 0) ? -1 : nz(pos[1], 0)
pos := src[1] < nz(xATRTrailingStop[1], 0) and src > nz(xATRTrailingStop[1], 0) ? 1 : iff_3

xcolor = pos == -1 ? color.red : pos == 1 ? color.green : color.blue

ema = ta.ema(src, 1)
above = ta.crossover(ema, xATRTrailingStop)
below = ta.crossover(xATRTrailingStop, ema)

buy = src > xATRTrailingStop and above
sell = src < xATRTrailingStop and below

barbuy = src > xATRTrailingStop
barsell = src < xATRTrailingStop




atr = ta.atr(14)
atr_length = input.int(25)
atr_rsi = ta.rsi(atr,atr_length)
atr_valid = atr_rsi>50

long_condition =  buy and bull_cycle and atr_valid
short_condition =  sell and bear_cycle and atr_valid

Exit_long_condition = short_condition
Exit_short_condition = long_condition

if long_condition
    strategy.entry("Andy Buy",strategy.long, limit=close,comment="Andy Buy Here")

if Exit_long_condition
    strategy.close("Andy Buy",comment="Andy Buy Out")
    // strategy.entry("Andy fandan Short",strategy.short, limit=close,comment="Andy 翻單 short Here")
    // strategy.close("Andy fandan Buy",comment="Andy short Out")


if short_condition
    strategy.entry("Andy Short",strategy.short, limit=close,comment="Andy short Here")


// strategy.exit("STR","Long",stop=longstoploss)
if Exit_short_condition
    strategy.close("Andy Short",comment="Andy short Out")
    // strategy.entry("Andy fandan Buy",strategy.long, limit=close,comment="Andy 翻單 Buy Here")
    // strategy.close("Andy fandan Short",comment="Andy Buy Out")




inLongTrade = strategy.position_size > 0
inLongTradecolor = #58D68D
notInTrade = strategy.position_size == 0
inShortTrade = strategy.position_size < 0

// bgcolor(color = inLongTrade?color.rgb(76, 175, 79, 70):inShortTrade?color.rgb(255, 82, 82, 70):na)
plotshape(close!=0,location = location.bottom,color = inLongTrade?color.rgb(76, 175, 79, 70):inShortTrade?color.rgb(255, 82, 82, 70):na)


plotshape(long_condition, title='Buy', text='Andy Buy', style=shape.labelup, location=location.belowbar, color=color.new(color.green, 0), textcolor=color.new(color.white, 0), size=size.tiny)
plotshape(short_condition, title='Sell', text='Andy Sell', style=shape.labeldown, location=location.abovebar, color=color.new(color.red, 0), textcolor=color.new(color.white, 0), size=size.tiny)


//atr > close *0.01* parameter

더 많은