Optimized Trend Tracker created by Kivanc Ozbilgic.
OTT is an indicator that allows traders to find an existing trend. In other words to see which side of the current trend we are on.
The area between HOTT and LOTT is FLAT ZONE which developer advises to do nothing.
Bars will be highlighted to Turquoise when candles close over HOTT, means an UPTREND SIGNAL
and to Fuchia when candles begin closing under LOTT line to indicate a DOWNTREND SIGNAL.
FLAT ZONE is highlighted also to have the maximum concentration on sideways market conditions.
There are three quantitative parameters in this indicator:
The first parameter in the OTT indicator set by the two parameters is the period/length.
OTT lines will be much sensitive to trend movements if it is smaller.
And vice versa, will be less sensitive when it is longer.
As the period increases it will become less sensitive to little trends and price actions.
In this way, your choice of period, will be closely related to which of the sort of trends you are interested in.
The OTT percent parameter in OTT is an optimization coefficient. Just like in the period
small values are better at capturing short term fluctuations, while large values
will be more suitable for long-term trends.
The final adjustable quantitative parameter is HIGHEST and LOWEST length which is the source of calculations.
SOURCE CODE
CSS:
#// © KivancOzbilgic
#//created by: @Anil_Ozeksi
#//developer: ANIL ÖZEKŞİ
#//author: @kivancozbilgic
#https://www.tradingview.com/script/5qkKOlVg-HIGH-and-LOW-Optimized-Trend-Tracker-HOTT-LOTT/
#indicator('HIGH AND LOW Optimized Trend Tracker', 'HL OTT', overlay=true)
# Converted and mod by Sam4Cok @ Samer800 08/2022
input Alert = {default "No Alert", "NoSound", "Ding", "Bell", "Chimes", "Ring"};
input ShowCloud = yes; # Highlighter On/Off ?
input BarColor = no;
input length = 2; # OTT Period
input percent = 0.6; # OTT Optimization Coeff
input hllength = 10; # Highest and Lowest Length
input MovAvgType = {default VAR, SMA, EMA, WMA, DEMA, TMA, WWMA, ZLEMA, TSF, HULL};
def na = Double.NaN;
script nz {
input data = 1;
input repl = 0;
def ret_val = if IsNaN(data) then repl else data;
plot return = ret_val;
}
def src = Highest(high, hllength);
def srcl = Lowest(low, hllength);
#Var_Func(src, length) =>
script Var_Func {
input src = close;
input length = 0;
def valpha = 2 / (length + 1);
def vud1 = if src > src[1] then src - src[1] else 0;
def vdd1 = if src < src[1] then src[1] - src else 0;
def vUD = Sum(vud1, 9);
def vDD = Sum(vdd1, 9);
def vCMO = nz((vUD - vDD) / (vUD + vDD));
def VAR;
VAR = valpha * AbsValue(vCMO) * src + (1 - valpha * AbsValue(vCMO)) * nz(VAR[1]);
plot result = VAR;
}
#Wwma_Func(src, length) =>
script Wwma_Func {
input src = close;
input length = 0;
def wwalpha = 1 / length;
def WWMA;
WWMA = wwalpha * src + (1 - wwalpha) * nz(WWMA[1]);
plot return = WWMA;
}
#Zlema_Func(src, length) =>
script Zlema_Func {
input src = close;
input length = 0;
def zxLag = if length / 2 == Round(length / 2) then length / 2 else (length - 1) / 2;
def zxEMAData = src + src - src[zxLag];
def ZLEMA = ExpAverage(zxEMAData, length);
plot return = ZLEMA;
}
#Tsf_Func(src, length) =>
script Tsf_Func {
input src = close;
input length = 0;
def lrc = Inertia(src, length);
def lrc1 = Inertia(src[1], length);
def lrs = lrc - lrc1;
def TSF = Inertia(src, length) + lrs;
plot retur = TSF;
}
def HMA = WMA(2 * WMA(src, length / 2) - WMA(src, length), Round(Sqrt(length)));
#Var_Funcl(srcl, length) =>
script Var_Funcl {
input srcl = close;
input length = 0;
def valphal = 2 / (length + 1);
def vud1l = if srcl > srcl[1] then srcl - srcl[1] else 0;
def vdd1l = if srcl < srcl[1] then srcl[1] - srcl else 0;
def vUDl = Sum(vud1l, 9);
def vDDl = Sum(vdd1l, 9);
def vCMOl = nz((vUDl - vDDl) / (vUDl + vDDl));
def VARl;
VARl = nz(valphal * AbsValue(vCMOl) * srcl) + (1 - valphal * AbsValue(vCMOl)) * nz(VARl[1]);
plot return = VARl;
}
#Wwma_Funcl(srcl, length) =>
script Wwma_Funcl {
input srcl = close;
input length = 0;
def wwalpha = 1 / length;
def WWMA;
WWMA = wwalpha * srcl + (1 - wwalpha) * nz(WWMA[1]);
plot return = WWMA;
}
#Zlema_Funcl(srcl, length) =>
script Zlema_Funcl {
input srcl = close;
input length = 0;
def zxLag = if length / 2 == Round(length / 2) then length / 2 else (length - 1) / 2;
def zxEMAData = srcl + srcl - srcl[zxLag];
def ZLEMA = ExpAverage(zxEMAData, length);
plot return = ZLEMA;
}
#Tsf_Funcl(srcl, length) =>
script Tsf_Funcl {
input srcl = close;
input length = 0;
def lrc = Inertia(srcl, length);
def lrc1 = Inertia(srcl[1], length);
def lrs = lrc - lrc1;
def TSF = Inertia(srcl, length) + lrs;
plot retur = TSF;
}
#getMA(src, length, type) =>
script getMA {
input src = close;
input length = 100;
input type = "SMA";
def ma;
ma = if type == "SMA" then SimpleMovingAvg(src, length) else
if type == "EMA" then ExpAverage(src, length) else
if type == "WMA" then WMA(src, length) else
if type == "DEMA" then 2 * ExpAverage(src, length) - ExpAverage(ExpAverage(src, length), length) else
if type == "TMA" then SimpleMovingAvg(SimpleMovingAvg(src, Ceil(length / 2)), Floor(length / 2) + 1) else
if type == "VAR" then Var_Func(src, length) else
if type == "WWMA" then WWMA_Func(src, length) else
if type == "ZLEMA" then Zlema_Func(src, length) else
if type == "TSF" then Tsf_Func(src, length) else
if type == "HULL" then WMA(2 * WMA(src, length / 2) - WMA(src, length), Round(Sqrt(length))) else Double.NaN;
plot result = ma;
}
#OTT(Source, percent) =>
script OTT {
input Source = close;
input percent = 0;
def fark = Source * percent * 0.01;
def UP = Source + fark;
def LW = Source - fark;
def UP_Band = if ((UP < UP_Band[1]) or (Source[1] > UP_Band[1])) then UP else UP_Band[1];
def LW_Band = if ((LW > LW_Band[1]) or (Source[1] < LW_Band[1])) then LW else LW_Band[1];
def MT = if ((MT[1] == UP_Band[1]) and (Source < UP_Band)) then UP_Band
else if ((MT[1] == UP_Band[1]) and (Source > UP_Band)) then LW_Band
else if ((MT[1] == LW_Band[1]) and (Source > LW_Band)) then LW_Band
else if ((MT[1] == LW_Band) and (Source < LW_Band)) then UP_Band
else LW_Band;
plot Super = MT;
}
def MAvg = getMA(src, length, MovAvgType);
def MT = OTT(MAvg, percent);
def HOTT = if MAvg > MT then MT * (200 + percent) / 200 else MT * (200 - percent) / 200;
def MAvgl = getMA(srcl, length, MovAvgType);
def MTl = OTT(MAvgl, percent);
def LOTT = if MAvgl > MTl then MTl * (200 + percent) / 200 else MTl * (200 - percent) / 200;
### Plots
plot HOTTLine = if HOTT then nz(HOTT[2]) else na;
plot LOTTLine = if LOTT then nz(LOTT[2]) else na;
HOTTLine.AssignValueColor(CreateColor(41,98,255));
HOTTLine.SetLineWeight(2);
LOTTLine.AssignValueColor(CreateColor(255,82,82));
LOTTLine.SetLineWeight(2);
### Clouds/BarColor
addcloud(if ShowCloud then HOTTLine else na, LOTTLine, CreateColor(48,25,52));
AssignPriceColor(if BarColor then if close > HOTT[2] then CreateColor(0,255,255) else if close < LOTT[2] then CreateColor(255,0,255) else Color.CURRENT else Color.CURRENT);
### Alerts
Alert(if alert ==alert."No Alert" then na else close crosses above HOTT[2],"PRICE OVER HOTT", Alert.ONCE, Alert);
Alert(if alert ==alert."No Alert" then na else close crosses below LOTT[2],"PRICE UNDER LOTT", Alert.ONCE, Alert);
### END of CODE
Last edited by a moderator: