임멘텀 로테이션 시간 프레임에 걸쳐 트렌드 전략에 따라

저자:차오장, 날짜: 2023-11-17 17:32:11
태그:

img

개요

이 전략은 시간 프레임에 걸쳐 움직이는 평균 라인 조합을 사용하여 중장거리 차트에서 트렌드 회전을 식별하고 낮은 위험 트렌드 추적 거래를 구현합니다. 이 전략은 트렌드를 추적하는 중장선 주식을 보유하는 거래자에게 적합합니다.

원리분석

전략은 5일, 20일, 40일 3개의 이동평균을 사용하여 다른 시간 프레임에서 추세를 판단하는 배열 조합을 사용한다.

구체적으로 5일 고속선에서 20일 중선을 통과하는 것은 단선 상승 신호이며, 20일 고속선에서 40일 느린선을 통과하는 것은 중선 상승 신호로 간주된다. 고속선에서 느린 3선이 정렬될 때 (5일>20일>40일) 다중 주기로 판단되며, 고속선에서 느린 3선이 역렬될 때 (5일<20일<40일) 빈 주기로 판단된다.

이렇게 큰 주기의 흐름 방향에 따라, 그리고 작은 주기의 힘과 결합하여 특정 입구를 검출한다. 즉, 큰 흐름이 동향적이고 작은 주기가 강한 경우에만 거래를 개시하면, 반전 허위 돌파를 효과적으로 필터링하여 높은 승률을 달성할 수 있다.

또한, 전략은 ATR 손해배상을 적용하여 단일 투자 위험을 통제하고 수익률을 더욱 높인다.

장점 분석

  • 사용자들이 다양한 품종과 거래 선호도에 맞게 이동평균 변수를 조정할 수 있는 유연한 구성

  • 이 방법은 매우 간단하고 초보자들도 쉽게 사용할 수 있습니다.

  • 자금의 사용 효율이 높고 자금의 레버리 효과를 최대한 활용할 수 있습니다.

  • 위험 통제, 손해 방지 메커니즘으로 큰 손실을 효과적으로 방지

  • 트렌드를 따라가는 능력, 큰 주기가 방향을 결정한 후 지속적인 수익

  • 승률이 높고 거래 신호 품질이 좋으며 경로 오작동이 적습니다.

위험과 개선

  • 대주기 판단은 이동평균선 배열에 의존하고 있으며, 뒤늦게 잘못된 판단의 위험이 있습니다.

  • 소주기 강도 검사는 하나의 K선만으로 가능하며, 미리 촉발될 수 있으며, 적절하게 쉴 수 있습니다.

  • 스톱 손실 규모는 고정되어 있으며, 동적 스톱으로 최적화됩니다.

  • 거래량 에너지와 같은 추가 필터링 조건을 추가하는 것을 고려할 수 있습니다.

  • 다양한 이동 평균 매개 변수 조합을 시도하여 전략을 최적화 할 수 있습니다.

요약

이 전략은 멀티 타임 프레임 분석과 스톱 손실 관리를 통합하여 낮은 위험 트렌드 추적 거래를 구현합니다. 파라미터 조정을 통해 트렌드 추종자의 요구를 충족시키기 위해 다양한 품종에 적용 할 수 있습니다. 전통적인 단일 타임 프레임 시스템보다 거래 결정이 더 견고하고 신호가 더 효율적입니다. 전반적으로 이 전략은 시장 적응성과 성장 전망이 좋습니다.

전반적인 설명

이 전략은 시간 프레임에 걸쳐 이동 평균의 조합을 사용하여 시간, 일 및 주간 차트에서 트렌드 회전을 식별합니다. 거래 후 낮은 위험 트렌드를 허용합니다. 이 전략은 유연하고 구현하기 쉽고 자본 효율적이며 중장기 트렌드 트레이더에 적합합니다.

거래 논리

이 전략은 5, 20 및 40 일 이동 평균을 사용하여 다른 시간 프레임에 걸쳐 트렌드의 조화를 결정합니다. 더 크고 작은 시간 프레임 사이의 일관성을 기반으로 상승 및 하락 주기를 식별합니다.

특히, 20일 중간 MA보다 5일 빠른 MA를 넘기는 것은 단기적으로 상승세를 나타냅니다. 40일 느린 MA보다 20일 중간 MA를 넘기는 것은 중기적으로 상승세를 나타냅니다. 빠른, 중간 및 느린 MA가 긍정적으로 정렬되면 (5일 > 20일 > 40일), 황소 사이클입니다. 부정적인 경우 (5일 < 20일 < 40일), 곰 사이클입니다.

더 큰 사이클에서 방향을 결정하고 더 작은 사이클에서 힘을 확인함으로써, 이 전략은 주요 트렌드와 소규모 추진력이 정렬될 때만 지점을 개척합니다. 이것은 잘못된 브레이크를 효과적으로 피하고 높은 승률을 달성합니다.

이 전략은 또한 ATR 트레일링 스톱을 사용하여 단일 무역 위험을 제어하고 수익성을 더 향상시킵니다.

장점

  • 다양한 도구와 거래 스타일에 맞는 유연한 구성

  • 심지어 초보 트레이더도 쉽게 구현할 수 있습니다.

  • 지분을 극대화하기 위한 높은 자본 효율성

  • 상당한 손실을 피하기 위한 효과적인 위험 관리

  • 지속 가능한 이익의 능력에 따른 강한 경향

  • 강력한 신호와 적은 윙사 때문에 높은 승률

