# Follow Line Indicator
# Coverted to ToS from TV by bigboss. Original © Dreadblitz
input BbPeriod = 21;
input BbDeviations = 1;
input UseAtrFilter = yes;
input AtrPeriod = 5;
input HideArrows = no;
def BBUpper = SimpleMovingAvg(close, BbPeriod) + StDev(close, BbPeriod) * BbDeviations;
def BBLower = SimpleMovingAvg(close, BbPeriod) - StDev(close, BbPeriod) * BbDeviations;
def BBSignal = if close > BBUpper then 1 else if close < BBLower then -1 else 0;
def TrendLine =
if BBSignal == 1 and UseAtrFilter == 1 then
Max(low - ATR(AtrPeriod), TrendLine[1])
else if BBSignal == -1 and UseAtrFilter == 1 then
Min(high + ATR(AtrPeriod), TrendLine[1])
else if BBSignal == 0 and UseAtrFilter == 1 then
TrendLine[1]
else if BBSignal == 1 and UseAtrFilter == 0 then
Max(low, TrendLine[1])
else if BBSignal == -1 and UseAtrFilter == 0 then
Min(high, TrendLine[1])
else if BBSignal == 0 and UseAtrFilter == 0 then
TrendLine[1]
else TrendLine[1];
def iTrend = if TrendLine > TrendLine[1] then 1 else if TrendLine < TrendLine[1] then -1 else iTrend[1];
plot buy = if iTrend[1] == -1 and iTrend == 1 and !HideArrows then TrendLine else Double.NaN;
buy.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
buy.SetDefaultColor(Color.GREEN);
buy.SetLineWeight(3);
plot sell = if iTrend[1] == 1 and iTrend == -1 and !HideArrows then TrendLine else Double.NaN;
sell.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
sell.SetDefaultColor(Color.RED);
sell.SetLineWeight(3);
plot tline = TrendLine;
tline.AssignValueColor(if iTrend > 0 then CreateColor(33, 150, 243) else CreateColor(255, 82, 82));
tline.SetLineWeight(2);
#Ehler's Distant Coefficient Filter Study Created by Christopher84 05/20/2022
input length = 34;
input coloredCandlesOn = no;
input displace = 13;
def price = (high + low) / 2;
def coeff = length * price * price - 2 * price * Sum(price, length)[1] + Sum(price * price, length)[1];
plot Ehlers = Sum(coeff * price, length) / Sum(coeff, length);
#Ehlers.SetDefaultColor(GetColor(1));
def EhlersD = Ehlers [+displace];
def UP1 = (price > Ehlers);
def DN1 = (price < Ehlers);
#Condition Calculation
def UPBias = UP1;
def DNBias = DN1;
def Direction = UPBias - DNBias;
#AddCloud(Ehlers, EhlersD, Color.GREEN, Color.CURRENT);
#AddCloud(EhlersD, Ehlers, Color.RED, Color.CURRENT);
AssignPriceColor(if coloredCandlesOn and ((Direction > 0)) then Color.GREEN else if coloredCandlesOn and ((Direction < 0)) then Color.RED else Color.CURRENT);
plot Long_Entry = (Direction crosses above 0);
Long_Entry.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
Long_Entry.SetLineWeight(3);
Long_Entry.AssignValueColor(Color.UPTICK);
plot Long_Exit = (Direction crosses below 0);
Long_Exit.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
Long_Exit.SetLineWeight(3);
Long_Exit.AssignValueColor(Color.DOWNTICK);
plot ema21 = ExpAverage(close, 21);
input showlabel = yes;
AddLabel(showlabel, if ema21 > TrendLine and close > TrendLine and Ehlers > TrendLine then "True" else "False", if ema21 > TrendLine and close > TrendLine and Ehlers > TrendLine then color.light_green else color.light_red);