Donchian Blaster

pckalai · study · 98 行 · 点赞 1,055 · 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/
 
//@version=4
//Indicator by CK(pckalai) - Published
 
//Modified Donchian Channel - This script/indicator is designed with the main purpose of identifying the strength of the instrument. 
//Inputs can be changed by users as per their own rules as per their matching style. 
 
study(title="Donchian Blaster", shorttitle="CK_DB", overlay=true)
 
isHMA = input(false, title="Use HMA as primary source")
 
//Linear Lines
 
//Linear Stop
 
srcStop = input(close, title="Linear Stop Source")
lengthStop = input(type=input.integer, defval=25, title="Stop Period")
offsetStop = input(type=input.integer, defval=0, title="Stop Offset")
linearStop = linreg(srcStop, lengthStop, offsetStop)
plot((isHMA==false) and linearStop ? linearStop : na, color=color.blue, style=plot.style_circles, linewidth=2, title="Linear Stop")
 
//Linear Trade Setup
 
src2Stop = input(close, title="Linear Setup Source")
length2Stop = input(type=input.integer, defval=75, title="Setup Period")
offset2Stop = input(type=input.integer, defval=0, title="Setup Offset")
linear2Stop = linreg(src2Stop, length2Stop, offset2Stop)
plot((isHMA==false)  and linear2Stop ? linear2Stop : na, color=color.fuchsia, style=plot.style_stepline, linewidth=2, title="Linear Trade Setup")
 
//Linear Trend Line
 
src3Stop = input(close, title="Linear Trend Source")
length3Stop = input(type=input.integer, defval=300, title="Trend Period")
offset3Stop = input(type=input.integer, defval=0, title="Trend Offset")
linear3Stop = linreg(src3Stop, length3Stop, offset3Stop)
 
linearTrendColor = (close > linear3Stop) ? color.green : color.red
 
plot((isHMA==false)  and linear3Stop ? linear3Stop : na, color=linearTrendColor, style=plot.style_line, linewidth=3, title="Linear Trend Line")
 
//HMA Lines
 
//HMA Stop
 
hmaIntermediatePeriod  = input(30, minval=1, title="HMA Stop Period")
hmaIntermediate        = hma(input(close), hmaIntermediatePeriod)
plot(isHMA and hmaIntermediate ? hmaIntermediate : na, color=color.blue, linewidth=2, title="HMA Stop")
 
//HMA Trade Setup
 
hmaMediumPeriod  = input(100, minval=1, title="HMA Trade Period")
hmaMedium        = hma(input(close), hmaMediumPeriod)
plot(isHMA and hmaMedium ? hmaMedium : na, color=color.fuchsia, linewidth=2, title="HMA Trade Setup")
 
//HMA Trend Line
 
hmaLongPeriod  = input(300, minval=1, title="HMA Trend Period")
hmaLong        = hma(input(close), hmaLongPeriod)
hmaTrendColor = (close > hmaLong) ? color.green : color.red
plot(isHMA and hmaLong ? hmaLong : na, color=hmaTrendColor, linewidth=3, title="HMA Trend Line")
 
//Donchian 50
 
DCLength = input(50, minval=1)
DCLower = lowest(DCLength)
DCUpper = highest(DCLength)
DCBasis = avg(DCUpper, DCLower)
 
maColor = (close > DCBasis) ? color.lime : color.red
 
plot(DCBasis, "DC Basis", color=maColor, linewidth=2)
 
fillColor = isHMA ? hmaTrendColor : linearTrendColor
 
upperBoundary = plot(DCUpper, "DC Upper", color=fillColor, linewidth=2)
lowerBoundary = plot(DCLower, "DC Lower", color=fillColor, linewidth=2)
fill(upperBoundary, lowerBoundary, color=fillColor, transp=95, title="DC Background")
 
//1 EMA - Long Term
 
showEMA1 = input(false, title="Exponential Moving Average - Long Term")
emaLongerPeriod = input(200, minval=1, title="EMA Longer Period")
emaLong       = ema(input(close), emaLongerPeriod)
plot(showEMA1 and emaLong ? emaLong : na, color=color.aqua, linewidth=2, title="EMA Longer Period")
 
 
//1 SMA - Medium Term
 
showSMA1 = input(false, title="Simple Moving Average - Medium Term")
smaMediumPeriod = input(50, minval=1, title="SMA Medium Period")
smaMedium       = sma(input(close), smaMediumPeriod)
plot(showSMA1 and smaMedium ? smaMedium : na, color=color.maroon, linewidth=2, title="SMA Medium Period")
 
 
//Disclaimer: Idea of publishing this script is to identify the strength of the instrument using multiple confirmation. 
//Disclaimer: Using this indicator, changing inputs, and trading decisions are upto the users/traders.
//Courtesy: Thanks to Richard Donchian, Alan Hull, and author of LSMA as this indicator/script inspired by Donchian Channels, Hull Moving Average, and LSMA

← 返回列表