위험 과 개선

  • MA 크로스오버가 늦어지고 추세 감지로 이어질 수 있습니다.

  • 단 하나의 촛불의 강도를 감지하면 조기 출입을 유발할 수 있습니다.

  • 고정 ATR 중지 손실, 동적 중지에 최적화

  • 부피와 같은 추가 필터를 추가하는 것을 고려하십시오.

  • 최적화를 위해 다른 MA 매개 변수를 탐구

결론

이 전략은 트레이딩 후 낮은 위험 트렌드를 위해 여러 시간 프레임 분석과 리스크 관리를 통합합니다. 매개 변수를 조정함으로써 트렌드 트레이더에 맞게 다른 도구에 적응 할 수 있습니다. 단일 시간 프레임 시스템과 비교하면 더 강력한 거래 결정을 내리고 더 높은 효율성 신호를 생성합니다. 결론적으로이 전략은 좋은 시장 적응력과 개발 잠재력을 가지고 있습니다.


/*backtest
start: 2023-10-17 00:00:00
end: 2023-11-16 00:00:00
period: 1h
basePeriod: 15m
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 [BTC|M15]",overlay = true, pyramiding = 1,initial_capital = 10000, default_qty_type = strategy.cash,default_qty_value = 10000)

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

// MONTHLY TABLE PERFORMANCE - Developed by @QuantNomad
// *************************************************************************************************************************************************************************************************************************************************************************
show_performance = input.bool(true, 'Show Monthly Performance ?', group='Performance - credits: @QuantNomad')
prec = input(2, 'Return Precision', group='Performance - credits: @QuantNomad')

if show_performance
    new_month = month(time) != month(time[1])
    new_year  = year(time)  != year(time[1])
    
    eq = strategy.equity
    
    bar_pnl = eq / eq[1] - 1
    
    cur_month_pnl = 0.0
    cur_year_pnl  = 0.0
    
    // Current Monthly P&L
    cur_month_pnl := new_month ? 0.0 : 
                     (1 + cur_month_pnl[1]) * (1 + bar_pnl) - 1 
    
    // Current Yearly P&L
    cur_year_pnl := new_year ? 0.0 : 
                     (1 + cur_year_pnl[1]) * (1 + bar_pnl) - 1  
    
    // Arrays to store Yearly and Monthly P&Ls
    var month_pnl  = array.new_float(0)
    var month_time = array.new_int(0)
    
    var year_pnl  = array.new_float(0)
    var year_time = array.new_int(0)
    
    last_computed = false
    
    if (not na(cur_month_pnl[1]) and (new_month or barstate.islastconfirmedhistory))
        if (last_computed[1])
            array.pop(month_pnl)
            array.pop(month_time)
            
        array.push(month_pnl , cur_month_pnl[1])
        array.push(month_time, time[1])
    
    if (not na(cur_year_pnl[1]) and (new_year or barstate.islastconfirmedhistory))
        if (last_computed[1])
            array.pop(year_pnl)
            array.pop(year_time)
            
        array.push(year_pnl , cur_year_pnl[1])
        array.push(year_time, time[1])
    
    last_computed := barstate.islastconfirmedhistory ? true : nz(last_computed[1])
    
    // Monthly P&L Table    
    var monthly_table = table(na)
    
    if (barstate.islastconfirmedhistory)
        monthly_table := table.new(position.bottom_center, columns = 14, rows = array.size(year_pnl) + 1, border_width = 1)
    
        table.cell(monthly_table, 0,  0, "",     bgcolor = #cccccc)
        table.cell(monthly_table, 1,  0, "Jan",  bgcolor = #cccccc)
        table.cell(monthly_table, 2,  0, "Feb",  bgcolor = #cccccc)
        table.cell(monthly_table, 3,  0, "Mar",  bgcolor = #cccccc)
        table.cell(monthly_table, 4,  0, "Apr",  bgcolor = #cccccc)
        table.cell(monthly_table, 5,  0, "May",  bgcolor = #cccccc)
        table.cell(monthly_table, 6,  0, "Jun",  bgcolor = #cccccc)
        table.cell(monthly_table, 7,  0, "Jul",  bgcolor = #cccccc)
        table.cell(monthly_table, 8,  0, "Aug",  bgcolor = #cccccc)
        table.cell(monthly_table, 9,  0, "Sep",  bgcolor = #cccccc)
        table.cell(monthly_table, 10, 0, "Oct",  bgcolor = #cccccc)
        table.cell(monthly_table, 11, 0, "Nov",  bgcolor = #cccccc)
        table.cell(monthly_table, 12, 0, "Dec",  bgcolor = #cccccc)
        table.cell(monthly_table, 13, 0, "Year", bgcolor = #999999)
    
    
        for yi = 0 to array.size(year_pnl) - 1
            table.cell(monthly_table, 0,  yi + 1, str.tostring(year(array.get(year_time, yi))), bgcolor = #cccccc)
            
            y_color = array.get(year_pnl, yi) > 0 ? color.new(color.teal, transp = 40) : color.new(color.gray, transp = 40)
            table.cell(monthly_table, 13, yi + 1, str.tostring(math.round(array.get(year_pnl, yi) * 100, prec)), bgcolor = y_color, text_color=color.new(color.white, 0))
            
        for mi = 0 to array.size(month_time) - 1
            m_row   = year(array.get(month_time, mi))  - year(array.get(year_time, 0)) + 1
            m_col   = month(array.get(month_time, mi)) 
            m_color = array.get(month_pnl, mi) > 0 ? color.new(color.teal, transp = 40) : color.new(color.gray, transp = 40)
            
            table.cell(monthly_table, m_col, m_row, str.tostring(math.round(array.get(month_pnl, mi) * 100, prec)), bgcolor = m_color, text_color=color.new(color.white, 0))



더 많은