本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © grnghost
//@version=6
indicator("Doc's Kinetic Energy", "KE")
len = input.int(21, "Displacement Length")
lookback = input.int(100, "Percentile Lookback")
disp = close - close[len]
velocity = disp/len
mass = math.sum(volume, len)
KE = 0.5*mass*(velocity*velocity)
KEpctl = ta.percentrank(KE, lookback)
Power = ta.change(KE, 1)
PowerPCTL = ta.percentrank(Power, lookback)
plot(math.max(PowerPCTL, 3), "Power", color = PowerPCTL <= 20 ? color.new(color.orange, 50) : PowerPCTL >= 80 ?color.new(color.blue, 25) : color.new(#1848cc, 50), style = plot.style_columns, linewidth = 1)
plot(KEpctl, "Kinetic Energy", color = color.new(color.yellow, 25), linewidth = 2)
hline(95)
hline(70, linestyle = hline.style_dotted)
hline(30, linestyle = hline.style_dotted)
hline(5)
hline(0, linestyle = hline.style_solid)
// -- Debug -- //
//pBuild = ta.change(area, 1) == 0
//plot(ta.change(swingHigh - swingLow, 1), display = display.status_line)