Trend Following MAs 3D For ThinkOrSwim

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

Appreciat who can help me make it into thinkscript, original links: https://www.tradingview.com/script/Vb8jW3I2-Trend-Following-MAs-3D/



study("Trend Following MAs 3D", precision=0)
matype= input('EMA', title = "MA Type", options =['EMA', 'SMA', 'RMA', 'WMA', 'VWMA'])
ulinreg = input(true, title = "Use Linear Regression")
linprd = input(10, title = "Linear Regression Period", minval = 2)
getma(len)=>
_ret = matype == 'EMA' ? ema(close, len) : matype == 'RMA' ? rma(close, len) : matype == 'VWMA' ? vwma(close, len) : matype == 'WMA' ? wma(close, len) : sma(close, len)
_ret := ulinreg ? linreg(_ret, linprd, 0) : _ret
_ret
p1 = getma(5) - getma(10)
p2 = p1 + getma(10) - getma(15)
p3 = p2 + getma(15) - getma(20)
p4 = p3 + getma(20) - getma(25)
p5 = p4 + getma(25) - getma(30)
p6 = p5 + getma(30) - getma(35)
p7 = p6 + getma(35) - getma(40)
p8 = p7 + getma(40) - getma(45)
p9 = p8 + getma(45) - getma(50)
p10 = p9 + getma(50) - getma(55)
p11 = p10 + getma(55) - getma(60)
p12 = p11 + getma(60) - getma(65)
p13 = p12 + getma(65) - getma(70)
p14 = p13 + getma(70) - getma(75)
p15 = p14 + getma(75) - getma(80)
p16 = p15 + getma(80) - getma(85)
p17 = p16 + getma(85) - getma(90)
p18 = p17 + getma(90) - getma(95)
p19 = p18 + getma(95) - getma(100)
l1 = plot(p1, color = na)
l2 = plot(p2, color = na)
l3 = plot(p3, color = na)
l4 = plot(p4, color = na)
l5 = plot(p5, color = na)
l6 = plot(p6, color = na)
l7 = plot(p7, color = na)
l8 = plot(p8, color = na)
l9 = plot(p9, color = na)
l10 = plot(p10, color = na)
l11 = plot(p11, color = na)
l12 = plot(p12, color = na)
l13 = plot(p13, color = na)
l14 = plot(p14, color = na)
l15 = plot(p15, color = na)
l16 = plot(p16, color = na)
l17 = plot(p17, color = na)
l18 = plot(p18, color = na)
l19 = plot(p19, color = na)
getwidth(a, b)=>
t = abs(a - b)
w = t * 10 / (highest(t, 200) - lowest(t, 200))
w := max(w, 4)
m = p1 > 0 ? p1 > nz(p1[1]) ? w > nz(w[1]) ? w + 1 : w - 1 : w > nz(w[1]) ? w - 3 : w - 2 : p1 < nz(p1[1]) ? w > nz(w[1]) ? -(w + 1) : -(w - 1) : w > nz(w[1]) ? -(w - 3) : -(w - 2)
m
getcolmult(trend)=>
_ret = trend >= 10.0 ? #00FF00ff : trend >= 9.0 ? #00FF00ef : trend >= 8.0 ? #00FF00df : trend >= 7.0 ? #00FF00cf : trend >= 6.0 ? #00FF00bf :
trend >= 5.0 ? #00FF00af : trend >= 4.0 ? #00FF009f : trend >= 3.0 ? #00FF008f : trend >= 2.0 ? #00FF007f : trend >= 1.0 ? #00FF006f :
trend <= -10.0 ? #FF0000ff : trend <= -9.0 ? #FF0000ef : trend <= -8.0 ? #FF0000df : trend <= -7.0 ? #FF0000cf : trend <= -6.0 ? #FF0000bf :
trend <= -5.0 ? #FF0000af : trend <= -4.0 ? #FF00009f : trend <= -3.0 ? #FF00008f : trend <= -2.0 ? #FF00007f : trend <= -1.0 ? #FF00006f :
na
getcol(p1, p2)=>
m = getwidth(p1, p2)

_ret = getcolmult(m)

fill(l18, l19, color = getcol(p18, p19))
fill(l17, l18, color = getcol(p17, p18))
fill(l16, l17, color = getcol(p16, p17))
fill(l15, l16, color = getcol(p15, p16))
fill(l14, l15, color = getcol(p14, p15))
fill(l13, l14, color = getcol(p13, p14))
fill(l12, l13, color = getcol(p12, p13))
fill(l11, l12, color = getcol(p11, p12))
fill(l10, l11, color = getcol(p10, p11))
fill(l9, l10, color = getcol(p9, p10))
fill(l8, l9, color = getcol(p8, p9))
fill(l7, l8, color = getcol(p7, p8))
fill(l6, l7, color = getcol(p6, p7))
fill(l5, l6, color = getcol(p5, p6))
fill(l4, l5, color = getcol(p4, p5))
fill(l3, l4, color = getcol(p3, p4))
fill(l2, l3, color = getcol(p2, p3))
fill(l1, l2, color = getcol(p1, p2))
check this

CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © LonesomeTheBlue
#study("Trend Following MAs 3D", precision=0)
# Converted by Sam4Cok@Samer800      - 08/2023
declare lower;

input maType = AverageType.EXPONENTIAL;
input source = close;
input UseLinearRegression = yes;      # "Use Linear Regression"
input LinearRegressionPeriod = 10;    # "Linear Regression Period"

def na = Double.NaN;

#-- Color
DefineGlobalColor("10", CreateColor(0, 255, 0));
DefineGlobalColor("9", CreateColor(0, 235, 0));
DefineGlobalColor("8", CreateColor(0, 216, 0));
DefineGlobalColor("7", CreateColor(0, 196, 0));
DefineGlobalColor("6", CreateColor(0, 177, 0));
DefineGlobalColor("5", CreateColor(0, 157, 0));
DefineGlobalColor("4", CreateColor(0, 137, 0));
DefineGlobalColor("3", CreateColor(0, 118, 0));
DefineGlobalColor("2", CreateColor(0, 98, 0));
DefineGlobalColor("1", CreateColor(0, 78, 0));
DefineGlobalColor("-10", CreateColor(255, 0, 0));
DefineGlobalColor("-9", CreateColor(235, 0, 0));
DefineGlobalColor("-8", CreateColor(216, 0, 0));
DefineGlobalColor("-7", CreateColor(196, 0, 0));
DefineGlobalColor("-6", CreateColor(177, 0, 0));
DefineGlobalColor("-5", CreateColor(157, 0, 0));
DefineGlobalColor("-4", CreateColor(137, 0, 0));
DefineGlobalColor("-3", CreateColor(118, 0, 0));
DefineGlobalColor("-2", CreateColor(98, 0, 0));
DefineGlobalColor("-1", CreateColor(78, 0, 0));
#// ] -------------- FUNCTIONS : Moving Avg ------------------ [

script getma {
    input length = 14;
    input source = close;
    input type = AverageType.EXPONENTIAL;
    input ulinreg = yes;
    input linprd = 10;
    def v = volume;
    def VWMA = Average(source * v, length) / Average(v, length);
    def multiMa = MovingAverage(type, source, length);
    def lin = Inertia(multiMa, linprd);
    plot return = if ulinreg then lin else multiMa;
}

def getma5 = getma(5, source, maType, UseLinearRegression, LinearRegressionPeriod);
def getma10 = getma(10, source, maType, UseLinearRegression, LinearRegressionPeriod);
def getma15 = getma(15, source, maType, UseLinearRegression, LinearRegressionPeriod);
def getma20 = getma(20, source, maType, UseLinearRegression, LinearRegressionPeriod);
def getma25 = getma(25, source, maType, UseLinearRegression, LinearRegressionPeriod);
def getma30 = getma(30, source, maType, UseLinearRegression, LinearRegressionPeriod);
def getma35 = getma(35, source, maType, UseLinearRegression, LinearRegressionPeriod);
def getma40 = getma(40, source, maType, UseLinearRegression, LinearRegressionPeriod);
def getma45 = getma(45, source, maType, UseLinearRegression, LinearRegressionPeriod);
def getma50 = getma(50, source, maType, UseLinearRegression, LinearRegressionPeriod);
def getma55 = getma(55, source, maType, UseLinearRegression, LinearRegressionPeriod);
def getma60 = getma(60, source, maType, UseLinearRegression, LinearRegressionPeriod);
def getma65 = getma(65, source, maType, UseLinearRegression, LinearRegressionPeriod);
def getma70 = getma(70, source, maType, UseLinearRegression, LinearRegressionPeriod);
def getma75 = getma(75, source, maType, UseLinearRegression, LinearRegressionPeriod);
def getma80 = getma(80, source, maType, UseLinearRegression, LinearRegressionPeriod);
def getma85 = getma(85, source, maType, UseLinearRegression, LinearRegressionPeriod);
def getma90 = getma(90, source, maType, UseLinearRegression, LinearRegressionPeriod);
def getma95 = getma(95, source, maType, UseLinearRegression, LinearRegressionPeriod);
def getma100 = getma(100, source, maType, UseLinearRegression, LinearRegressionPeriod);
def getma105 = getma(105, source, maType, UseLinearRegression, LinearRegressionPeriod);

def p1 = getma5 - getma10;
def p2 = p1 + getma10 - getma15;
def p3 = p2 + getma15 - getma20;
def p4 = p3 + getma20 - getma25;
def p5 = p4 + getma25 - getma30;
def p6 = p5 + getma30 - getma35;
def p7 = p6 + getma35 - getma40;
def p8 = p7 + getma40 - getma45;
def p9 = p8 + getma45 - getma50;
def p10 = p9 + getma50 - getma55;
def p11 = p10 + getma55 - getma60;
def p12 = p11 + getma60 - getma65;
def p13 = p12 + getma65 - getma70;
def p14 = p13 + getma70 - getma75;
def p15 = p14 + getma75 - getma80;
def p16 = p15 + getma80 - getma85;
def p17 = p16 + getma85 - getma90;
def p18 = p17 + getma90 - getma95;
def p19 = p18 + getma95 - getma100;
def p20 = p19 + getma100 - getma105;

def l1 = p1;
def l2 = p2;
def l3 = p3;
def l4 = p4;
def l5 = p5;
def l6 = p6;
def l7 = p7;
def l8 = p8;
def l9 = p9;
def l10 = p10;
def l11 = p11;
def l12 = p12;
def l13 = p13;
def l14 = p14;
def l15 = p15;
def l16 = p16;
def l17 = p17;
def l18 = p18;
def l19 = p19;
def l20 = p20;

#getwidth(a, b)=>
script getwidth {
    input p1 = close;
    input a = close;
    input b = close;
    def t = AbsValue(a - b);
    def w_ = t * 10 / (Highest(t, 200) - Lowest(t, 200));
    def w = Max(w_, 4);#if !w[1] then w_ else Max(w_, 4);
    def m = if p1 > 0 then if p1 > p1[1] then if w > w[1] then w + 1 else w - 1 else
            if w > w[1] then w - 3 else w - 2 else
            if p1 < p1[1] then if w > w[1] then -(w + 1) else -(w - 1) else
            if w > w[1] then -(w - 3) else -(w - 2);
    plot out = m;
}
#getcolmult(trend)=>
script getcolmult {
    input trend = 0;
    def _ret = if trend >= 10.0 then 10 else if trend >=  9.0 then  9  else if trend >= 8.0 then 8 else
               if trend >= 7.0  then  7 else if trend >=  6.0 then  6  else if trend >= 5.0 then 5 else
               if trend >= 4.0  then  4 else if trend >=  3.0 then  3  else if trend >= 2.0 then 2 else
               if trend >= 1.0  then  1 else if trend <= -10  then -10 else if trend <= -9.0 then -9 else
               if trend <= -8.0 then -8 else if trend <= -7.0 then -7  else if trend <= -6.0 then -6 else
               if trend <= -5.0 then -5 else if trend <= -4.0 then -4  else if trend <= -3.0 then -3 else
               if trend <= -2.0 then -2 else if trend <= -1.0 then -1  else _ret[1];
    plot out = _ret;
}
def m19 = getwidth(p1, p19, p20);
def m18 = getwidth(p1, p18, p19);
def m17 = getwidth(p1, p17, p18);
def m16 = getwidth(p1, p16, p17);
def m15 = getwidth(p1, p15, p16);
def m14 = getwidth(p1, p14, p15);
def m13 = getwidth(p1, p13, p14);
def m12 = getwidth(p1, p12, p13);
def m11 = getwidth(p1, p11, p12);
def m10 = getwidth(p1, p10, p11);
def m9 = getwidth(p1, p9, p10);
def m8 = getwidth(p1, p8, p9);
def m7 = getwidth(p1, p7, p8);
def m6 = getwidth(p1, p6, p7);
def m5 = getwidth(p1, p5, p6);
def m4 = getwidth(p1, p4, p5);
def m3 = getwidth(p1, p3, p4);
def m2 = getwidth(p1, p2, p3);
def m1 = getwidth(p1, p1, p2);

def r01 = getcolmult(m1);
def r02 = getcolmult(m2);
def r03 = getcolmult(m3);
def r04 = getcolmult(m4);
def r05 = getcolmult(m5);
def r06 = getcolmult(m6);
def r07 = getcolmult(m7);
def r08 = getcolmult(m8);
def r09 = getcolmult(m9);
def r010 = getcolmult(m10);
def r011 = getcolmult(m11);
def r012 = getcolmult(m12);
def r013 = getcolmult(m13);
def r014 = getcolmult(m14);
def r015 = getcolmult(m15);
def r016 = getcolmult(m16);
def r017 = getcolmult(m17);
def r018 = getcolmult(m18);
def r019 = getcolmult(m19);

def m01 = r01;
def m02 = r02;
def m03 = r03;
def m04 = r04;
def m05 = r05;
def m06 = r06;
def m07 = r07;
def m08 = r08;
def m09 = r09;
def m010 = r010;
def m011 = r011;
def m012 = r012;
def m013 = r013;
def m014 = r014;
def m015 = r015;
def m016 = r016;
def m017 = r017;
def m018 = r018;
def m019 = r019;

plot l19Line = l19;
plot l18Line = l18;
plot l17Line = l17;
plot l16Line = l16;
plot l15Line = l15;
plot l14Line = l14;
plot l13Line = l13;
plot l12Line = l12;
plot l11Line = l11;
plot l10Line = l10;
plot l9Line = l9;
plot l8Line = l8;
plot l7Line = l7;
plot l6Line = l6;
plot l5Line = l5;
plot l4Line = l4;
plot l3Line = l3;
plot l2Line = l2;
plot l1Line = l1;

l19Line.SetLineWeight(2);
l18Line.SetLineWeight(2);
l17Line.SetLineWeight(2);
l16Line.SetLineWeight(2);
l15Line.SetLineWeight(2);
l14Line.SetLineWeight(2);
l13Line.SetLineWeight(2);
l12Line.SetLineWeight(2);
l11Line.SetLineWeight(2);
l10Line.SetLineWeight(2);
l9Line.SetLineWeight(2);
l8Line.SetLineWeight(2);
l7Line.SetLineWeight(2);
l5Line.SetLineWeight(2);
l4Line.SetLineWeight(2);
l3Line.SetLineWeight(2);
l2Line.SetLineWeight(2);
l1Line.SetLineWeight(2);
l1Line.SetLineWeight(2);

l19Line.AssignValueColor(if m019== 10 then GlobalColor("10") else
                         if m019== 9 then GlobalColor("9") else
                         if m019== 8 then GlobalColor("8") else
                         if m019== 7 then GlobalColor("7") else
                         if m019== 6 then GlobalColor("6") else
                         if m019== 5 then GlobalColor("5") else
                         if m019== 4 then GlobalColor("4") else
                         if m019== 3 then GlobalColor("3") else
                         if m019== 2 then GlobalColor("2") else
                         if m019== 1 then GlobalColor("1") else
                         if m019== -1 then GlobalColor("-1") else
                         if m019== -2 then GlobalColor("-2") else
                         if m019== -3 then GlobalColor("-3") else
                         if m019== -4 then GlobalColor("-4") else
                         if m019== -5 then GlobalColor("-5") else
                         if m019== -6 then GlobalColor("-6") else
                         if m019== -7 then GlobalColor("-7") else
                         if m019== -8 then GlobalColor("-8") else
                         if m019== -9 then GlobalColor("-9") else GlobalColor("-10"));
l18Line.AssignValueColor(if m018== 10 then GlobalColor("10") else
                         if m018== 9 then GlobalColor("9") else
                         if m018== 8 then GlobalColor("8") else
                         if m018== 7 then GlobalColor("7") else
                         if m018== 6 then GlobalColor("6") else
                         if m018== 5 then GlobalColor("5") else
                         if m018== 4 then GlobalColor("4") else
                         if m018== 3 then GlobalColor("3") else
                         if m018== 2 then GlobalColor("2") else
                         if m018== 1 then GlobalColor("1") else
                         if m018== -1 then GlobalColor("-1") else
                         if m018== -2 then GlobalColor("-2") else
                         if m018== -3 then GlobalColor("-3") else
                         if m018== -4 then GlobalColor("-4") else
                         if m018== -5 then GlobalColor("-5") else
                         if m018== -6 then GlobalColor("-6") else
                         if m018== -7 then GlobalColor("-7") else
                         if m018== -8 then GlobalColor("-8") else
                         if m018== -9 then GlobalColor("-9") else GlobalColor("-10"));
l17Line.AssignValueColor(if m017== 10 then GlobalColor("10") else
                         if m017== 9 then GlobalColor("9") else
                         if m017== 8 then GlobalColor("8") else
                         if m017== 7 then GlobalColor("7") else
                         if m017== 6 then GlobalColor("6") else
                         if m017== 5 then GlobalColor("5") else
                         if m017== 4 then GlobalColor("4") else
                         if m017== 3 then GlobalColor("3") else
                         if m017== 2 then GlobalColor("2") else
                         if m017== 1 then GlobalColor("1") else
                         if m017== -1 then GlobalColor("-1") else
                         if m017== -2 then GlobalColor("-2") else
                         if m017== -3 then GlobalColor("-3") else
                         if m017== -4 then GlobalColor("-4") else
                         if m017== -5 then GlobalColor("-5") else
                         if m017== -6 then GlobalColor("-6") else
                         if m017== -7 then GlobalColor("-7") else
                         if m017== -8 then GlobalColor("-8") else
                         if m017== -9 then GlobalColor("-9") else GlobalColor("-10"));
l16Line.AssignValueColor(if m016== 10 then GlobalColor("10") else
                         if m016== 9 then GlobalColor("9") else
                         if m016== 8 then GlobalColor("8") else
                         if m016== 7 then GlobalColor("7") else
                         if m016== 6 then GlobalColor("6") else
                         if m016== 5 then GlobalColor("5") else
                         if m016== 4 then GlobalColor("4") else
                         if m016== 3 then GlobalColor("3") else
                         if m016== 2 then GlobalColor("2") else
                         if m016== 1 then GlobalColor("1") else
                         if m016== -1 then GlobalColor("-1") else
                         if m016== -2 then GlobalColor("-2") else
                         if m016== -3 then GlobalColor("-3") else
                         if m016== -4 then GlobalColor("-4") else
                         if m016== -5 then GlobalColor("-5") else
                         if m016== -6 then GlobalColor("-6") else
                         if m016== -7 then GlobalColor("-7") else
                         if m016== -8 then GlobalColor("-8") else
                         if m016== -9 then GlobalColor("-9") else GlobalColor("-10"));
l15Line.AssignValueColor(if m015== 10 then GlobalColor("10") else
                         if m015== 9 then GlobalColor("9") else
                         if m015== 8 then GlobalColor("8") else
                         if m015== 7 then GlobalColor("7") else
                         if m015== 6 then GlobalColor("6") else
                         if m015== 5 then GlobalColor("5") else
                         if m015== 4 then GlobalColor("4") else
                         if m015== 3 then GlobalColor("3") else
                         if m015== 2 then GlobalColor("2") else
                         if m015== 1 then GlobalColor("1") else
                         if m015== -1 then GlobalColor("-1") else
                         if m015== -2 then GlobalColor("-2") else
                         if m015== -3 then GlobalColor("-3") else
                         if m015== -4 then GlobalColor("-4") else
                         if m015== -5 then GlobalColor("-5") else
                         if m015== -6 then GlobalColor("-6") else
                         if m015== -7 then GlobalColor("-7") else
                         if m015== -8 then GlobalColor("-8") else
                         if m015== -9 then GlobalColor("-9") else GlobalColor("-10"));
l14Line.AssignValueColor(if m014== 10 then GlobalColor("10") else
                         if m014== 9 then GlobalColor("9") else
                         if m014== 8 then GlobalColor("8") else
                         if m014== 7 then GlobalColor("7") else
                         if m014== 6 then GlobalColor("6") else
                         if m014== 5 then GlobalColor("5") else
                         if m014== 4 then GlobalColor("4") else
                         if m014== 3 then GlobalColor("3") else
                         if m014== 2 then GlobalColor("2") else
                         if m014== 1 then GlobalColor("1") else
                         if m014== -1 then GlobalColor("-1") else
                         if m014== -2 then GlobalColor("-2") else
                         if m014== -3 then GlobalColor("-3") else
                         if m014== -4 then GlobalColor("-4") else
                         if m014== -5 then GlobalColor("-5") else
                         if m014== -6 then GlobalColor("-6") else
                         if m014== -7 then GlobalColor("-7") else
                         if m014== -8 then GlobalColor("-8") else
                         if m014== -9 then GlobalColor("-9") else GlobalColor("-10"));
l13Line.AssignValueColor(if m013== 10 then GlobalColor("10") else
                         if m013== 9 then GlobalColor("9") else
                         if m013== 8 then GlobalColor("8") else
                         if m013== 7 then GlobalColor("7") else
                         if m013== 6 then GlobalColor("6") else
                         if m013== 5 then GlobalColor("5") else
                         if m013== 4 then GlobalColor("4") else
                         if m013== 3 then GlobalColor("3") else
                         if m013== 2 then GlobalColor("2") else
                         if m013== 1 then GlobalColor("1") else
                         if m013== -1 then GlobalColor("-1") else
                         if m013== -2 then GlobalColor("-2") else
                         if m013== -3 then GlobalColor("-3") else
                         if m013== -4 then GlobalColor("-4") else
                         if m013== -5 then GlobalColor("-5") else
                         if m013== -6 then GlobalColor("-6") else
                         if m013== -7 then GlobalColor("-7") else
                         if m013== -8 then GlobalColor("-8") else
                         if m013== -9 then GlobalColor("-9") else GlobalColor("-10"));
l12Line.AssignValueColor(if m012== 10 then GlobalColor("10") else
                         if m012== 9 then GlobalColor("9") else
                         if m012== 8 then GlobalColor("8") else
                         if m012== 7 then GlobalColor("7") else
                         if m012== 6 then GlobalColor("6") else
                         if m012== 5 then GlobalColor("5") else
                         if m012== 4 then GlobalColor("4") else
                         if m012== 3 then GlobalColor("3") else
                         if m012== 2 then GlobalColor("2") else
                         if m012== 1 then GlobalColor("1") else
                         if m012== -1 then GlobalColor("-1") else
                         if m012== -2 then GlobalColor("-2") else
                         if m012== -3 then GlobalColor("-3") else
                         if m012== -4 then GlobalColor("-4") else
                         if m012== -5 then GlobalColor("-5") else
                         if m012== -6 then GlobalColor("-6") else
                         if m012== -7 then GlobalColor("-7") else
                         if m012== -8 then GlobalColor("-8") else
                         if m012== -9 then GlobalColor("-9") else GlobalColor("-10"));
l11Line.AssignValueColor(if m011== 10 then GlobalColor("10") else
                         if m011== 9 then GlobalColor("9") else
                         if m011== 8 then GlobalColor("8") else
                         if m011== 7 then GlobalColor("7") else
                         if m011== 6 then GlobalColor("6") else
                         if m011== 5 then GlobalColor("5") else
                         if m011== 4 then GlobalColor("4") else
                         if m011== 3 then GlobalColor("3") else
                         if m011== 2 then GlobalColor("2") else
                         if m011== 1 then GlobalColor("1") else
                         if m011== -1 then GlobalColor("-1") else
                         if m011== -2 then GlobalColor("-2") else
                         if m011== -3 then GlobalColor("-3") else
                         if m011== -4 then GlobalColor("-4") else
                         if m011== -5 then GlobalColor("-5") else
                         if m011== -6 then GlobalColor("-6") else
                         if m011== -7 then GlobalColor("-7") else
                         if m011== -8 then GlobalColor("-8") else
                         if m011== -9 then GlobalColor("-9") else GlobalColor("-10"));
l10Line.AssignValueColor(if m010== 10 then GlobalColor("10") else
                         if m010== 9 then GlobalColor("9") else
                         if m010== 8 then GlobalColor("8") else
                         if m010== 7 then GlobalColor("7") else
                         if m010== 6 then GlobalColor("6") else
                         if m010== 5 then GlobalColor("5") else
                         if m010== 4 then GlobalColor("4") else
                         if m010== 3 then GlobalColor("3") else
                         if m010== 2 then GlobalColor("2") else
                         if m010== 1 then GlobalColor("1") else
                         if m010== -1 then GlobalColor("-1") else
                         if m010== -2 then GlobalColor("-2") else
                         if m010== -3 then GlobalColor("-3") else
                         if m010== -4 then GlobalColor("-4") else
                         if m010== -5 then GlobalColor("-5") else
                         if m010== -6 then GlobalColor("-6") else
                         if m010== -7 then GlobalColor("-7") else
                         if m010== -8 then GlobalColor("-8") else
                         if m010== -9 then GlobalColor("-9") else GlobalColor("-10"));
