Donchian Trend Ribbon

LonesomeTheBlue · study · 38 行 · 点赞 7,228 · 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/
// © LonesomeTheBlue
 
//@version=4
study("Donchian Trend Ribbon")
dlen = input(defval = 20, title = "Donchian Channel Period", minval = 10)
 
dchannel(len)=>
    float hh = highest(len)
    float ll = lowest(len)
    
    int trend = 0
    trend := close > hh[1] ? 1 : close < ll[1] ? -1 : nz(trend[1])
    trend
    
dchannelalt(len, maintrend)=>
    float hh = highest(len)
    float ll = lowest(len)
    
    int trend = 0
    trend := close > hh[1] ? 1 : close < ll[1] ? -1 : nz(trend[1])
    trendcolor =  maintrend == 1  ? trend == 1  ? #00FF00ff :  #00FF009f :
                  maintrend == -1 ? trend == -1 ? #FF0000ff :  #FF00009f :
                  na
    trendcolor
 
maintrend = dchannel(dlen)
 
plot(05, color = dchannelalt(dlen - 0, maintrend), style = plot.style_columns, histbase=00, transp = 0)
plot(10, color = dchannelalt(dlen - 1, maintrend), style = plot.style_columns, histbase=05, transp = 10)
plot(15, color = dchannelalt(dlen - 2, maintrend), style = plot.style_columns, histbase=10, transp = 15)
plot(20, color = dchannelalt(dlen - 3, maintrend), style = plot.style_columns, histbase=15, transp = 20)
plot(25, color = dchannelalt(dlen - 4, maintrend), style = plot.style_columns, histbase=20, transp = 25)
plot(30, color = dchannelalt(dlen - 5, maintrend), style = plot.style_columns, histbase=25, transp = 30)
plot(35, color = dchannelalt(dlen - 6, maintrend), style = plot.style_columns, histbase=30, transp = 35)
plot(40, color = dchannelalt(dlen - 7, maintrend), style = plot.style_columns, histbase=35, transp = 40)
plot(45, color = dchannelalt(dlen - 8, maintrend), style = plot.style_columns, histbase=40, transp = 45)
plot(50, color = dchannelalt(dlen - 9, maintrend), style = plot.style_columns, histbase=45, transp = 50)

← 返回列表