(AK) TrendXplorer.com HLC Trend Indicator For ThinkOrSwim

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Try this...


Code:
# study("(AK) TrendXplorer.com HLC Trend Indicator")
# Indicator based on article found on TrendXplorer.com
# Link:  https://www.tradingview.com/script/i218XnGI-TrendXplorer-com-HLC-Trend-Indicator/
# Ported to TOS by tradegeek

declare lower;

input closeLength = 5;
input lowLength = 13;
input highLength = 34;
input PaintBars = yes;

def emac = ExpAverage(close, closeLength);
def emal = ExpAverage(low, lowLength);
def emah = ExpAverage(high, highLength);

# Calculations
def long = (emac - emah) >= (emal - emac);
def neut = (emac - emah);
def short = (emal - emac) > ( emac - emah);

# plots
plot ch = emac - emah;
ch.SetDefaultColor(Color.GREEN);
ch.SetPaintingStrategy(PaintingStrategy.LINE);
ch.SetLineWeight(2);

plot lc = emal - emac;
lc.SetDefaultColor(Color.RED);
lc.SetPaintingStrategy(PaintingStrategy.LINE);
lc.SetLineWeight(2);

assignpriceColor(if long and PaintBars then color.Green else if short and PaintBars then color.RED else color.YELLOW);
 
Last edited:
Changed the plot to a histogram and added arrows and dev bands
Code:
# Link:  https://www.tradingview.com/script/i218XnGI-TrendXplorer-com-HLC-Trend-Indicator/
# Ported to TOS by tradegeek

declare lower;

input closeLength = 5;
input lowLength = 13;
input highLength = 34;
input PaintBars = yes;
input arrows = 0;
input dotsize =3;

def emac = ExpAverage(close, closeLength);
def emal = ExpAverage(low, lowLength);
def emah = ExpAverage(high, highLength);

# Calculations
def long = (emac - emah) >= (emal - emac);
def neut = (emac - emah);
def short = (emal - emac) > ( emac - emah);

# plots
def ch = emac - emah;

def lc = emal - emac;

Plot osc = CH - LC;
osc.assignValueColor( if Osc >= osc[1] then color.Green else Color.Red);
osc.SetLineWeight(2);
AddCloud(Osc,0,Color.Light_Green,Color.Light_Red);
Def Con1 = osc >= 0;
Def Con2 = osc < 0;
Def Con3 = osc > osc [1];
Def Con4 = osc < osc[1];

Plot BullRise = If Con1 and Con3 then osc else 0;
BullRise.SetPaintingStrategy(PaintingStrategy.Histogram);
BullRise.SetDefaultColor(Color.Green);
BullRise.SetLineWeight(3);
Plot BullFall = if Con1 and Con4 then osc else 0;
BullFall.SetPaintingStrategy(PaintingStrategy.Histogram);
BullFall.SetDefaultColor(Color.Dark_Green);
BullFall.SetLineWeight(3);
Plot BearFall = if Con2 and Con4 then osc else 0;
BearFall.SetPaintingStrategy(PaintingStrategy.Histogram);
BearFall.SetDefaultColor(Color.Dark_Red);
BearFall.SetLineWeight(3);
Plot BearRise = if Con2 and Con3 then osc else 0;
BearRise.SetPaintingStrategy(PaintingStrategy.Histogram);
BearRise.SetDefaultColor(Color.Red);
BEarRise.SetLineWeight(3);

Plot UZ = Average(osc,34) + (1.3185*StDev(osc,34));
UZ.SetPaintingStrategy(PaintingStrategy.Line);
UZ.SetLineWeight(2);
UZ.SetDefaultColor(Color.Yellow);
Plot LZ = Average(osc,34) - (1.3185*StDev(osc,34));
LZ.SetPaintingStrategy(PaintingStrategy.Line);
LZ.SetLineWeight(2);
LZ.SetDefaultColor(Color.Yellow);

#ARROWS
plot ArrowDown = if arrows and (osc Crosses below osc[1]) then osc else double.nan;
ArrowDown.setpaintingStrategy(paintingStrategy.Arrow_Down);
ArrowDown.setDefaultColor(color.Magenta);
ArrowDown.setLineWeight(dotsize);

