mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-12 23:58:04 +00:00
- Updated BBWN, BBWP, CCV, CV, CVI, EWMA, GKV, HLV, HV, Jvolty, JVOLTYN, MASSI, NATR, RSV, RV, RVI, TR, UI, VOV, VR, YZV indicators with documentation links. - Added documentation links for Aberration, Acceleration Bands, Andrews' Pitchfork, Adaptive Price Zone, ATR Bands, Bollinger Bands, Center of Gravity, Donchian Channels, Decay Min-Max Channel, Detrended Synthetic Price, EACP, EBSW, HOMOD, Jurik Volatility Bands, Keltner Channel, MA Envelope, Min-Max Channel, Price Channel, Regression Channels, Standard Deviation Channel, Stoller Average Range Channel, Super Trend Bands, Ultimate Bands, Ultimate Channel, VWAP Bands, and VWAP with Standard Deviation Bands.
60 lines
1.7 KiB
Plaintext
60 lines
1.7 KiB
Plaintext
// The MIT License (MIT)
|
|
// © mihakralj
|
|
//@version=6
|
|
indicator("Tillson T3 Moving Average (T3)", "T3", overlay=true)
|
|
|
|
//@function Calculates T3 using six EMAs with volume factor optimization
|
|
//@param source Series to calculate T3 from
|
|
//@param period Smoothing period
|
|
//@param v Volume factor controlling smoothing (default 0.7)
|
|
//@returns T3 value with optimized coefficients
|
|
//@optimized Uses six cascaded EMAs with precomputed coefficients for O(1) complexity
|
|
t3(series float src, simple int period, simple float v) =>
|
|
if period <= 0
|
|
runtime.error("T3 period must be > 0")
|
|
float a = 2.0 / (period + 1)
|
|
float v2 = v * v
|
|
float v3 = v2 * v
|
|
float c1 = -v3
|
|
float c2 = 3.0 * (v2 + v3)
|
|
float c3 = -3.0 * (2.0 * v2 + v + v3)
|
|
float c4 = 1.0 + 3.0 * v + 3.0 * v2 + v3
|
|
var float e1 = na
|
|
var float e2 = na
|
|
var float e3 = na
|
|
var float e4 = na
|
|
var float e5 = na
|
|
var float e6 = na
|
|
float res = na
|
|
if not na(src)
|
|
if na(e1)
|
|
e1 := src
|
|
e2 := src
|
|
e3 := src
|
|
e4 := src
|
|
e5 := src
|
|
e6 := src
|
|
res := src
|
|
else
|
|
e1 := e1 + a * (src - e1)
|
|
e2 := e2 + a * (e1 - e2)
|
|
e3 := e3 + a * (e2 - e3)
|
|
e4 := e4 + a * (e3 - e4)
|
|
e5 := e5 + a * (e4 - e5)
|
|
e6 := e6 + a * (e5 - e6)
|
|
res := c1 * e6 + c2 * e5 + c3 * e4 + c4 * e3
|
|
res
|
|
|
|
// ---------- Main loop ----------
|
|
|
|
// Inputs
|
|
i_source = input.source(close, "Source")
|
|
i_period = input.int(10, "Period", minval=1)
|
|
i_vfactor = input.float(0.7, "Volume Factor", minval=0.0, maxval=1.0, step=0.1)
|
|
|
|
// Calculation
|
|
t3_value = t3(i_source, i_period, i_vfactor)
|
|
|
|
// Plot
|
|
plot(t3_value, "T3", color=color.yellow, linewidth=2)
|