l9Line.AssignValueColor(if m09== 10 then GlobalColor("10") else
                         if m09== 9 then GlobalColor("9") else
                         if m09== 8 then GlobalColor("8") else
                         if m09== 7 then GlobalColor("7") else
                         if m09== 6 then GlobalColor("6") else
                         if m09== 5 then GlobalColor("5") else
                         if m09== 4 then GlobalColor("4") else
                         if m09== 3 then GlobalColor("3") else
                         if m09== 2 then GlobalColor("2") else
                         if m09== 1 then GlobalColor("1") else
                         if m09== -1 then GlobalColor("-1") else
                         if m09== -2 then GlobalColor("-2") else
                         if m09== -3 then GlobalColor("-3") else
                         if m09== -4 then GlobalColor("-4") else
                         if m09== -5 then GlobalColor("-5") else
                         if m09== -6 then GlobalColor("-6") else
                         if m09== -7 then GlobalColor("-7") else
                         if m09== -8 then GlobalColor("-8") else
                         if m09== -9 then GlobalColor("-9") else GlobalColor("-10"));
l8Line.AssignValueColor(if m08== 10 then GlobalColor("10") else
                         if m08== 9 then GlobalColor("9") else
                         if m08== 8 then GlobalColor("8") else
                         if m08== 7 then GlobalColor("7") else
                         if m08== 6 then GlobalColor("6") else
                         if m08== 5 then GlobalColor("5") else
                         if m08== 4 then GlobalColor("4") else
                         if m08== 3 then GlobalColor("3") else
                         if m08== 2 then GlobalColor("2") else
                         if m08== 1 then GlobalColor("1") else
                         if m08== -1 then GlobalColor("-1") else
                         if m08== -2 then GlobalColor("-2") else
                         if m08== -3 then GlobalColor("-3") else
                         if m08== -4 then GlobalColor("-4") else
                         if m08== -5 then GlobalColor("-5") else
                         if m08== -6 then GlobalColor("-6") else
                         if m08== -7 then GlobalColor("-7") else
                         if m08== -8 then GlobalColor("-8") else
                         if m08== -9 then GlobalColor("-9") else GlobalColor("-10"));
l7Line.AssignValueColor(if m07== 10 then GlobalColor("10") else
                         if m07== 9 then GlobalColor("9") else
                         if m07== 8 then GlobalColor("8") else
                         if m07== 7 then GlobalColor("7") else
                         if m07== 6 then GlobalColor("6") else
                         if m07== 5 then GlobalColor("5") else
                         if m07== 4 then GlobalColor("4") else
                         if m07== 3 then GlobalColor("3") else
                         if m07== 2 then GlobalColor("2") else
                         if m07== 1 then GlobalColor("1") else
                         if m07== -1 then GlobalColor("-1") else
                         if m07== -2 then GlobalColor("-2") else
                         if m07== -3 then GlobalColor("-3") else
                         if m07== -4 then GlobalColor("-4") else
                         if m07== -5 then GlobalColor("-5") else
                         if m07== -6 then GlobalColor("-6") else
                         if m07== -7 then GlobalColor("-7") else
                         if m07== -8 then GlobalColor("-8") else
                         if m07== -9 then GlobalColor("-9") else GlobalColor("-10"));
l6Line.AssignValueColor(if m06== 10 then GlobalColor("10") else
                         if m06== 9 then GlobalColor("9") else
                         if m06== 8 then GlobalColor("8") else
                         if m06== 7 then GlobalColor("7") else
                         if m06== 6 then GlobalColor("6") else
                         if m06== 5 then GlobalColor("5") else
                         if m06== 4 then GlobalColor("4") else
                         if m06== 3 then GlobalColor("3") else
                         if m06== 2 then GlobalColor("2") else
                         if m06== 1 then GlobalColor("1") else
                         if m06== -1 then GlobalColor("-1") else
                         if m06== -2 then GlobalColor("-2") else
                         if m06== -3 then GlobalColor("-3") else
                         if m06== -4 then GlobalColor("-4") else
                         if m06== -5 then GlobalColor("-5") else
                         if m06== -6 then GlobalColor("-6") else
                         if m06== -7 then GlobalColor("-7") else
                         if m06== -8 then GlobalColor("-8") else
                         if m06== -9 then GlobalColor("-9") else GlobalColor("-10"));
l5Line.AssignValueColor(if m05== 10 then GlobalColor("10") else
                         if m05== 9 then GlobalColor("9") else
                         if m05== 8 then GlobalColor("8") else
                         if m05== 7 then GlobalColor("7") else
                         if m05== 6 then GlobalColor("6") else
                         if m05== 5 then GlobalColor("5") else
                         if m05== 4 then GlobalColor("4") else
                         if m05== 3 then GlobalColor("3") else
                         if m05== 2 then GlobalColor("2") else
                         if m05== 1 then GlobalColor("1") else
                         if m05== -1 then GlobalColor("-1") else
                         if m05== -2 then GlobalColor("-2") else
                         if m05== -3 then GlobalColor("-3") else
                         if m05== -4 then GlobalColor("-4") else
                         if m05== -5 then GlobalColor("-5") else
                         if m05== -6 then GlobalColor("-6") else
                         if m05== -7 then GlobalColor("-7") else
                         if m05== -8 then GlobalColor("-8") else
                         if m05== -9 then GlobalColor("-9") else GlobalColor("-10"));
l4Line.AssignValueColor(if m04== 10 then GlobalColor("10") else
                         if m04== 9 then GlobalColor("9") else
                         if m04== 8 then GlobalColor("8") else
                         if m04== 7 then GlobalColor("7") else
                         if m04== 6 then GlobalColor("6") else
                         if m04== 5 then GlobalColor("5") else
                         if m04== 4 then GlobalColor("4") else
                         if m04== 3 then GlobalColor("3") else
                         if m04== 2 then GlobalColor("2") else
                         if m04== 1 then GlobalColor("1") else
                         if m04== -1 then GlobalColor("-1") else
                         if m04== -2 then GlobalColor("-2") else
                         if m04== -3 then GlobalColor("-3") else
                         if m04== -4 then GlobalColor("-4") else
                         if m04== -5 then GlobalColor("-5") else
                         if m04== -6 then GlobalColor("-6") else
                         if m04== -7 then GlobalColor("-7") else
                         if m04== -8 then GlobalColor("-8") else
                         if m04== -9 then GlobalColor("-9") else GlobalColor("-10"));
l3Line.AssignValueColor(if m03== 10 then GlobalColor("10") else
                         if m03== 9 then GlobalColor("9") else
                         if m03== 8 then GlobalColor("8") else
                         if m03== 7 then GlobalColor("7") else
                         if m03== 6 then GlobalColor("6") else
                         if m03== 5 then GlobalColor("5") else
                         if m03== 4 then GlobalColor("4") else
                         if m03== 3 then GlobalColor("3") else
                         if m03== 2 then GlobalColor("2") else
                         if m03== 1 then GlobalColor("1") else
                         if m03== -1 then GlobalColor("-1") else
                         if m03== -2 then GlobalColor("-2") else
                         if m03== -3 then GlobalColor("-3") else
                         if m03== -4 then GlobalColor("-4") else
                         if m03== -5 then GlobalColor("-5") else
                         if m03== -6 then GlobalColor("-6") else
                         if m03== -7 then GlobalColor("-7") else
                         if m03== -8 then GlobalColor("-8") else
                         if m03== -9 then GlobalColor("-9") else GlobalColor("-10"));
l2Line.AssignValueColor(if m02== 10 then GlobalColor("10") else
                         if m02== 9 then GlobalColor("9") else
                         if m02== 8 then GlobalColor("8") else
                         if m02== 7 then GlobalColor("7") else
                         if m02== 6 then GlobalColor("6") else
                         if m02== 5 then GlobalColor("5") else
                         if m02== 4 then GlobalColor("4") else
                         if m02== 3 then GlobalColor("3") else
                         if m02== 2 then GlobalColor("2") else
                         if m02== 1 then GlobalColor("1") else
                         if m02== -1 then GlobalColor("-1") else
                         if m02== -2 then GlobalColor("-2") else
                         if m02== -3 then GlobalColor("-3") else
                         if m02== -4 then GlobalColor("-4") else
                         if m02== -5 then GlobalColor("-5") else
                         if m02== -6 then GlobalColor("-6") else
                         if m02== -7 then GlobalColor("-7") else
                         if m02== -8 then GlobalColor("-8") else
                         if m02== -9 then GlobalColor("-9") else GlobalColor("-10"));
l1Line.AssignValueColor(if m01== 10 then GlobalColor("10") else
                         if m01== 9 then GlobalColor("9") else
                         if m01== 8 then GlobalColor("8") else
                         if m01== 7 then GlobalColor("7") else
                         if m01== 6 then GlobalColor("6") else
                         if m01== 5 then GlobalColor("5") else
                         if m01== 4 then GlobalColor("4") else
                         if m01== 3 then GlobalColor("3") else
                         if m01== 2 then GlobalColor("2") else
                         if m01== 1 then GlobalColor("1") else
                         if m01== -1 then GlobalColor("-1") else
                         if m01== -2 then GlobalColor("-2") else
                         if m01== -3 then GlobalColor("-3") else
                         if m01== -4 then GlobalColor("-4") else
                         if m01== -5 then GlobalColor("-5") else
                         if m01== -6 then GlobalColor("-6") else
                         if m01== -7 then GlobalColor("-7") else
                         if m01== -8 then GlobalColor("-8") else
                         if m01== -9 then GlobalColor("-9") else GlobalColor("-10"));


#--- END OF CODE
 
check this

CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © LonesomeTheBlue
#study("Trend Following MAs 3D", precision=0)
# Converted by Sam4Cok@Samer800      - 08/2023
declare lower;

input maType = AverageType.EXPONENTIAL;
input source = close;
input UseLinearRegression = yes;      # "Use Linear Regression"
input LinearRegressionPeriod = 10;    # "Linear Regression Period"

def na = Double.NaN;

#-- Color
DefineGlobalColor("10", CreateColor(0, 255, 0));
DefineGlobalColor("9", CreateColor(0, 235, 0));
DefineGlobalColor("8", CreateColor(0, 216, 0));
DefineGlobalColor("7", CreateColor(0, 196, 0));
DefineGlobalColor("6", CreateColor(0, 177, 0));
DefineGlobalColor("5", CreateColor(0, 157, 0));
DefineGlobalColor("4", CreateColor(0, 137, 0));
DefineGlobalColor("3", CreateColor(0, 118, 0));
DefineGlobalColor("2", CreateColor(0, 98, 0));
DefineGlobalColor("1", CreateColor(0, 78, 0));
DefineGlobalColor("-10", CreateColor(255, 0, 0));
DefineGlobalColor("-9", CreateColor(235, 0, 0));
DefineGlobalColor("-8", CreateColor(216, 0, 0));
DefineGlobalColor("-7", CreateColor(196, 0, 0));
DefineGlobalColor("-6", CreateColor(177, 0, 0));
DefineGlobalColor("-5", CreateColor(157, 0, 0));
DefineGlobalColor("-4", CreateColor(137, 0, 0));
DefineGlobalColor("-3", CreateColor(118, 0, 0));
DefineGlobalColor("-2", CreateColor(98, 0, 0));
DefineGlobalColor("-1", CreateColor(78, 0, 0));
#// ] -------------- FUNCTIONS : Moving Avg ------------------ [

script getma {
    input length = 14;
    input source = close;
    input type = AverageType.EXPONENTIAL;
    input ulinreg = yes;
    input linprd = 10;
    def v = volume;
    def VWMA = Average(source * v, length) / Average(v, length);
    def multiMa = MovingAverage(type, source, length);
    def lin = Inertia(multiMa, linprd);
    plot return = if ulinreg then lin else multiMa;
}

def getma5 = getma(5, source, maType, UseLinearRegression, LinearRegressionPeriod);
def getma10 = getma(10, source, maType, UseLinearRegression, LinearRegressionPeriod);
def getma15 = getma(15, source, maType, UseLinearRegression, LinearRegressionPeriod);
def getma20 = getma(20, source, maType, UseLinearRegression, LinearRegressionPeriod);
def getma25 = getma(25, source, maType, UseLinearRegression, LinearRegressionPeriod);
def getma30 = getma(30, source, maType, UseLinearRegression, LinearRegressionPeriod);
def getma35 = getma(35, source, maType, UseLinearRegression, LinearRegressionPeriod);
def getma40 = getma(40, source, maType, UseLinearRegression, LinearRegressionPeriod);
def getma45 = getma(45, source, maType, UseLinearRegression, LinearRegressionPeriod);
def getma50 = getma(50, source, maType, UseLinearRegression, LinearRegressionPeriod);
def getma55 = getma(55, source, maType, UseLinearRegression, LinearRegressionPeriod);
def getma60 = getma(60, source, maType, UseLinearRegression, LinearRegressionPeriod);
def getma65 = getma(65, source, maType, UseLinearRegression, LinearRegressionPeriod);
def getma70 = getma(70, source, maType, UseLinearRegression, LinearRegressionPeriod);
def getma75 = getma(75, source, maType, UseLinearRegression, LinearRegressionPeriod);
def getma80 = getma(80, source, maType, UseLinearRegression, LinearRegressionPeriod);
def getma85 = getma(85, source, maType, UseLinearRegression, LinearRegressionPeriod);
def getma90 = getma(90, source, maType, UseLinearRegression, LinearRegressionPeriod);
def getma95 = getma(95, source, maType, UseLinearRegression, LinearRegressionPeriod);
def getma100 = getma(100, source, maType, UseLinearRegression, LinearRegressionPeriod);
def getma105 = getma(105, source, maType, UseLinearRegression, LinearRegressionPeriod);

def p1 = getma5 - getma10;
def p2 = p1 + getma10 - getma15;
def p3 = p2 + getma15 - getma20;
def p4 = p3 + getma20 - getma25;
def p5 = p4 + getma25 - getma30;
def p6 = p5 + getma30 - getma35;
def p7 = p6 + getma35 - getma40;
def p8 = p7 + getma40 - getma45;
def p9 = p8 + getma45 - getma50;
def p10 = p9 + getma50 - getma55;
def p11 = p10 + getma55 - getma60;
def p12 = p11 + getma60 - getma65;
def p13 = p12 + getma65 - getma70;
def p14 = p13 + getma70 - getma75;
def p15 = p14 + getma75 - getma80;
def p16 = p15 + getma80 - getma85;
def p17 = p16 + getma85 - getma90;
def p18 = p17 + getma90 - getma95;
def p19 = p18 + getma95 - getma100;
def p20 = p19 + getma100 - getma105;

def l1 = p1;
def l2 = p2;
def l3 = p3;
def l4 = p4;
def l5 = p5;
def l6 = p6;
def l7 = p7;
def l8 = p8;
def l9 = p9;
def l10 = p10;
def l11 = p11;
def l12 = p12;
def l13 = p13;
def l14 = p14;
def l15 = p15;
def l16 = p16;
def l17 = p17;
def l18 = p18;
def l19 = p19;
def l20 = p20;

#getwidth(a, b)=>
script getwidth {
    input p1 = close;
    input a = close;
    input b = close;
    def t = AbsValue(a - b);
    def w_ = t * 10 / (Highest(t, 200) - Lowest(t, 200));
    def w = Max(w_, 4);#if !w[1] then w_ else Max(w_, 4);
    def m = if p1 > 0 then if p1 > p1[1] then if w > w[1] then w + 1 else w - 1 else
            if w > w[1] then w - 3 else w - 2 else
            if p1 < p1[1] then if w > w[1] then -(w + 1) else -(w - 1) else
            if w > w[1] then -(w - 3) else -(w - 2);
    plot out = m;
}
#getcolmult(trend)=>
script getcolmult {
    input trend = 0;
    def _ret = if trend >= 10.0 then 10 else if trend >=  9.0 then  9  else if trend >= 8.0 then 8 else
               if trend >= 7.0  then  7 else if trend >=  6.0 then  6  else if trend >= 5.0 then 5 else
               if trend >= 4.0  then  4 else if trend >=  3.0 then  3  else if trend >= 2.0 then 2 else
               if trend >= 1.0  then  1 else if trend <= -10  then -10 else if trend <= -9.0 then -9 else
               if trend <= -8.0 then -8 else if trend <= -7.0 then -7  else if trend <= -6.0 then -6 else
               if trend <= -5.0 then -5 else if trend <= -4.0 then -4  else if trend <= -3.0 then -3 else
               if trend <= -2.0 then -2 else if trend <= -1.0 then -1  else _ret[1];
    plot out = _ret;
}
def m19 = getwidth(p1, p19, p20);
def m18 = getwidth(p1, p18, p19);
def m17 = getwidth(p1, p17, p18);
def m16 = getwidth(p1, p16, p17);
def m15 = getwidth(p1, p15, p16);
def m14 = getwidth(p1, p14, p15);
def m13 = getwidth(p1, p13, p14);
def m12 = getwidth(p1, p12, p13);
def m11 = getwidth(p1, p11, p12);
def m10 = getwidth(p1, p10, p11);
def m9 = getwidth(p1, p9, p10);
def m8 = getwidth(p1, p8, p9);
def m7 = getwidth(p1, p7, p8);
def m6 = getwidth(p1, p6, p7);
def m5 = getwidth(p1, p5, p6);
def m4 = getwidth(p1, p4, p5);
def m3 = getwidth(p1, p3, p4);
def m2 = getwidth(p1, p2, p3);
def m1 = getwidth(p1, p1, p2);

def r01 = getcolmult(m1);
def r02 = getcolmult(m2);
def r03 = getcolmult(m3);
def r04 = getcolmult(m4);
def r05 = getcolmult(m5);
def r06 = getcolmult(m6);
def r07 = getcolmult(m7);
def r08 = getcolmult(m8);
def r09 = getcolmult(m9);
def r010 = getcolmult(m10);
def r011 = getcolmult(m11);
def r012 = getcolmult(m12);
def r013 = getcolmult(m13);
def r014 = getcolmult(m14);
def r015 = getcolmult(m15);
def r016 = getcolmult(m16);
def r017 = getcolmult(m17);
def r018 = getcolmult(m18);
def r019 = getcolmult(m19);

def m01 = r01;
def m02 = r02;
def m03 = r03;
def m04 = r04;
def m05 = r05;
def m06 = r06;
def m07 = r07;
def m08 = r08;
def m09 = r09;
def m010 = r010;
def m011 = r011;
def m012 = r012;
def m013 = r013;
def m014 = r014;
def m015 = r015;
def m016 = r016;
def m017 = r017;
def m018 = r018;
def m019 = r019;

plot l19Line = l19;
plot l18Line = l18;
plot l17Line = l17;
plot l16Line = l16;
plot l15Line = l15;
plot l14Line = l14;
plot l13Line = l13;
plot l12Line = l12;
plot l11Line = l11;
plot l10Line = l10;
plot l9Line = l9;
plot l8Line = l8;
plot l7Line = l7;
plot l6Line = l6;
plot l5Line = l5;
plot l4Line = l4;
plot l3Line = l3;
plot l2Line = l2;
plot l1Line = l1;

l19Line.SetLineWeight(2);
l18Line.SetLineWeight(2);
l17Line.SetLineWeight(2);
l16Line.SetLineWeight(2);
l15Line.SetLineWeight(2);
l14Line.SetLineWeight(2);
l13Line.SetLineWeight(2);
l12Line.SetLineWeight(2);
l11Line.SetLineWeight(2);
l10Line.SetLineWeight(2);
l9Line.SetLineWeight(2);
l8Line.SetLineWeight(2);
l7Line.SetLineWeight(2);
l5Line.SetLineWeight(2);
l4Line.SetLineWeight(2);
l3Line.SetLineWeight(2);
l2Line.SetLineWeight(2);
l1Line.SetLineWeight(2);
l1Line.SetLineWeight(2);

l19Line.AssignValueColor(if m019== 10 then GlobalColor("10") else
                         if m019== 9 then GlobalColor("9") else
                         if m019== 8 then GlobalColor("8") else
                         if m019== 7 then GlobalColor("7") else
                         if m019== 6 then GlobalColor("6") else
                         if m019== 5 then GlobalColor("5") else
                         if m019== 4 then GlobalColor("4") else
                         if m019== 3 then GlobalColor("3") else
                         if m019== 2 then GlobalColor("2") else
                         if m019== 1 then GlobalColor("1") else
                         if m019== -1 then GlobalColor("-1") else
                         if m019== -2 then GlobalColor("-2") else
                         if m019== -3 then GlobalColor("-3") else
                         if m019== -4 then GlobalColor("-4") else
                         if m019== -5 then GlobalColor("-5") else
                         if m019== -6 then GlobalColor("-6") else
                         if m019== -7 then GlobalColor("-7") else
                         if m019== -8 then GlobalColor("-8") else
                         if m019== -9 then GlobalColor("-9") else GlobalColor("-10"));
l18Line.AssignValueColor(if m018== 10 then GlobalColor("10") else
                         if m018== 9 then GlobalColor("9") else
                         if m018== 8 then GlobalColor("8") else
                         if m018== 7 then GlobalColor("7") else
                         if m018== 6 then GlobalColor("6") else
                         if m018== 5 then GlobalColor("5") else
                         if m018== 4 then GlobalColor("4") else
                         if m018== 3 then GlobalColor("3") else
                         if m018== 2 then GlobalColor("2") else
                         if m018== 1 then GlobalColor("1") else
                         if m018== -1 then GlobalColor("-1") else
                         if m018== -2 then GlobalColor("-2") else
                         if m018== -3 then GlobalColor("-3") else
                         if m018== -4 then GlobalColor("-4") else
                         if m018== -5 then GlobalColor("-5") else
                         if m018== -6 then GlobalColor("-6") else
                         if m018== -7 then GlobalColor("-7") else
                         if m018== -8 then GlobalColor("-8") else
                         if m018== -9 then GlobalColor("-9") else GlobalColor("-10"));
l17Line.AssignValueColor(if m017== 10 then GlobalColor("10") else
                         if m017== 9 then GlobalColor("9") else
                         if m017== 8 then GlobalColor("8") else
                         if m017== 7 then GlobalColor("7") else
                         if m017== 6 then GlobalColor("6") else
                         if m017== 5 then GlobalColor("5") else
                         if m017== 4 then GlobalColor("4") else
                         if m017== 3 then GlobalColor("3") else
                         if m017== 2 then GlobalColor("2") else
                         if m017== 1 then GlobalColor("1") else
                         if m017== -1 then GlobalColor("-1") else
                         if m017== -2 then GlobalColor("-2") else
                         if m017== -3 then GlobalColor("-3") else
                         if m017== -4 then GlobalColor("-4") else
                         if m017== -5 then GlobalColor("-5") else
                         if m017== -6 then GlobalColor("-6") else
                         if m017== -7 then GlobalColor("-7") else
                         if m017== -8 then GlobalColor("-8") else
                         if m017== -9 then GlobalColor("-9") else GlobalColor("-10"));
l16Line.AssignValueColor(if m016== 10 then GlobalColor("10") else
                         if m016== 9 then GlobalColor("9") else
                         if m016== 8 then GlobalColor("8") else
                         if m016== 7 then GlobalColor("7") else
                         if m016== 6 then GlobalColor("6") else
                         if m016== 5 then GlobalColor("5") else
                         if m016== 4 then GlobalColor("4") else
                         if m016== 3 then GlobalColor("3") else
                         if m016== 2 then GlobalColor("2") else
                         if m016== 1 then GlobalColor("1") else
                         if m016== -1 then GlobalColor("-1") else
                         if m016== -2 then GlobalColor("-2") else
                         if m016== -3 then GlobalColor("-3") else
                         if m016== -4 then GlobalColor("-4") else
                         if m016== -5 then GlobalColor("-5") else
                         if m016== -6 then GlobalColor("-6") else
                         if m016== -7 then GlobalColor("-7") else
                         if m016== -8 then GlobalColor("-8") else
                         if m016== -9 then GlobalColor("-9") else GlobalColor("-10"));
l15Line.AssignValueColor(if m015== 10 then GlobalColor("10") else
                         if m015== 9 then GlobalColor("9") else
                         if m015== 8 then GlobalColor("8") else
                         if m015== 7 then GlobalColor("7") else
                         if m015== 6 then GlobalColor("6") else
                         if m015== 5 then GlobalColor("5") else
                         if m015== 4 then GlobalColor("4") else
                         if m015== 3 then GlobalColor("3") else
                         if m015== 2 then GlobalColor("2") else
                         if m015== 1 then GlobalColor("1") else
                         if m015== -1 then GlobalColor("-1") else
                         if m015== -2 then GlobalColor("-2") else
                         if m015== -3 then GlobalColor("-3") else
                         if m015== -4 then GlobalColor("-4") else
                         if m015== -5 then GlobalColor("-5") else
                         if m015== -6 then GlobalColor("-6") else
                         if m015== -7 then GlobalColor("-7") else
                         if m015== -8 then GlobalColor("-8") else
                         if m015== -9 then GlobalColor("-9") else GlobalColor("-10"));
l14Line.AssignValueColor(if m014== 10 then GlobalColor("10") else
                         if m014== 9 then GlobalColor("9") else
                         if m014== 8 then GlobalColor("8") else
                         if m014== 7 then GlobalColor("7") else
                         if m014== 6 then GlobalColor("6") else
                         if m014== 5 then GlobalColor("5") else
                         if m014== 4 then GlobalColor("4") else
                         if m014== 3 then GlobalColor("3") else
                         if m014== 2 then GlobalColor("2") else
                         if m014== 1 then GlobalColor("1") else
                         if m014== -1 then GlobalColor("-1") else
                         if m014== -2 then GlobalColor("-2") else
                         if m014== -3 then GlobalColor("-3") else
                         if m014== -4 then GlobalColor("-4") else
                         if m014== -5 then GlobalColor("-5") else
                         if m014== -6 then GlobalColor("-6") else
                         if m014== -7 then GlobalColor("-7") else
                         if m014== -8 then GlobalColor("-8") else
                         if m014== -9 then GlobalColor("-9") else GlobalColor("-10"));
l13Line.AssignValueColor(if m013== 10 then GlobalColor("10") else
                         if m013== 9 then GlobalColor("9") else
                         if m013== 8 then GlobalColor("8") else
                         if m013== 7 then GlobalColor("7") else
                         if m013== 6 then GlobalColor("6") else
                         if m013== 5 then GlobalColor("5") else
                         if m013== 4 then GlobalColor("4") else
                         if m013== 3 then GlobalColor("3") else
                         if m013== 2 then GlobalColor("2") else
                         if m013== 1 then GlobalColor("1") else
                         if m013== -1 then GlobalColor("-1") else
                         if m013== -2 then GlobalColor("-2") else
                         if m013== -3 then GlobalColor("-3") else
                         if m013== -4 then GlobalColor("-4") else
                         if m013== -5 then GlobalColor("-5") else
                         if m013== -6 then GlobalColor("-6") else
                         if m013== -7 then GlobalColor("-7") else
                         if m013== -8 then GlobalColor("-8") else
                         if m013== -9 then GlobalColor("-9") else GlobalColor("-10"));
l12Line.AssignValueColor(if m012== 10 then GlobalColor("10") else
                         if m012== 9 then GlobalColor("9") else
                         if m012== 8 then GlobalColor("8") else
                         if m012== 7 then GlobalColor("7") else
                         if m012== 6 then GlobalColor("6") else
                         if m012== 5 then GlobalColor("5") else
                         if m012== 4 then GlobalColor("4") else
                         if m012== 3 then GlobalColor("3") else
                         if m012== 2 then GlobalColor("2") else
                         if m012== 1 then GlobalColor("1") else
                         if m012== -1 then GlobalColor("-1") else
                         if m012== -2 then GlobalColor("-2") else
                         if m012== -3 then GlobalColor("-3") else
                         if m012== -4 then GlobalColor("-4") else
                         if m012== -5 then GlobalColor("-5") else
                         if m012== -6 then GlobalColor("-6") else
                         if m012== -7 then GlobalColor("-7") else
                         if m012== -8 then GlobalColor("-8") else
                         if m012== -9 then GlobalColor("-9") else GlobalColor("-10"));
l11Line.AssignValueColor(if m011== 10 then GlobalColor("10") else
                         if m011== 9 then GlobalColor("9") else
                         if m011== 8 then GlobalColor("8") else
                         if m011== 7 then GlobalColor("7") else
                         if m011== 6 then GlobalColor("6") else
                         if m011== 5 then GlobalColor("5") else
                         if m011== 4 then GlobalColor("4") else
                         if m011== 3 then GlobalColor("3") else
                         if m011== 2 then GlobalColor("2") else
                         if m011== 1 then GlobalColor("1") else
                         if m011== -1 then GlobalColor("-1") else
                         if m011== -2 then GlobalColor("-2") else
                         if m011== -3 then GlobalColor("-3") else
                         if m011== -4 then GlobalColor("-4") else
                         if m011== -5 then GlobalColor("-5") else
                         if m011== -6 then GlobalColor("-6") else
                         if m011== -7 then GlobalColor("-7") else
                         if m011== -8 then GlobalColor("-8") else
                         if m011== -9 then GlobalColor("-9") else GlobalColor("-10"));
l10Line.AssignValueColor(if m010== 10 then GlobalColor("10") else
                         if m010== 9 then GlobalColor("9") else
                         if m010== 8 then GlobalColor("8") else
                         if m010== 7 then GlobalColor("7") else
                         if m010== 6 then GlobalColor("6") else
                         if m010== 5 then GlobalColor("5") else
                         if m010== 4 then GlobalColor("4") else
                         if m010== 3 then GlobalColor("3") else
                         if m010== 2 then GlobalColor("2") else
                         if m010== 1 then GlobalColor("1") else
                         if m010== -1 then GlobalColor("-1") else
                         if m010== -2 then GlobalColor("-2") else
                         if m010== -3 then GlobalColor("-3") else
                         if m010== -4 then GlobalColor("-4") else
                         if m010== -5 then GlobalColor("-5") else
                         if m010== -6 then GlobalColor("-6") else
                         if m010== -7 then GlobalColor("-7") else
                         if m010== -8 then GlobalColor("-8") else
                         if m010== -9 then GlobalColor("-9") else GlobalColor("-10"));
l9Line.AssignValueColor(if m09== 10 then GlobalColor("10") else
                         if m09== 9 then GlobalColor("9") else
                         if m09== 8 then GlobalColor("8") else
                         if m09== 7 then GlobalColor("7") else
                         if m09== 6 then GlobalColor("6") else
                         if m09== 5 then GlobalColor("5") else
                         if m09== 4 then GlobalColor("4") else
                         if m09== 3 then GlobalColor("3") else
                         if m09== 2 then GlobalColor("2") else
                         if m09== 1 then GlobalColor("1") else
                         if m09== -1 then GlobalColor("-1") else
                         if m09== -2 then GlobalColor("-2") else
                         if m09== -3 then GlobalColor("-3") else
                         if m09== -4 then GlobalColor("-4") else
                         if m09== -5 then GlobalColor("-5") else
                         if m09== -6 then GlobalColor("-6") else
                         if m09== -7 then GlobalColor("-7") else
                         if m09== -8 then GlobalColor("-8") else
                         if m09== -9 then GlobalColor("-9") else GlobalColor("-10"));
l8Line.AssignValueColor(if m08== 10 then GlobalColor("10") else
                         if m08== 9 then GlobalColor("9") else
                         if m08== 8 then GlobalColor("8") else
                         if m08== 7 then GlobalColor("7") else
                         if m08== 6 then GlobalColor("6") else
                         if m08== 5 then GlobalColor("5") else
                         if m08== 4 then GlobalColor("4") else
                         if m08== 3 then GlobalColor("3") else
                         if m08== 2 then GlobalColor("2") else
                         if m08== 1 then GlobalColor("1") else
                         if m08== -1 then GlobalColor("-1") else
                         if m08== -2 then GlobalColor("-2") else
                         if m08== -3 then GlobalColor("-3") else
                         if m08== -4 then GlobalColor("-4") else
                         if m08== -5 then GlobalColor("-5") else
                         if m08== -6 then GlobalColor("-6") else
                         if m08== -7 then GlobalColor("-7") else
                         if m08== -8 then GlobalColor("-8") else
                         if m08== -9 then GlobalColor("-9") else GlobalColor("-10"));
l7Line.AssignValueColor(if m07== 10 then GlobalColor("10") else
                         if m07== 9 then GlobalColor("9") else
                         if m07== 8 then GlobalColor("8") else
                         if m07== 7 then GlobalColor("7") else
                         if m07== 6 then GlobalColor("6") else
                         if m07== 5 then GlobalColor("5") else
                         if m07== 4 then GlobalColor("4") else
                         if m07== 3 then GlobalColor("3") else
                         if m07== 2 then GlobalColor("2") else
                         if m07== 1 then GlobalColor("1") else
                         if m07== -1 then GlobalColor("-1") else
                         if m07== -2 then GlobalColor("-2") else
                         if m07== -3 then GlobalColor("-3") else
                         if m07== -4 then GlobalColor("-4") else
                         if m07== -5 then GlobalColor("-5") else
                         if m07== -6 then GlobalColor("-6") else
                         if m07== -7 then GlobalColor("-7") else
                         if m07== -8 then GlobalColor("-8") else
                         if m07== -9 then GlobalColor("-9") else GlobalColor("-10"));
l6Line.AssignValueColor(if m06== 10 then GlobalColor("10") else
                         if m06== 9 then GlobalColor("9") else
                         if m06== 8 then GlobalColor("8") else
                         if m06== 7 then GlobalColor("7") else
                         if m06== 6 then GlobalColor("6") else
                         if m06== 5 then GlobalColor("5") else
                         if m06== 4 then GlobalColor("4") else
                         if m06== 3 then GlobalColor("3") else
                         if m06== 2 then GlobalColor("2") else
                         if m06== 1 then GlobalColor("1") else
                         if m06== -1 then GlobalColor("-1") else
                         if m06== -2 then GlobalColor("-2") else
                         if m06== -3 then GlobalColor("-3") else
                         if m06== -4 then GlobalColor("-4") else
                         if m06== -5 then GlobalColor("-5") else
                         if m06== -6 then GlobalColor("-6") else
                         if m06== -7 then GlobalColor("-7") else
                         if m06== -8 then GlobalColor("-8") else
                         if m06== -9 then GlobalColor("-9") else GlobalColor("-10"));
l5Line.AssignValueColor(if m05== 10 then GlobalColor("10") else
                         if m05== 9 then GlobalColor("9") else
                         if m05== 8 then GlobalColor("8") else
                         if m05== 7 then GlobalColor("7") else
                         if m05== 6 then GlobalColor("6") else
                         if m05== 5 then GlobalColor("5") else
                         if m05== 4 then GlobalColor("4") else
                         if m05== 3 then GlobalColor("3") else
                         if m05== 2 then GlobalColor("2") else
                         if m05== 1 then GlobalColor("1") else
                         if m05== -1 then GlobalColor("-1") else
                         if m05== -2 then GlobalColor("-2") else
                         if m05== -3 then GlobalColor("-3") else
                         if m05== -4 then GlobalColor("-4") else
                         if m05== -5 then GlobalColor("-5") else
                         if m05== -6 then GlobalColor("-6") else
                         if m05== -7 then GlobalColor("-7") else
                         if m05== -8 then GlobalColor("-8") else
                         if m05== -9 then GlobalColor("-9") else GlobalColor("-10"));
l4Line.AssignValueColor(if m04== 10 then GlobalColor("10") else
                         if m04== 9 then GlobalColor("9") else
                         if m04== 8 then GlobalColor("8") else
                         if m04== 7 then GlobalColor("7") else
                         if m04== 6 then GlobalColor("6") else
                         if m04== 5 then GlobalColor("5") else
                         if m04== 4 then GlobalColor("4") else
                         if m04== 3 then GlobalColor("3") else
                         if m04== 2 then GlobalColor("2") else
                         if m04== 1 then GlobalColor("1") else
                         if m04== -1 then GlobalColor("-1") else
                         if m04== -2 then GlobalColor("-2") else
                         if m04== -3 then GlobalColor("-3") else
                         if m04== -4 then GlobalColor("-4") else
                         if m04== -5 then GlobalColor("-5") else
                         if m04== -6 then GlobalColor("-6") else
                         if m04== -7 then GlobalColor("-7") else
                         if m04== -8 then GlobalColor("-8") else
                         if m04== -9 then GlobalColor("-9") else GlobalColor("-10"));
l3Line.AssignValueColor(if m03== 10 then GlobalColor("10") else
                         if m03== 9 then GlobalColor("9") else
                         if m03== 8 then GlobalColor("8") else
                         if m03== 7 then GlobalColor("7") else
                         if m03== 6 then GlobalColor("6") else
                         if m03== 5 then GlobalColor("5") else
                         if m03== 4 then GlobalColor("4") else
                         if m03== 3 then GlobalColor("3") else
                         if m03== 2 then GlobalColor("2") else
                         if m03== 1 then GlobalColor("1") else
                         if m03== -1 then GlobalColor("-1") else
                         if m03== -2 then GlobalColor("-2") else
                         if m03== -3 then GlobalColor("-3") else
                         if m03== -4 then GlobalColor("-4") else
                         if m03== -5 then GlobalColor("-5") else
                         if m03== -6 then GlobalColor("-6") else
                         if m03== -7 then GlobalColor("-7") else
                         if m03== -8 then GlobalColor("-8") else
                         if m03== -9 then GlobalColor("-9") else GlobalColor("-10"));
l2Line.AssignValueColor(if m02== 10 then GlobalColor("10") else
                         if m02== 9 then GlobalColor("9") else
                         if m02== 8 then GlobalColor("8") else
                         if m02== 7 then GlobalColor("7") else
                         if m02== 6 then GlobalColor("6") else
                         if m02== 5 then GlobalColor("5") else
                         if m02== 4 then GlobalColor("4") else
                         if m02== 3 then GlobalColor("3") else
                         if m02== 2 then GlobalColor("2") else
                         if m02== 1 then GlobalColor("1") else
                         if m02== -1 then GlobalColor("-1") else
                         if m02== -2 then GlobalColor("-2") else
                         if m02== -3 then GlobalColor("-3") else
                         if m02== -4 then GlobalColor("-4") else
                         if m02== -5 then GlobalColor("-5") else
                         if m02== -6 then GlobalColor("-6") else
                         if m02== -7 then GlobalColor("-7") else
                         if m02== -8 then GlobalColor("-8") else
                         if m02== -9 then GlobalColor("-9") else GlobalColor("-10"));
l1Line.AssignValueColor(if m01== 10 then GlobalColor("10") else
                         if m01== 9 then GlobalColor("9") else
                         if m01== 8 then GlobalColor("8") else
                         if m01== 7 then GlobalColor("7") else
                         if m01== 6 then GlobalColor("6") else
                         if m01== 5 then GlobalColor("5") else
                         if m01== 4 then GlobalColor("4") else
                         if m01== 3 then GlobalColor("3") else
                         if m01== 2 then GlobalColor("2") else
                         if m01== 1 then GlobalColor("1") else
                         if m01== -1 then GlobalColor("-1") else
                         if m01== -2 then GlobalColor("-2") else
                         if m01== -3 then GlobalColor("-3") else
                         if m01== -4 then GlobalColor("-4") else
                         if m01== -5 then GlobalColor("-5") else
                         if m01== -6 then GlobalColor("-6") else
                         if m01== -7 then GlobalColor("-7") else
                         if m01== -8 then GlobalColor("-8") else
                         if m01== -9 then GlobalColor("-9") else GlobalColor("-10"));


#--- END OF CODE
Hey Samer is it possible to add a code to show the breakout signals like a arrow that points green or red depending on which way the MAs point?
 
Hey Samer is it possible to add a code to show the breakout signals like a arrow that points green or red depending on which way the MAs point?
add the below at the end of the code:

CSS:
input colorBars = no;
input showSignalLines = yes;
def cum = m01 + m02 + m03 + m04 + m05 + m06 + m07 + m08 + m09 + m010
              + m011 + m012 + m013 + m014 + m015 + m016 + m017 + m018 + m019;
def condup = cum > 0 and cum[1] <= 0;
def condDn = cum < 0 and cum[1] >= 0;
def barCol = if condup then 1 else
             if condDn then -1 else barCol[1];
AssignPriceColor(if !colorBars then Color.CURRENT else
                 if barCol>0 then Color.GREEN else
                 if barCol<0 then Color.RED else Color.GRAY);
AddVerticalLine(condup and showSignalLines, "Buy", Color.CYAN);
AddVerticalLine(condDn and showSignalLines, "Sell", Color.MAGENTA);
 
add the below at the end of the code:

CSS:
input colorBars = no;
input showSignalLines = yes;
def cum = m01 + m02 + m03 + m04 + m05 + m06 + m07 + m08 + m09 + m010
              + m011 + m012 + m013 + m014 + m015 + m016 + m017 + m018 + m019;
def condup = cum > 0 and cum[1] <= 0;
def condDn = cum < 0 and cum[1] >= 0;
def barCol = if condup then 1 else
             if condDn then -1 else barCol[1];
AssignPriceColor(if !colorBars then Color.CURRENT else
                 if barCol>0 then Color.GREEN else
                 if barCol<0 then Color.RED else Color.GRAY);
AddVerticalLine(condup and showSignalLines, "Buy", Color.CYAN);
AddVerticalLine(condDn and showSignalLines, "Sell", Color.MAGENTA);
thank you kindly
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
473 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