本页源码来自 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/
// © blackcat1402
//@version=4
study(title="[blackcat] L2 Ehlers ITrendline and Trigger Trend-Following System", shorttitle="BCL2EITTFS", overlay=true)
//Inputs
Price = input(hl2, title = "Source")
alpha = input(0.07, title = "alpha")
// Vars:
Smooth = 0.00
ITrend = 0.00
Trigger = 0.00
ITrend := (alpha - alpha*alpha/4)*Price + .5*alpha*alpha*nz(Price[1]) - (alpha - .75*alpha*alpha)*nz(Price[2]) + 2*(1 - alpha)*nz(ITrend[1]) - (1 - alpha) *(1 - alpha)*nz(ITrend[2])
ITrend := bar_index < 7 ? (Price + 2*nz(Price[1]) + nz(Price[2])) / 4 : ITrend
Trigger := 2*ITrend - nz(ITrend[2])
plot1 = plot(Trigger, "Trigger", color=color.yellow, linewidth=3)
plot2 = plot(ITrend, "ITrend", color=color.fuchsia, linewidth =3 )
fill(plot1, plot2, color=Trigger>ITrend ? color.yellow : color.fuchsia, transp=40)
// Plots cross labels
l = crossunder(Trigger, ITrend) ?
label.new (bar_index, Trigger[1]+1, "SELL", color=color.red, textcolor=color.white, style=label.style_labeldown, yloc=yloc.price, size=size.small) :
crossover(Trigger, ITrend) ?
label.new (bar_index, Trigger[1]-1, "BUY", color=color.green, textcolor=color.white, style=label.style_labelup, yloc=yloc.price, size=size.small) :
na