plot ArrowUp = if arrows and (osc crosses above osc[1]) then osc else double.nan;
ArrowUp.setpaintingStrategy(paintingStrategy.Arrow_Up);
ArrowUp.setDefaultColor(color.Cyan);
ArrowUp.setLineWeight(dotsize);

plot ArrowDown2 = if arrows and (osc Crosses below 0) then 0 else double.nan;
ArrowDown2.setpaintingStrategy(paintingStrategy.Arrow_Down);
ArrowDown2.setDefaultColor(color.Red);
ArrowDown2.setLineWeight(dotsize);

plot ArrowUp2 = if arrows and (osc crosses above 0 ) then 0 else double.nan;
ArrowUp2.setpaintingStrategy(paintingStrategy.Arrow_Up);
ArrowUp2.setDefaultColor(color.Blue);
ArrowUp2.setLineWeight(dotsize);

plot ArrowDown3 = if arrows and (osc Crosses below UZ) then UZ else double.nan;
ArrowDown3.setpaintingStrategy(paintingStrategy.Arrow_Down);
ArrowDown3.setDefaultColor(color.Yellow);
ArrowDown3.setLineWeight(dotsize);

plot ArrowUp3 = if arrows and (osc crosses above LZ ) then LZ else double.nan;
ArrowUp3.setpaintingStrategy(paintingStrategy.Arrow_Up);
ArrowUp3.setDefaultColor(color.Yellow);
ArrowUp3.setLineWeight(dotsize);

assignpriceColor(if long and PaintBars then color.Green else if short and PaintBars then color.RED else color.YELLOW);
 
Here is a binary version that looks over 6 lengths of oscillators, it also has the ability to color bars depending on the line that you set in the APC input
Code:
declare lower;
input Dotsize =3;
input APC = 0;
def emac = ExpAverage(close, 3);
def emal = ExpAverage(low, 5);
def emah = ExpAverage(high, 8);
def Bemac = ExpAverage(close, 5);
def Bemal = ExpAverage(low, 8);
def Bemah = ExpAverage(high, 13);
def Cemac = ExpAverage(close, 8);
def Cemal = ExpAverage(low, 13);
def Cemah = ExpAverage(high, 21);
def Demac = ExpAverage(close, 13);
def Demal = ExpAverage(low, 21);
def Demah = ExpAverage(high, 34);
def Eemac = ExpAverage(close, 21);
def Eemal = ExpAverage(low, 34);
def Eemah = ExpAverage(high, 55);
def Femac = ExpAverage(close, 34);
def Femal = ExpAverage(low, 55);
def Femah = ExpAverage(high, 89);
def ch = emac - emah;
def lc = emal - emac;
def Bch = Bemac - Bemah;
def Blc = Bemal - Bemac;
def Cch = Cemac - Cemah;
def Clc = Cemal - Cemac;
def Dch = Demac - Demah;
def Dlc = Demal - Demac;
def Ech = Eemac - Eemah;
def Elc = Eemal - Eemac;
def Fch = Femac - Femah;
def Flc = Femal - Femac;

def osc = CH - LC;
def Bosc = BCH - BLC;
def Cosc = CCH - CLC;
def Dosc = DCH - DLC;
def Eosc = ECH - ELC;
def Fosc = FCH - FLC;
Def Con1 = osc >= 0;
Def Con2 = osc < 0;
Def Con3 = osc > osc [1];
Def Con4 = osc < osc[1];
Def BCon1 = Bosc >= 0;
Def BCon2 = Bosc < 0;
Def BCon3 = Bosc > Bosc [1];
Def BCon4 = Bosc < Bosc[1];
Def CCon1 = Cosc >= 0;
Def CCon2 = Cosc < 0;
Def CCon3 = Cosc > Cosc [1];
Def CCon4 = Cosc < Cosc[1];
Def DCon1 = Dosc >= 0;
Def DCon2 = Dosc < 0;
Def DCon3 = Dosc > Dosc [1];
Def DCon4 = Dosc < Dosc[1];
Def ECon1 = Eosc >= 0;
Def ECon2 = Eosc < 0;
Def ECon3 = Eosc > Eosc [1];
Def ECon4 = Eosc < Eosc[1];
Def FCon1 = Fosc >= 0;
Def FCon2 = Fosc < 0;
Def FCon3 = Fosc > Fosc [1];
Def FCon4 = Fosc < Fosc[1];
Def BullRise = If Con1 and Con3 then 1 else 0;
Def BullFall = if Con1 and Con4 then 1 else 0;
Def BearFall = if Con2 and Con4 then 1 else 0;
Def BearRise = if Con2 and Con3 then 1 else 0;
Def BBullRise = If BCon1 and BCon3 then 1 else 0;
Def BBullFall = if BCon1 and BCon4 then 1 else 0;
Def BBearFall = if BCon2 and BCon4 then 1 else 0;
Def BBearRise = if BCon2 and BCon3 then 1 else 0;
Def CBullRise = If CCon1 and CCon3 then 1 else 0;
Def CBullFall = if CCon1 and CCon4 then 1 else 0;
Def CBearFall = if CCon2 and CCon4 then 1 else 0;
Def CBearRise = if CCon2 and CCon3 then 1 else 0;
Def DBullRise = If DCon1 and DCon3 then 1 else 0;
Def DBullFall = if DCon1 and DCon4 then 1 else 0;
Def DBearFall = if DCon2 and DCon4 then 1 else 0;
Def DBearRise = if DCon2 and DCon3 then 1 else 0;
Def EBullRise = If ECon1 and ECon3 then 1 else 0;
Def EBullFall = if ECon1 and ECon4 then 1 else 0;
Def EBearFall = if ECon2 and ECon4 then 1 else 0;
Def EBearRise = if ECon2 and ECon3 then 1 else 0;
Def FBullRise = If FCon1 and FCon3 then 1 else 0;
Def FBullFall = if FCon1 and FCon4 then 1 else 0;
Def FBearFall = if FCon2 and FCon4 then 1 else 0;
Def FBearRise = if FCon2 and FCon3 then 1 else 0;

plot A1_Dot = if IsNaN(Close) then Double.NaN else 1;
A1_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A1_Dot.SetLineWeight(DotSize);
A1_Dot.AssignValueColor(if BULLRISE ==1 then Color.GREEN else if BULLFALL ==1 then Color.Dark_GREEN else if BearRISE ==1 then Color.red else if Bearfall ==1 then Color.Dark_Red else Color.Gray);
plot A2_Dot = if IsNaN(Close) then Double.NaN else 2;
A2_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A2_Dot.SetLineWeight(DotSize);
A2_Dot.AssignValueColor(if BBULLRISE ==1 then Color.GREEN else if BBULLFALL ==1 then Color.Dark_GREEN else if BBearRISE ==1 then Color.red else if BBearfall ==1 then Color.Dark_Red else Color.Gray);
plot A3_Dot = if IsNaN(Close) then Double.NaN else 3;
A3_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A3_Dot.SetLineWeight(DotSize);
A3_Dot.AssignValueColor(if CBULLRISE ==1 then Color.GREEN else if CBULLFALL ==1 then Color.Dark_GREEN else if CBearRISE ==1 then Color.red else if CBearfall ==1 then Color.Dark_Red else Color.Gray);
plot A4_Dot = if IsNaN(Close) then Double.NaN else 4;
A4_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A4_Dot.SetLineWeight(DotSize);
A4_Dot.AssignValueColor(if DBULLRISE ==1 then Color.GREEN else if DBULLFALL ==1 then Color.Dark_GREEN else if DBearRISE ==1 then Color.red else if DBearfall ==1 then Color.Dark_Red else Color.Gray);
plot A5_Dot = if IsNaN(Close) then Double.NaN else 5;
A5_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A5_Dot.SetLineWeight(DotSize);
A5_Dot.AssignValueColor(if EBULLRISE ==1 then Color.GREEN else if EBULLFALL ==1 then Color.Dark_GREEN else if EBearRISE ==1 then Color.red else if EBearfall ==1 then Color.Dark_Red else Color.Gray);
plot A6_Dot = if IsNaN(Close) then Double.NaN else 6;
A6_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A6_Dot.SetLineWeight(DotSize);
A6_Dot.AssignValueColor(if FBULLRISE ==1 then Color.GREEN else if FBULLFALL ==1 then Color.Dark_GREEN else if FBearRISE ==1 then Color.red else if FBearfall ==1 then Color.Dark_Red else Color.Gray);

AssignPriceColor(if APC ==1 and BULLRISE ==1 then Color.GREEN else if APC ==1 and BULLFALL ==1 then Color.Dark_GREEN else if APC ==1 and BearRISE ==1 then Color.red else if APC ==1 and Bearfall ==1 then Color.Dark_Red else if APC ==2 and BBULLRISE ==1 then Color.GREEN else if APC ==2 and BBULLFALL ==1 then Color.Dark_GREEN else if APC ==2 and BBearRISE ==1 then Color.red else if APC ==2 and BBearfall ==1 then Color.Dark_Red else if APC ==3 and CBULLRISE ==1 then Color.GREEN else if APC ==3 and CBULLFALL ==1 then Color.Dark_GREEN else if APC ==3 and CBearRISE ==1 then Color.red else if APC ==3 and CBearfall ==1 then Color.Dark_Red else if APC ==4 and DBULLRISE ==1 then Color.GREEN else if APC ==4 and DBULLFALL ==1 then Color.Dark_GREEN else if APC ==4 and DBearRISE ==1 then Color.red else if APC ==4 and DBearfall ==1 then Color.Dark_Red else if APC ==5 and EBULLRISE ==1 then Color.GREEN else if APC ==5 and EBULLFALL ==1 then Color.Dark_GREEN else if APC ==5 and EBearRISE ==1 then Color.red else if APC ==5 and EBearfall ==1 then Color.Dark_Red else if APC ==6 and FBULLRISE ==1 then Color.GREEN else if APC ==6 and FBULLFALL ==1 then Color.Dark_GREEN else if APC ==6 and FBearRISE ==1 then Color.red else if APC ==6 and FBearfall ==1 then Color.Dark_Red else Color.Current);

NJaYwur.png
 
here is the 2 pole Butterworth filter version

Code:
declare lower;
input Dotsize =3;
input APC = 0;
def a1AC3 = exp(-1.414 * 3.14159 / 3);
def b1AC3 = 2 * a1AC3 * Cos(1.414 * 3.14159 / 3);
def coef2AC3 =b1AC3;
def coef3AC3 = -a1AC3 * a1AC3;
def coef1AC3 = (1 – b1AC3 + a1AC3 * a1AC3) / 4;
rec EMAC3 = if barNumber() < 3 then Close else coef1AC3 * (Close + 2 * Close[1] + Close[2]) + coef2AC3 * EMAC3[1] + coef3AC3 * EMAC3[2];
def emac = EMAC3;
def a1AL5 = exp(-1.414 * 3.14159 / 5);
def b1AL5 = 2 * a1AL5 * Cos(1.414 * 3.14159 / 5);
def coef2AL5 =b1AL5;
def coef3AL5 = -a1AL5 * a1AL5;
def coef1AL5 = (1 – b1AL5 + a1AL5 * a1AL5) / 4;
rec EMAL5 = if barNumber() < 3 then Low else coef1AL5 * (Low + 2 * Low[1] + LOW[2]) + coef2AL5 * EMAL5[1] + coef3AL5 * EMAL5[2];
def emal = EMAL5;
def a1AH8 = exp(-1.414 * 3.14159 / 8);
def b1AH8 = 2 * a1AH8 * Cos(1.414 * 3.14159 / 8);
def coef2AH8 =b1AH8;
def coef3AH8 = -a1AH8 * a1AH8;
def coef1AH8 = (1 – b1AH8 + a1AH8 * a1AH8) / 4;
rec EMAH8 = if barNumber() < 3 then High else coef1AH8 * (High + 2 * High[1] + HIGH[2]) + coef2AH8 * EMAH8[1] + coef3AH8 * EMAH8[2];
def emah = EMAH8;
def a1AC5 = exp(-1.414 * 3.14159 / 5);
def b1AC5 = 2 * a1AC5 * Cos(1.414 * 3.14159 / 5);
def coef2AC5 =b1AC5;
def coef3AC5 = -a1AC5 * a1AC5;
def coef1AC5 = (1 – b1AC5 + a1AC5 * a1AC5) / 4;
rec EMAC5 = if barNumber() < 3 then Close else coef1AC5 * (Close + 2 * Close[1] + Close[2]) + coef2AC5 * EMAC5[1] + coef3AC5 * EMAC5[2];
def Bemac = EMAC5;
def a1AL8 = exp(-1.414 * 3.14159 / 8);
def b1AL8 = 2 * a1AL8 * Cos(1.414 * 3.14159 / 8);
def coef2AL8 =b1AL8;
def coef3AL8 = -a1AL8 * a1AL8;
def coef1AL8 = (1 – b1AL8 + a1AL8 * a1AL8) / 4;
rec EMAL8 = if barNumber() < 3 then Low else coef1AL8 * (Low + 2 * Low[1] + Low[2]) + coef2AL8 * EMAL8[1] + coef3AL8 * EMAL8[2];
def Bemal = EMAL8;
def a1AH13 = exp(-1.414 * 3.14159 / 13);
def b1AH13 = 2 * a1AH13 * Cos(1.414 * 3.14159 / 13);
def coef2AH13 =b1AH13;
def coef3AH13 = -a1AH13 * a1AH13;
def coef1AH13 = (1 – b1AH13 + a1AH13 * a1AH13) / 4;
rec EMAH13 = if barNumber() < 3 then High else coef1AH13 * (High + 2 * High[1] + High[2]) + coef2AH13 * EMAH13[1] + coef3AH13 * EMAH13[2];
def Bemah = EMAH13;
def a1AC8 = exp(-1.414 * 3.14159 / 8);
def b1AC8 = 2 * a1AC8 * Cos(1.414 * 3.14159 / 8);
def coef2AC8 =b1AC8;
def coef3AC8 = -a1AC8 * a1AC8;
def coef1AC8 = (1 – b1AC8 + a1AC8 * a1AC8) / 4;
rec EMAC8 = if barNumber() < 3 then Close else coef1AC8 * (Close + 2 * Close[1] + Close[2]) + coef2AC8 * EMAC8[1] + coef3AC8 * EMAC8[2];


def Cemac = EMAC8;
def a1AL13 = exp(-1.414 * 3.14159 / 13);
def b1AL13 = 2 * a1AL13 * Cos(1.414 * 3.14159 / 13);
def coef2AL13 =b1AL13;
def coef3AL13= -a1AL13 * a1AL13;
def coef1AL13 = (1 – b1AL13 + a1AL13 * a1AL13) / 4;
rec EMAL13 = if barNumber() < 3 then Low else coef1AL13 * (Low + 2 * Low[1] + Low[2]) + coef2AL13 * EMAL13[1] + coef3AL13* EMAL13[2];
def Cemal = EMAL13;
def a1AH21 = exp(-1.414 * 3.14159 / 21);
def b1AH21 = 2 * a1AH21 * Cos(1.414 * 3.14159 / 21);
def coef2AH21 =b1AH21;
def coef3AH21 = -a1AH21 * a1AH21;
def coef1AH21 = (1 – b1AH21 + a1AH21 * a1AH21) / 4;
rec EMAH21 = if barNumber() < 3 then High else coef1AH21 * (High + 2 * High[1] + High[2]) + coef2AH21 * EMAH21[1] + coef3AH21 * EMAH21[2];
def Cemah = EMAH21;
def a1AC13 = exp(-1.414 * 3.14159 / 13);
def b1AC13 = 2 * a1AC13 * Cos(1.414 * 3.14159 / 13);
def coef2AC13 =b1AC13;
def coef3AC13 = -a1AC13 * a1AC13;
def coef1AC13 = (1 – b1AC13 + a1AC13 * a1AC13) / 4;
rec EMAC13= if barNumber() < 3 then Close else coef1AC13 * (Close + 2 * Close[1] + Close[2]) + coef2AC13 * EMAC13[1] + coef3AC13 * EMAC13[2];
def Demac = EMAC13;
def a1AL21 = exp(-1.414 * 3.14159 / 21);
def b1AL21 = 2 * a1AL21 * Cos(1.414 * 3.14159 / 21);
def coef2AL21 =b1AL21;
def coef3AL21= -a1AL21 * a1AL21;
def coef1AL21 = (1 – b1AL21 + a1AL21 * a1AL21) / 4;
rec EMAL21 = if barNumber() < 3 then Low else coef1AL21 * (Low + 2 * Low[1] + Low[2]) + coef2AL21 * EMAL21[1] + coef3AL21* EMAL21[2];
def Demal = EMAL21;
def a1AH34 = exp(-1.414 * 3.14159 / 34);
def b1AH34 = 2 * a1AH34 * Cos(1.414 * 3.14159 / 34);
def coef2AH34 =b1AH34;
def coef3AH34 = -a1AH34 * a1AH34;
def coef1AH34 = (1 – b1AH34 + a1AH34 * a1AH34) / 4;
rec EMAH34 = if barNumber() < 3 then High else coef1AH34 * (High + 2 * High[1] + High[2]) + coef2AH34 * EMAH34[1] + coef3AH34 * EMAH34[2];
def Demah = EMAH34;
def a1AC21 = exp(-1.414 * 3.14159 / 21);
def b1AC21 = 2 * a1AC21 * Cos(1.414 * 3.14159 / 21);
def coef2AC21 =b1AC21;
def coef3AC21 = -a1AC21 * a1AC21;
def coef1AC21 = (1 – b1AC21 + a1AC21 * a1AC21) / 4;
rec EMAC21= if barNumber() < 3 then Close else coef1AC21 * (Close + 2 * Close[1] + Close[2]) + coef2AC21 * EMAC21[1] + coef3AC21 * EMAC21[2];
def Eemac = EMAC21;
def a1AL34 = exp(-1.414 * 3.14159 / 34);
def b1AL34 = 2 * a1AL34 * Cos(1.414 * 3.14159 / 34);
def coef2AL34 =b1AL34;
def coef3AL34= -a1AL34 * a1AL34;
def coef1AL34 = (1 – b1AL34 + a1AL34 * a1AL34) / 4;
rec EMAL34 = if barNumber() < 3 then Low else coef1AL34 * (Low + 2 * Low[1] + Low[2]) + coef2AL34 * EMAL34[1] + coef3AL34* EMAL34[2];
def Eemal = EMAL34;
def a1AH55 = exp(-1.414 * 3.14159 / 55);
def b1AH55 = 2 * a1AH55 * Cos(1.414 * 3.14159 / 55);
def coef2AH55 =b1AH55;
def coef3AH55 = -a1AH55 * a1AH55;
def coef1AH55 = (1 – b1AH55 + a1AH55 * a1AH55) / 4;
rec EMAH55 = if barNumber() < 3 then High else coef1AH55 * (High + 2 * High[1] + High[2]) + coef2AH55 * EMAH55[1] + coef3AH55 * EMAH55[2];
def Eemah = EMAH55;
def a1AC34 = exp(-1.414 * 3.14159 / 34);
def b1AC34 = 2 * a1AC34 * Cos(1.414 * 3.14159 / 34);
def coef2AC34 =b1AC34;
def coef3AC34 = -a1AC34 * a1AC34;
def coef1AC34 = (1 – b1AC34 + a1AC34 * a1AC34) / 4;
rec EMAC34= if barNumber() < 3 then Close else coef1AC34 * (Close + 2 * Close[1] + Close[2]) + coef2AC34 * EMAC34[1] + coef3AC34 * EMAC34[2];
def Femac = EMAC34;
def a1AL55 = exp(-1.414 * 3.14159 / 55);
def b1AL55 = 2 * a1AL55 * Cos(1.414 * 3.14159 / 55);
def coef2AL55 =b1AL55;
def coef3AL55= -a1AL55 * a1AL55;
def coef1AL55 = (1 – b1AL55 + a1AL55 * a1AL55) / 4;
rec EMAL55 = if barNumber() < 3 then Low else coef1AL55 * (Low + 2 * Low[1] + Low[2]) + coef2AL55 * EMAL55[1] + coef3AL55* EMAL55[2];
def Femal = EMAL55;
def a1AH89 = exp(-1.414 * 3.14159 / 89);
def b1AH89 = 2 * a1AH89 * Cos(1.414 * 3.14159 / 89);
def coef2AH89 =b1AH89;
def coef3AH89 = -a1AH89 * a1AH89;
def coef1AH89 = (1 – b1AH89 + a1AH89 * a1AH89) / 4;
rec EMAH89 = if barNumber() < 3 then High else coef1AH89 * (High + 2 * High[1] + High[2]) + coef2AH89* EMAH89[1] + coef3AH89 * EMAH89[2];

def Femah = EMAH89;
def ch = emac - emah;
def lc = emal - emac;
def Bch = Bemac - Bemah;
def Blc = Bemal - Bemac;
def Cch = Cemac - Cemah;
def Clc = Cemal - Cemac;
def Dch = Demac - Demah;
def Dlc = Demal - Demac;
def Ech = Eemac - Eemah;
def Elc = Eemal - Eemac;
def Fch = Femac - Femah;
def Flc = Femal - Femac;

def osc = CH - LC;
def Bosc = BCH - BLC;
def Cosc = CCH - CLC;
def Dosc = DCH - DLC;
def Eosc = ECH - ELC;
def Fosc = FCH - FLC;
Def Con1 = osc >= 0;
Def Con2 = osc < 0;
Def Con3 = osc > osc [1];
Def Con4 = osc < osc[1];
Def BCon1 = Bosc >= 0;
Def BCon2 = Bosc < 0;
Def BCon3 = Bosc > Bosc [1];
Def BCon4 = Bosc < Bosc[1];
Def CCon1 = Cosc >= 0;
Def CCon2 = Cosc < 0;
Def CCon3 = Cosc > Cosc [1];
Def CCon4 = Cosc < Cosc[1];
Def DCon1 = Dosc >= 0;
Def DCon2 = Dosc < 0;
Def DCon3 = Dosc > Dosc [1];
Def DCon4 = Dosc < Dosc[1];
Def ECon1 = Eosc >= 0;
Def ECon2 = Eosc < 0;
Def ECon3 = Eosc > Eosc [1];
Def ECon4 = Eosc < Eosc[1];
Def FCon1 = Fosc >= 0;
Def FCon2 = Fosc < 0;
Def FCon3 = Fosc > Fosc [1];
Def FCon4 = Fosc < Fosc[1];
Def BullRise = If Con1 and Con3 then 1 else 0;
Def BullFall = if Con1 and Con4 then 1 else 0;
Def BearFall = if Con2 and Con4 then 1 else 0;
Def BearRise = if Con2 and Con3 then 1 else 0;
Def BBullRise = If BCon1 and BCon3 then 1 else 0;
Def BBullFall = if BCon1 and BCon4 then 1 else 0;
Def BBearFall = if BCon2 and BCon4 then 1 else 0;
Def BBearRise = if BCon2 and BCon3 then 1 else 0;
Def CBullRise = If CCon1 and CCon3 then 1 else 0;
Def CBullFall = if CCon1 and CCon4 then 1 else 0;
Def CBearFall = if CCon2 and CCon4 then 1 else 0;
Def CBearRise = if CCon2 and CCon3 then 1 else 0;
Def DBullRise = If DCon1 and DCon3 then 1 else 0;
Def DBullFall = if DCon1 and DCon4 then 1 else 0;
Def DBearFall = if DCon2 and DCon4 then 1 else 0;
Def DBearRise = if DCon2 and DCon3 then 1 else 0;
Def EBullRise = If ECon1 and ECon3 then 1 else 0;
Def EBullFall = if ECon1 and ECon4 then 1 else 0;
Def EBearFall = if ECon2 and ECon4 then 1 else 0;
Def EBearRise = if ECon2 and ECon3 then 1 else 0;
Def FBullRise = If FCon1 and FCon3 then 1 else 0;
Def FBullFall = if FCon1 and FCon4 then 1 else 0;
Def FBearFall = if FCon2 and FCon4 then 1 else 0;
Def FBearRise = if FCon2 and FCon3 then 1 else 0;

plot A1_Dot = if IsNaN(Close) then Double.NaN else 1;
A1_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A1_Dot.SetLineWeight(DotSize);
A1_Dot.AssignValueColor(if BULLRISE ==1 then Color.GREEN else if BULLFALL ==1 then Color.Dark_GREEN else if BearRISE ==1 then Color.red else if Bearfall ==1 then Color.Dark_Red else Color.Gray);
plot A2_Dot = if IsNaN(Close) then Double.NaN else 2;
A2_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A2_Dot.SetLineWeight(DotSize);
A2_Dot.AssignValueColor(if BBULLRISE ==1 then Color.GREEN else if BBULLFALL ==1 then Color.Dark_GREEN else if BBearRISE ==1 then Color.red else if BBearfall ==1 then Color.Dark_Red else Color.Gray);
plot A3_Dot = if IsNaN(Close) then Double.NaN else 3;
A3_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A3_Dot.SetLineWeight(DotSize);
A3_Dot.AssignValueColor(if CBULLRISE ==1 then Color.GREEN else if CBULLFALL ==1 then Color.Dark_GREEN else if CBearRISE ==1 then Color.red else if CBearfall ==1 then Color.Dark_Red else Color.Gray);
plot A4_Dot = if IsNaN(Close) then Double.NaN else 4;
A4_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A4_Dot.SetLineWeight(DotSize);
A4_Dot.AssignValueColor(if DBULLRISE ==1 then Color.GREEN else if DBULLFALL ==1 then Color.Dark_GREEN else if DBearRISE ==1 then Color.red else if DBearfall ==1 then Color.Dark_Red else Color.Gray);
plot A5_Dot = if IsNaN(Close) then Double.NaN else 5;
A5_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A5_Dot.SetLineWeight(DotSize);
A5_Dot.AssignValueColor(if EBULLRISE ==1 then Color.GREEN else if EBULLFALL ==1 then Color.Dark_GREEN else if EBearRISE ==1 then Color.red else if EBearfall ==1 then Color.Dark_Red else Color.Gray);
plot A6_Dot = if IsNaN(Close) then Double.NaN else 6;
A6_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A6_Dot.SetLineWeight(DotSize);
A6_Dot.AssignValueColor(if FBULLRISE ==1 then Color.GREEN else if FBULLFALL ==1 then Color.Dark_GREEN else if FBearRISE ==1 then Color.red else if FBearfall ==1 then Color.Dark_Red else Color.Gray);

AssignPriceColor(if APC ==1 and BULLRISE ==1 then Color.GREEN else if APC ==1 and BULLFALL ==1 then Color.Dark_GREEN else if APC ==1 and BearRISE ==1 then Color.red else if APC ==1 and Bearfall ==1 then Color.Dark_Red else if APC ==2 and BBULLRISE ==1 then Color.GREEN else if APC ==2 and BBULLFALL ==1 then Color.Dark_GREEN else if APC ==2 and BBearRISE ==1 then Color.red else if APC ==2 and BBearfall ==1 then Color.Dark_Red else if APC ==3 and CBULLRISE ==1 then Color.GREEN else if APC ==3 and CBULLFALL ==1 then Color.Dark_GREEN else if APC ==3 and CBearRISE ==1 then Color.red else if APC ==3 and CBearfall ==1 then Color.Dark_Red else if APC ==4 and DBULLRISE ==1 then Color.GREEN else if APC ==4 and DBULLFALL ==1 then Color.Dark_GREEN else if APC ==4 and DBearRISE ==1 then Color.red else if APC ==4 and DBearfall ==1 then Color.Dark_Red else if APC ==5 and EBULLRISE ==1 then Color.GREEN else if APC ==5 and EBULLFALL ==1 then Color.Dark_GREEN else if APC ==5 and EBearRISE ==1 then Color.red else if APC ==5 and EBearfall ==1 then Color.Dark_Red else if APC ==6 and FBULLRISE ==1 then Color.GREEN else if APC ==6 and FBULLFALL ==1 then Color.Dark_GREEN else if APC ==6 and FBearRISE ==1 then Color.red else if APC ==6 and FBearfall ==1 then Color.Dark_Red else Color.Current);
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
531 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top