[dev]RedK Momentum Bars

RedKTrader · study · 75 行 · 点赞 4,994 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

// 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 v1.0')
 
// 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
 
 
//==============================================================================
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
//==============================================================================
 
// Inputs
 
Fast_Src    = input.source(close, title='Source',  inline = 'Fast')
Fast_Length = input.int(6, title = 'Length', minval = 1,   inline = 'Fast')
Slow_Src    = input.source(open, title='Source', inline = 'Slow')
Slow_Length = input.int(8, title='Length', minval = 1, inline = 'Slow')
Slow_Delay  = input.int(3, title='Delay (1 = No Delay', minval = 1)
 
Filter_Length = input.int(24, title='Filter Length', minval = 1)
 
 
// Calculation
Fast    = f_LazyLine(Fast_Src, Fast_Length)
Slow    = f_LazyLine(Slow_Src, Slow_Length)
 
Filter  = ta.wma(close, Filter_Length)
 
Fast_M  = Fast - Filter
Slow_M  = Slow - Filter
 
Rel_M = ta.wma(Slow_M, Slow_Delay)
 
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)
 
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)

← 返回列表