Hi; I use this one give it a try @DeepwaterMy Third Lower section Indicator i sometimes use is a Bollenger Bandwidth indicator. It lets me know when a breakout occurs, either up or down.
Code:declare lower; input averageType = AverageType.Simple; input price = close; input displace = 0; input length = 20; input Num_Dev_Dn = -2.0; input Num_Dev_Up = 2.0; input BulgeLength = 150; input SqueezeLength = 150; def upperBand = BollingerBands(price, displace, length, Num_Dev_Dn, Num_Dev_Up, averageType).UpperBand; def lowerBand = BollingerBands(price, displace, length, Num_Dev_Dn, Num_Dev_Up, averageType).LowerBand; def midLine = BollingerBands(price, displace, length, Num_Dev_Dn, Num_Dev_Up, averageType).MidLine; plot Bandwidth = (upperBand - lowerBand) / midLine * 100; Bandwidth.SetDefaultColor(GetColor(1)); Bandwidth.SetLineWeight(3); AddLabel(yes, if Bandwidth > 1 then "BREAKOUT" else "", Color.CYAN); Alert( Bandwidth > 2 , "BREAKOUT ", Alert.BAR, Sound.Ring); plot Bulge = Highest(Bandwidth, BulgeLength); Bulge.SetDefaultColor(GetColor(8)); Bulge.setStyle(Curve.SHORT_DASH); plot Squeeze = Lowest(Bandwidth, SqueezeLength); Squeeze.SetDefaultColor(GetColor(8)); Squeeze.setStyle(Curve.SHORT_DASH); #End Code
Code:
#// Indicator for TOS
#// © peacefulLizard50262
#indicator("Chebyshev type I and II", "CHBV", true)
# Converted by Sam4Cok@Samer800 - 12/2024
# Modified to plot I&II lenghts on chart by CANDO13579
# Description:
# Implements two Chebyshev smoothing filters (Type I and Type II)
# using custom fractional complement logic and fundamental data source.
#------------------------------------------------------------
input timeframe = AggregationPeriod.MIN;
input Source = FundamentalType.CLOSE;
input length = 50;
input ripple = 7.5;
def na = Double.NaN;
def last = IsNaN(close);
def cap = GetAggregationPeriod();
def tf = Max(cap, timeframe);
# Custom Functions
script fractional_complement {
input x = 7.5;
plot out = (10 - ((9 / 10 * x) % 9)) * Power(10, -1 - Floor(x / 10));
}
script cosh {
input x = 1;
plot out = (Exp(x) + Exp(-x)) / 2;
}
script sinh {
input x = 1;
plot out = (Exp(x) - Exp(-x)) / 2;
}
script acosh {
input x = 1;
plot out = if x < 1 then 0 else Log(x + Sqrt(x * x - 1));
}
script asinh {
input x = 1;
plot out = Log(x + Sqrt(x * x + 1));
}
# Shared Value
def fc = fractional_complement(ripple);
# Chebyshev Type I
def a1 = cosh(1 / length * acosh(1 / (1 - fc)));
def b1 = sinh(1 / length * asinh(1 / fc));
def g1 = (a1 - b1) / (a1 + b1);
def chbv1 = if IsNaN(chbv1[1]) then Fundamental(Source, period = tf)
else (1 - g1) * Fundamental(Source, period = tf) + g1 * chbv1[1];
# Chebyshev Type II
def a2 = cosh(1 / length * acosh(1 / fc));
def b2 = sinh(1 / length * asinh(fc));
def g2 = (a2 - b2) / (a2 + b2);
def chbv2 = if IsNaN(chbv2[1]) then Fundamental(Source, period = tf)
else (1 - g2) * Fundamental(Source, period = tf) + g2 * chbv2[1];
# Define Price for Comparison
def price = Fundamental(Source, period = tf);
# Plot CHBV_I with Dynamic Color
plot CHBV_I = if !last then chbv1 else na;
CHBV_I.SetLineWeight(2);
CHBV_I.AssignValueColor(
if price > chbv1 then Color.GREEN # Price above → Green
else if price < chbv1 then Color.RED # Price below → Red
else Color.CYAN # Neutral (if price = CHBV_I)
);
CHBV_I.SetStyle(Curve.FIRM);
# Plot CHBV_II with Dynamic Color
plot CHBV_II = if !last then chbv2 else na;
CHBV_II.SetLineWeight(2);
CHBV_II.AssignValueColor(
if price > chbv2 then Color.LIGHT_ORANGE # Price above → Green
else if price < chbv2 then Color.RED # Price below → Red
else Color.YELLOW # Neutral (if price = CHBV_II)
);
CHBV_II.SetStyle(Curve.FIRM);
Last edited by a moderator: