本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © HeWhoMustNotBeNamed
//@version=4
study("Adoptive Donchian Channel", overlay=true)
InitialLength = input(40, step=10)
showChannel = input(true)
donchian(rangeLength)=>
top = highest(rangeLength)
bottom = lowest(rangeLength)
middle = (top+bottom)/2
[middle, top, bottom]
adoptive_donchian(rangeLength)=>
[middle, top, bottom] = donchian(rangeLength)
channelBreak = high >= top[1] or low <= bottom[1]
if(not channelBreak)
middle := nz(middle[1], middle)
top := nz(top[1], top)
bottom := nz(bottom[1], bottom)
[middle, top, bottom]
[middle, top, bottom] = adoptive_donchian(InitialLength)
DCU = plot(showChannel?top:na, title="Upper", color=color.green, linewidth=1, transp=50, style=plot.style_linebr)
DCM = plot(showChannel?middle:na, title="Middle", color=color.maroon, linewidth=1, transp=50, style=plot.style_linebr)
DCL = plot(showChannel?bottom:na, title="Lower", color=color.red, linewidth=1, transp=50, style=plot.style_linebr)
fill(DCU, DCM, title="Upper", color=color.green, transp=90)
fill(DCM, DCL, title="Lower", color=color.red, transp=90)