레드K 모멘텀 바

저자:차오장, 날짜: 2022-05-18 11:28:24
태그:SMAEMAWMAHMA

모멘텀 바 (Mo_Bars) 는 (상대적) 모멘텀을 시각화하는 다른 방법을 제공합니다. 그리고 간단한 TA 개념을 사용하여 모멘텀 변화를 읽고 거래에 통합하는 방법에 대한 다른 관점을 제공합니다.

이 아이디어 (그리고 시나리오 자체) 는 정말 매우 간단하며, 엘더의 충동 시스템 (EIS) 에서 영감을 받아 다른 개념을 활용하고 더 덜 엉망이되고 읽기 쉬워졌습니다.

모_바의 건설

기본 개념은 3개의 이동평균선을 이용합니다: 첫 번째 라인은 짧은 길이의 비교적 빠른 MA입니다. 주요 가격 추적 라인으로 작용합니다.

두 번째 라인은 메인 라인보다 약간 느리다 - 길이가 2 ~ 3 바 더 길다 - 기본적으로 오픈 값을 소스로 사용합니다 - 이것은 닫기 가격이 오픈보다 더 빨리 움직이기 시작할 때 더 잘 작동합니다 (바르가 열기보다 더 자주 닫을 때) - 이 라인은 신호 라인으로 작용합니다 - 규칙적인 WMA 평형을 사용하는 추가 지연 설정이 있습니다 - 지연은 2 MA 사이의 상대적 이동을 확대합니다.

이 두 MA의 경우, 저는 RSS MA (Lazy Line) 를 사용하기로 결정했습니다. 다른 MA 유형도 사용할 수 있지만, 제가 MA 유형을 특별히 사용하게 된 이유는 그것은 gracefully로 움직이기 때문입니다. 그리고 2개의 Lazy Lines가 함께 움직이면 작은 가격 변동으로 인한 윙스를 최소화합니다.

세 번째 라인은 훨씬 느린 MA (길이 5 ~ 6 × 빠른 라인) 이며 필터 또는 기본 라인으로 작용합니다. 그 라인의 위에있을 때 우리는 긴 포지션을 선호해야합니다. 우리는 황소 영역에 있습니다. 그 라인의 아래에있을 때 우리는 짧은 포지션을 선호하고 곰 영역에 있습니다. 귀하의 거래 스타일과 시간 틀에 맞게이 라인을 조정하십시오. (나는 WMA를 필터 라인의 MA 유형으로 사용하기로 결정했습니다. 그리고 그 이유는 좋은 이유가 있습니다. 지금은 넘어가겠습니다. 그러나 미래의 버전에서는 다른 선택 가능한 MA 유형을 추가 할 수 있습니다.)

Mo_Bars를 사용함

매우 넓은 차원에서, 우리는 MACD를 사용하는 것과 비슷하게 Mo_Bars를 사용할 수 있습니다. 둘 다 중심 및 무제한 오시레이터입니다. Mo_Bars가 2가 아닌 3 MA를 기반으로한다는 차이점을 주목하십시오.

Mo_Bar 바 길이는 주요 MA와 신호 MA 사이의 거리를 나타냅니다. 기본선 (필터 라인) 에 비해 그래프화됩니다. 즉 바 길이는 2 MA 사이의 상대적 모멘텀을 나타냅니다. Mo_Bars는 그 모멘텀의 값을 증가하거나 감소시키는 방식으로 색칠됩니다.

간단히 말해서, 주 MA가 신호 MA 아래에 있다면, 바는 빨간색이고, 주 MA가 신호 MA 위에 있을 때, 바는 초록색입니다. 상대적 운동 방향의 변화가 감지되면 흰색 바가 보통 나타납니다.

  • 위의 차트에서, 나는 어떻게 상대적 모멘텀을 시각화 하는 방법에 대한 몇 가지 예를 언급했습니다. 이러한 방법으로 의 영역을 노출합니다. (Mo_Bars는 0보다 높지만 빨간색 또는 아래로 이동하거나 Mo_Bars가 0보다 낮고 녹색 또는 위로 이동할 때) - 가격과 동떨림 / 분산 - 그리고 이것이 가격 행동 또는 트렌드에서 잠재적 변화의 가능성을 노출하는 데 어떻게 작용할 수 있는지.

  • 이 설정에 대해 더 많은 것을 할 수 있습니다. 그리고 아마도 충분한 관심이 있다면 앞으로 어떻게 활용할 것인지 또는 더 발전시킬 것인지에 대한 전용 게시물이있을 수 있습니다. 여기에 더 많은 필터를 추가할 가능성이 있습니다. (어쩌면 볼륨 기반), 알림, 신호...

다음은 Mo_Bars가 기반을 둔 상세한 (올라기 차트) 설정입니다. 가격 차트의 MA의 설정은 아래에서 볼 수있는 가격 차트에서 MA 동작을 번역하는 스크립트가 작동하는 방법을 보여주기 위해 아래 패널의 Mo_Bars 설정과 일치 / 동기화되었습니다.

백테스트

img


