本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
// TASC Issue: November 2026
// Article: The UniEMA
// A Universal Exponential Moving Average
// Article By: Igor Durkin
// Language: TradingView's Pine Script™ v6
// Provided By: PineCoders, for tradingview.com
//@version=6
TITLE = "TASC 2026.11 The UniEMA"
SHORTTITLE = "UniEMA"
indicator(TITLE,SHORTTITLE, overlay = true)
//#region Functions
UniXMA (float _price, int _length,
int _poles, int _order,
float _wf, float _df) =>
float alpha = _wf*_order / (_length + _wf*_order - 1.0)
float bet = 1.0 - alpha
int uni_size = _poles*_order
float[] u_tmp = array.new<float>(uni_size, float(na))
float uniema = _price
if bar_index >= 1
for _k=0 to _order - 1
for _j=0 to _poles - 1
if bar_index == 1
u_tmp.set(_poles*_k+_j, _price)
else
float[] _p = u_tmp[1]
u_tmp.set(_poles*_k + _j,
bet*_p.get(_poles*_k + _j) +
alpha*uniema)
if _j > 0
uniema := (uniema +
_df*(u_tmp.get(_poles*_k) -
u_tmp.get(_poles*_k + _j)))
else
uniema := u_tmp.get(_poles*_k + _j)
uniema
//#endregion
//#region Inputs
float src = input.source(close, "Source")
int len = input.int(14, "Length")
int poles = input.int(2, "Poles", 1, 4,
tooltip="Poles: 1-EMA, 2-DEMA, 3-TEMA, 4-QEMA")
int order = input.int(3, "Order", 1,
tooltip="Smoothing Order (min. 1)")
float wf = input.float(0.5, "Weight Factor",
tooltip="Weight Factor (Wilder=1, EMA=2)")
float df = input.float(0.5, "Damping Factor",
tooltip="Damping Factor (ex. 0.7)")
bool show2Col =
input.bool(true, "Show Multi-Color Line")
color upColor = input.color(color.blue, "Color 1")
color downColor = input.color(color.red, "Color 2",
active = show2Col)
//#endregion
//#region Calculations
float UniEma = UniXMA(src, len, poles, order, wf, df)
//#endregion
//#region Display
color pcol = upColor
pcol := switch
UniEma > UniEma[1] or not show2Col => upColor
UniEma < UniEma[1] => downColor
plot(UniEma, "UniEMA", pcol)
//#endregion