Creator Message:
T3 Volatility Quality Index ( VQI ) w/ DSL & Pips Filtering is a VQI indicator that uses T3 smoothing and discontinued signal lines to determine breakouts and breakdowns. This also allows filtering by pips.***
CODE:
CSS:
#/ This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © loxx
# https://www.tradingview.com/v/56Q61Aff/
#indicator("T3 Volatility Quality Index (VQI) w/ DSL & Pips Filtering [Loxx]",
# converted by Sam4Cok@Samer800 - 03/2023
declare lower;
#_iT3(src, per, hot, clean)=>
script _iT3 {
input src = close;
input per = 5;
input hot = 0.5;
input clean = "T3 New";
def a = hot;
def _c1 = -a * a * a;
def _c2 = 3 * a * a + 3 * a * a * a;
def _c3 = -6 * a * a - 3 * a - 3 * a * a * a;
def _c4 = 1 + 3 * a + a * a * a + 3 * a * a;
def alpha1 = 2.0 / (2.0 + (per - 1.0) / 2.0);
def alpha2 = 2.0 / (1.0 + per);
def alpha;
def t3Type = clean == "T3 New";
alpha = if t3Type then alpha1 else alpha2;
def _t30;
def _t31;
def _t32;
def _t33;
def _t34;
def _t35;
_t30 = CompoundValue(1, _t30[1] + alpha * (src - _t30[1]), src);
_t31 = CompoundValue(1, _t31[1] + alpha * (_t30 - _t31[1]), _t30);
_t32 = CompoundValue(1, _t32[1] + alpha * (_t31 - _t32[1]), _t31);
_t33 = CompoundValue(1, _t33[1] + alpha * (_t32 - _t33[1]), _t32);
_t34 = CompoundValue(1, _t34[1] + alpha * (_t33 - _t34[1]), _t33);
_t35 = CompoundValue(1, _t35[1] + alpha * (_t34 - _t35[1]), _t34);
def out = _c1 * _t35 + _c2 * _t34 + _c3 * _t33 + _c4 * _t32;
plot return = out;
}
script _declen {
def mtckstr = TickValue();
def dstr = if mtckstr < 1 then mtckstr else 0;
plot out = dstr;
}
#variant(type, src, len) =>
script variant {
input type = "Exponential Moving Average - EMA";
input src = close;
input len = 5;
def trig;# = 0.0
def MovType = type == "Exponential Moving Average - EMA";
def alpha = (2.0 / (2.0 + (len - 1.0) / 2.0));
def FEMA;
FEMA = CompoundValue(1, FEMA[1] + alpha * (src - FEMA[1]), src);
def ema = ExpAverage(src, len);
trig = if MovType then ema else FEMA;
plot out = trig;
}
input PriceSmoothing = 5; # "Source Smoothing Period"
input t3hot = 0.5; # "T3 Hot"
input t3Type = {default "T3 New", "T3 Original"}; # "T3 Type"
input FilterInPips = 1.9; # "Filter in Pips"
input sigmatype = {default "Exponential Moving Average - EMA", "Fast Exponential Moving Average - FEMA"};# "Signal/DSL Smoothing"
input Ma1Period = 9; # "DSL Period"
input colorbars = yes; # "Color bars?"
input showSigs = yes; # "Show signals?"
def na = Double.NaN;
def pipMultiplier = power(10, _declen() % 2);
def cHigh = _iT3(high, PriceSmoothing, t3hot, t3Type);
def cLow = _iT3(low, PriceSmoothing, t3hot, t3Type);
def cOpen = _iT3(open, PriceSmoothing, t3hot, t3Type);
def cClose = _iT3(close, PriceSmoothing, t3hot, t3Type);
def pClose = _iT3(close[1], PriceSmoothing, t3hot, t3Type);
def val;# = 0.,
def valc;# = 0.
def truerng = Max(cHigh, pClose) - Min(cLow, pClose);
def rng = cHigh - cLow;
def vqi = if (rng != 0 and truerng != 0) then ((cClose - pClose) / truerng + (cClose - cOpen) / rng) * 0.5 else val[1];
def vgiValue = AbsValue(vqi) * (cClose - pClose + cClose - cOpen) * 0.5;
valc = CompoundValue(1, val[1] + vgiValue, valc[1]);
def cond = AbsValue(valc-valc[1]) < FilterInPips * TickValue() * pipMultiplier;
if (FilterInPips > 0) {
if cond {
val = val[1];
} else {
val = valc;
}
} else {
val = val[1];
}
def sig = val[1];
def temp = variant(sigmatype, val, Ma1Period);
def levelu = if (val > sig) then temp else levelu[1];
def leveld = if (val < sig) then temp else leveld[1];
def colorout = if val > levelu then 1 else if val < leveld then -1 else 0;
plot VQILine = val; # "VQI"
VQILine.SetLineWeight(2);
VQILine.AssignValueColor(if colorout > 0 then Color.GREEN else
if colorout < 0 then Color.RED else Color.GRAY);
plot LevelUp = levelu; # "Level Up"
LevelUp.SetDefaultColor(Color.DARK_GREEN);
plot LevelDown = leveld; # "Level Down"
LevelDown.SetDefaultColor(Color.DARK_RED);
#--- Sig
def goLong = crosses(val, levelu, CrossingDirection.ABOVE);
def goShort = crosses(val, leveld, CrossingDirection.BELOW);
plot long = if showSigs and goLong then val else na;#, "Long", color.yellow, no);
long.SetPaintingStrategy(PaintingStrategy.SQUARES);
long.SetDefaultColor(Color.CYAN);
long.SetLineWeight(3);
plot short = if showSigs and goShort then val else na;#, "Short", color.MAGENTA, yes);
short.SetPaintingStrategy(PaintingStrategy.SQUARES);
short.SetDefaultColor(Color.MAGENTA);
short.SetLineWeight(3);
AssignPriceColor(if !Colorbars then Color.CURRENT else
if colorout > 0 then Color.GREEN else
if colorout < 0 then Color.RED else Color.GRAY);
#--- END CODE
Last edited by a moderator: