동적 모멘텀 오시레이터 거래 전략

저자:차오장, 날짜: 2023-12-15 11:00:25
태그:

img

전반적인 설명

동적 모멘텀 오시레이터 (DMO) 거래 전략은 모멘텀 오시레이터 지표를 기반으로 한 15 분 단기 거래 전략이다. 이 전략은 매우 정확한 거래 신호를 생성하기 위해 여러 기술적 지표를 결합하여 초보자 거래자가 짧은 시간 내에 구매 및 판매 결정을 내리고 위험을 제어하고 수익성을 높이는 데 효과적으로 도움을 줄 수 있습니다.

전략 논리

이 전략은 먼저 시장의 주요 트렌드 방향을 결정하기 위해 도인치안 채널을 사용합니다. 채널의 상단단위 이상의 브레이크오웃은 상승 신호이며, 하단단위 이하의 브레이크오웃은 하향 신호입니다. 둘째, 전략은 더 정확한 트렌드 판단을 위해 적응형 ATR 채널과 결합하여 세 가지 헐 이동 평균 변수 중 하나를 채택합니다. 빠른 라인이 중간 라인의 위를 넘을 때 그것은 구매 신호이며, 아래를 넘을 때 그것은 판매 신호입니다. 마지막으로, 잘못된 신호의 추가 필터링을위한 하프트렌드 지표의 도움으로 거래 신호의 신뢰성을 더욱 향상시킬 수 있습니다. 상대적으로 신뢰할 수있는 거래 신호를 수신하면 전략은 해당 장기 또는 짧은 위치에 들어갈 것입니다.

이점 분석

DMO 전략의 가장 큰 장점은 여러 지표의 유기적인 조합에 있다. 다른 지표들은 서로 확인하여 잘못된 신호를 필터링하여 각 거래 신호를 더 정확하고 신뢰할 수 있다. 또한, 도인치안 채널의 주요 트렌드를 판단하는 방법은 간단하고 직설적이며, 하프트렌드 라인을 통해 신호를 필터링하는 수단도 비교적 일반적이다. 전반적으로 초보자들에게는 낮은 학습 곡선으로 이해하기 쉽다. 단일 지표와 비교하면 DMO는 같은 수의 거래를 고려하여 더 높은 승률과 수익성을 달성할 수 있다.

위험 분석

DMO 전략은 비교적 안정적이고 신뢰할 수 있지만, 어떤 양적 거래 전략도 특정 위험을 초래할 수밖에 없다. 특히, 빠른 선이 중간 선 아래를 넘을 때, 다른 지표로부터 검증을 받지 않고 여전히 잘못된 신호일 수 있다. 또한, 모든 단기 전략과 마찬가지로, DMO는 또한 과거래와 관련된 위험에 직면한다. 지표가 비효율적으로 작용하는 갑작스러운 시장 사건이 발생하면, 부적절한 스톱 로스 설정도 더 큰 손실로 이어질 수 있다. 위험을 완화하기 위해, 중장기 지표의 매개 변수를 적절히 조정하고, 검증을 위해 더 높은 시간 프레임 지표와 결합하고, 단일 거래 손실을 엄격하게 제어하기 위해 스톱 로스 거리를 늘리는 것이 좋습니다.

최적화 방향

DMO 전략은 다음과 같은 측면에서 최적화 될 수 있습니다: 첫째, 이동 평균의 평형 효과와 민감성을 균형을 맞추기 위해 Hull MA의 매개 변수를 조정하십시오. 둘째, 채널 매개 변수를 조정하거나 추가 제한을 추가하는 것과 같은 도인치안 채널 논리를 개선하십시오. 셋째, 볼링거 밴드, KDJ 등과 같은 더 나은 필터레이션을 위해 하프트렌드를 대체하는 다른 지표를 시도하십시오. 넷째, 예를 들어 5 분 또는 30 분 전략으로 변경하여 다른 거래 도구의 특성에 따라 적절한 거래 간격을 지정하십시오. 이러한 최적화 조치는 안정성을 높이기 위해 시장 조건과 도구 특성에 따라 DMO 전략을 사용자 정의하는 데 도움이 될 수 있습니다.