/*backtest
start: 2022-05-10 00:00:00
end: 2022-05-16 23:59:00
period: 3m
basePeriod: 1m
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/
// © RedKTrader

//@version=5
indicator('[dev]RedK Momentum Bars', shorttitle='RedK MoBars v3.0', explicit_plot_zorder = true, timeframe='', timeframe_gaps=false)

// A trading system composed of 2 short Lazy Lines (preferably one open and one close - 2-3 bars apart) and a WMA long filter 
// loosely inspired by Edler Impulse
// v2.0 cleaned up code and added MA options to be able to mix and match, and experiment with various setups 
// default values (my personal preference) remain the same as in v1.0 
// for example, some traders will consider "bear territory" only below SMA50, others will use EMA30 .. and so on.
// ---------------------------------------------------------------------------------------------------------------
// MoBars v3.0: 
// updated defaults to match the most common 3x MA cross-over set-up of SMA (10, 20, 50)
// updated visuals to push the 0 line to the background of the plot (using the explcit_plot_zorder param)
// and added alerts for crossing up, down and swing around the 0 line (the Bullish/Bearish Filter MA)

//==============================================================================
f_LazyLine(_data, _length) =>
    w1 = 0,     w2 = 0,     w3 = 0
    L1 = 0.0,   L2 = 0.0,   L3 = 0.0
    w = _length / 3

    if _length > 2
        w2 := math.round(w)
        w1 := math.round((_length - w2) / 2)
        w3 := int((_length - w2) / 2)

        L1 := ta.wma(_data, w1)
        L2 := ta.wma(L1, w2)
        L3 := ta.wma(L2, w3)
        
    else
        L3 := _data
        
    L3
//==============================================================================

// =============================================================================    
f_getMA(source, length, type) =>
    type == "SMA" ? ta.sma(source, length) : 
      type == "EMA" ? ta.ema(source, length) :
      type == "WMA" ? ta.wma(source, length) :
      type == "HMA" ? ta.hma(source, length) :
      f_LazyLine(source, length)
// =============================================================================    

// ------------------------------------------------------------------------------------------------
// Inputs
// Note, in v3.0, changed default lengths to 10, 20 and 50  -- and all MA types to SMA. 
// ------------------------------------------------------------------------------------------------

Fast_Src    = input.source(close,   title='Fast MA Source',          inline = 'Fast')
Fast_Length = input.int(10,          title = 'Length',   minval = 1, inline = 'Fast')
Fast_Type   = input.string('SMA', title = 'Type',                    inline = 'Fast',
  options = ['RSS_WMA', 'WMA', 'EMA', 'SMA', 'HMA'])

Slow_Src    = input.source(close,    title='Slow MA Source',         inline = 'Slow')
Slow_Length = input.int(20,          title='Length',     minval = 1, inline = 'Slow')
Slow_Type   = input.string('SMA', title = 'Type',                    inline = 'Slow',
  options = ['RSS_WMA', 'WMA', 'EMA', 'SMA', 'HMA'])

Slow_Delay  = input.int(3,          title='Delay (1 = None)',       minval = 1)

Fil_Length  = input.int(50,       title='Filter MA Length', minval = 1, inline = 'Filter')
Fil_Type    = input.string('SMA', title = 'Type',                   inline = 'Filter',
  options = ['RSS_WMA', 'WMA', 'EMA', 'SMA', 'HMA'])


// ------------------------------------------------------------------------------------------------
// Calculation
// ------------------------------------------------------------------------------------------------

Fast    = f_getMA(Fast_Src, Fast_Length, Fast_Type)
Slow    = f_getMA(Slow_Src, Slow_Length, Slow_Type)

Filter  = f_getMA(close, Fil_Length, Fil_Type)

Fast_M  = Fast - Filter
Slow_M  = Slow - Filter

Rel_M   = ta.wma(Slow_M, Slow_Delay)

// prep the Momentum bars
o = Rel_M
c = Fast_M
h = math.max(o, c)
l = math.min(o, c)

rising      = ta.change(c) > 0


// ------------------------------------------------------------------------------------------------
// Colors & Plots
// ------------------------------------------------------------------------------------------------

hline(0, title = 'Zero Line', color = color.blue, linestyle = hline.style_solid)

c_barup     = #11ff20ff
c_bardn     = #ff1111ff
c_bardj     = #ffffffff

c_barupb    = #1b5e20ff
c_bardnb    = #981919ff
c_bardjb    = #9598a1ff

barcolor    = c > o and rising ? c_barup : c < o and not rising ? c_bardn : c_bardj
borcolor    = c > o and rising ? c_barupb : c < o and not rising ? c_bardnb : c_bardjb
//plotcandle(o, h, l, c, 'MoBars', barcolor, barcolor, bordercolor = borcolor)


// ===========================================================================================================
//      v3.0 adding alerts 
// these alerts will trigger as soon as the Momentum Bar touches above the filter line 
// this approach can lead to "false signals" but also has an advantage (of alerting to a possible mood/mode change)
// another option - maybe in an updated version - could be to trigger alerts *only* when the full Momentum Bar completely clears the filter line (above or below)
// and it's easy to make that a user choice in the study inputs
// ===========================================================================================================

Alert_up    = ta.crossover(h,0)
Alert_dn    = ta.crossunder(l,0)
Alert_swing = Alert_up or Alert_dn

// "." in alert title for the alerts to show in the right order up/down/swing 
alertcondition(Alert_up,    ".   MoBars Crossing 0 Up",         "MoBars Up - Bullish Mode Detected!")
alertcondition(Alert_dn,    "..  MoBars Crossing 0 Down",       "MoBars Down - Bearish Mode Detected!")
alertcondition(Alert_swing, "... MoBars Crossing 0",            "Mobars Swing - Possible Reversal Detected!")



if Alert_up
    strategy.entry("Enter Long", strategy.long)
else if Alert_dn
    strategy.entry("Enter Short", strategy.short)

관련

더 많은