결론

DMO는 여러 지표의 조합을 최적화하는 단기 전략이다. 시장 추세를 효과적으로 결정하고 정확한 거래 신호를 생성하기 위해 Doinchian Channel, Hull MA 및 Halftrend을 통합합니다. 비교적 간단하고 직관적인 기술과 쉬운 조작으로 초보자에게 소개 전략으로 사용될 수 있습니다. 단일 지표와 비교하면 DMO는 더 높은 승률과 수익성을 달성 할 수 있습니다. 매개 변수 조정, 조합 개선 및 간격 규격과 같은 조치를 통해 DMO 전략은 향상된 안정성으로 장기적인 우수한 성능을 달성 할 수 있습니다.


/*backtest
start: 2022-12-08 00:00:00
end: 2023-12-14 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/
// © kgynofomo

//@version=5
strategy(title="[Salavi] | Andy Super Pro Strategy [BTC|M15]",overlay = true, pyramiding = 1,initial_capital = 10000, default_qty_type = strategy.cash,default_qty_value = 10000)

//Doinchian Trend Ribbon
dlen = input.int(defval=30, minval=10)

dchannel(len) =>
    float hh = ta.highest(len)
    float ll = ta.lowest(len)

    int trend = 0
    trend := close > hh[1] ? 1 : close < ll[1] ? -1 : nz(trend[1])
    trend

dchannelalt(len, maintrend) =>
    float hh = ta.highest(len)
    float ll = ta.lowest(len)

    int trend = 0
    trend := close > hh[1] ? 1 : close < ll[1] ? -1 : nz(trend[1])
    maintrend == 1 ? trend == 1 ? #00FF00ff : #00FF009f : maintrend == -1 ? trend == -1 ? #FF0000ff : #FF00009f : na

maintrend = dchannel(dlen)
donchian_bull = maintrend==1
donchian_bear = maintrend==-1


//Hulls
src = input(hlc3, title='Source')
modeSwitch = input.string('Hma', title='Hull Variation', options=['Hma', 'Thma', 'Ehma'])
length = input(55, title='Length')
lengthMult = input(1.0, title='Length multiplier ')

useHtf = false
htf = '240'

switchColor = true
candleCol = false
visualSwitch = true
thicknesSwitch = 1
transpSwitch = 40

//FUNCTIONS
//HMA
HMA(_src, _length) =>
    ta.wma(2 * ta.wma(_src, _length / 2) - ta.wma(_src, _length), math.round(math.sqrt(_length)))
//EHMA    
EHMA(_src, _length) =>
    ta.ema(2 * ta.ema(_src, _length / 2) - ta.ema(_src, _length), math.round(math.sqrt(_length)))
//THMA    
THMA(_src, _length) =>
    ta.wma(ta.wma(_src, _length / 3) * 3 - ta.wma(_src, _length / 2) - ta.wma(_src, _length), _length)

//SWITCH
Mode(modeSwitch, src, len) =>
    modeSwitch == 'Hma' ? HMA(src, len) : modeSwitch == 'Ehma' ? EHMA(src, len) : modeSwitch == 'Thma' ? THMA(src, len / 2) : na

//OUT
_hull = Mode(modeSwitch, src, int(length * lengthMult))
HULL = useHtf ? request.security(syminfo.ticker, htf, _hull) : _hull
MHULL = HULL[0]
SHULL = HULL[2]

//COLOR
hullColor = switchColor ? HULL > HULL[2] ? #00ff00 : #ff0000 : #ff9800
hull_bull = HULL > HULL[2]
bull_start = hull_bull and hull_bull[1]==false
hull_bear = HULL < HULL[2]
bear_start = hull_bear and hull_bear[1]==false

barcolor(color=candleCol ? switchColor ? hullColor : na : na)

//halftrend
amplitude = input(title='Amplitude', defval=2)
channelDeviation = input(title='Channel Deviation', defval=2)
// showArrows = input(title='Show Arrows', defval=true)
// showChannels = input(title='Show Channels', defval=true)

var int trend = 0
var int nextTrend = 0
var float maxLowPrice = nz(low[1], low)
var float minHighPrice = nz(high[1], high)

var float up = 0.0
var float down = 0.0
float atrHigh = 0.0
float atrLow = 0.0
float arrowUp = na
float arrowDown = na

atr2 = ta.atr(100) / 2
dev = channelDeviation * atr2

highPrice = high[math.abs(ta.highestbars(amplitude))]
lowPrice = low[math.abs(ta.lowestbars(amplitude))]
highma = ta.sma(high, amplitude)
lowma = ta.sma(low, amplitude)

if nextTrend == 1
    maxLowPrice := math.max(lowPrice, maxLowPrice)

    if highma < maxLowPrice and close < nz(low[1], low)
        trend := 1
        nextTrend := 0
        minHighPrice := highPrice
        minHighPrice
else
    minHighPrice := math.min(highPrice, minHighPrice)

    if lowma > minHighPrice and close > nz(high[1], high)
        trend := 0
        nextTrend := 1
        maxLowPrice := lowPrice
        maxLowPrice

if trend == 0
    if not na(trend[1]) and trend[1] != 0
        up := na(down[1]) ? down : down[1]
        arrowUp := up - atr2
        arrowUp
    else
        up := na(up[1]) ? maxLowPrice : math.max(maxLowPrice, up[1])
        up
    atrHigh := up + dev
    atrLow := up - dev
    atrLow
else
    if not na(trend[1]) and trend[1] != 1
        down := na(up[1]) ? up : up[1]
        arrowDown := down + atr2
        arrowDown
    else
        down := na(down[1]) ? minHighPrice : math.min(minHighPrice, down[1])
        down
    atrHigh := down + dev
    atrLow := down - dev
    atrLow

ht = trend == 0 ? up : down

var color buyColor = color.blue
var color sellColor = color.red

htColor = trend == 0 ? buyColor : sellColor
// htPlot = plot(ht, title='HalfTrend', linewidth=2, color=htColor)

// atrHighPlot = plot(showChannels ? atrHigh : na, title='ATR High', style=plot.style_circles, color=color.new(sellColor, 0))
// atrLowPlot = plot(showChannels ? atrLow : na, title='ATR Low', style=plot.style_circles, color=color.new(buyColor, 0))

// fill(htPlot, atrHighPlot, title='ATR High Ribbon', color=color.new(sellColor, 90))
// fill(htPlot, atrLowPlot, title='ATR Low Ribbon', color=color.new(buyColor, 90))

HalfTrend_buySignal = not na(arrowUp) and trend == 0 and trend[1] == 1
HalfTrend_sellSignal = not na(arrowDown) and trend == 1 and trend[1] == 0

// plotshape(showArrows and buySignal ? atrLow : na, title='Arrow Up', style=shape.triangleup, location=location.absolute, size=size.tiny, color=color.new(buyColor, 0))
// plotshape(showArrows and sellSignal ? atrHigh : na, title='Arrow Down', style=shape.triangledown, location=location.absolute, size=size.tiny, color=color.new(sellColor, 0))




//ema
filter_ema = ta.ema(close,200)
ema_bull = close>filter_ema
ema_bear = close<filter_ema

atr_length = input.int(7)
atr = ta.atr(atr_length)
atr_rsi_length = input.int(50)
atr_rsi = ta.rsi(atr,atr_rsi_length)
atr_valid = atr_rsi>50

longCondition = bull_start and atr_valid
shortCondition = bear_start and atr_valid

Exit_long_condition = shortCondition
Exit_short_condition = longCondition

if longCondition
    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 shortCondition
    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.green:inShortTrade?color.red:na)


plotshape(longCondition, 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(shortCondition, 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)

Fi1 = plot(MHULL, title='MHULL', color=hullColor, linewidth=thicknesSwitch, transp=50)
Fi2 = plot(SHULL, title='SHULL', color=hullColor, linewidth=thicknesSwitch, transp=50)

fill(Fi1, Fi2, title='Band Filler', color=hullColor, transp=transpSwitch)




더 많은