A 5 MA Ribbon, With Dynamic Trend-Based Coloring?

drizzla

Member
On many of my charts, I use a single study with 5 moving averages in color-gradient band/ribbon. This allows quick visual reference of the overall trend. I currently use a purple variant; the darker the hue, the longer the MA timeframe (Figure 1).

I have an idea for a new direction I'd like to take this study, if anyone can lend a hand. I am not sure if what I am looking for is even possible.

There are dynamic moving average ribbon studies that can flip from green to red, depending on the trend, but display no gradient (Figure 2: Madrid Moving Average Ribbon, by @Xiuying).

There is the "MovAvgExpRibbon" study baked right into ToS, but it does not change color based on trend, similar to my original study. (Figure 3)

My end goal is something like Figure 4: it displays 5 key moving averages, with a gradient from shortest to longest MA, that flips dynamically from green to red and back, depending on the overall trend (and stays painted on the chart as it was at the time, like Figure 2). Say, when the 50 crosses over the 20 or 100 MA. (I am 100% open to suggestions if there is a more meaningful crossover point to display overall trend!)

On the red side, the longer MA would be the lighter color, showing essentially the inverse and strength of bearish trend.

I would love to be able to chance the moving average type, and length of each of the MAs in the study setting/customization window. Is this even possible, and would anyone be able to help me out? Thanks!


Side note: on Figure 1, it looks weird on certain monitors. On the monitor I keep generally these charts on, there is a greater contrast visible between the 5 different purple gradient colors.
 
Last edited:
On many of my charts, I use a single study with 5 moving averages in color-gradient band/ribbon. This allows quick visual reference of the overall trend. I currently use a purple variant; the darker the hue, the longer the MA timeframe (Figure 1).

I have an idea for a new direction I'd like to take this study, if anyone can lend a hand. I am not sure if what I am looking for is even possible.

There are dynamic moving average ribbon studies that can flip from green to red, depending on the trend, but display no gradient (Figure 2: Madrid Moving Average Ribbon, by @Xiuying).

There is the "MovAvgExpRibbon" study baked right into ToS, but it does not change color based on trend, similar to my original study. (Figure 3)

My end goal is something like Figure 4: it displays 5 key moving averages, with a gradient from shortest to longest MA, that flips dynamically from green to red and back, depending on the overall trend (and stays painted on the chart as it was at the time, like Figure 2). Say, when the 50 crosses over the 20 or 100 MA. (I am 100% open to suggestions if there is a more meaningful crossover point to display overall trend!)

On the red side, the longer MA would be the lighter color, showing essentially the inverse and strength of bearish trend.

I would love to be able to chance the moving average type, and length of each of the MAs in the study setting/customization window. Is this even possible, and would anyone be able to help me out? Thanks!


Side note: on Figure 1, it looks weird on certain monitors. On the monitor I keep generally these charts on, there is a greater contrast visible between the 5 different purple gradient colors.


please bear with me , as i ask some questions, to help clarify your request.

i am confused by gradient. gradient implies 1 thing changing, as in 1 line changing to many colors.
but i think you want 5 lines, each one a different SHADE of red or green.

why didn't you post the code for fig.1, then we would have a starting point with your settings?

what are your preferred default settings for the averages? length, type

if fig.4 is what you want, why not use it?
if fig.4 is close to what you want, then why didn't you post the code for it, for others to have a starting point?


-----------------------
here are the links you mentioned

Madrid Moving Average Ribbons for ThinkorSwim , by Xiuying
https://usethinkscript.com/threads/madrid-moving-average-ribbons-for-thinkorswim.3122/

MovAvgExpRibbon
https://tlc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/M-N/MovAvgExpRibbon

-----------------------


i copied that madrid study and modified it.
you didn't mention any of your settings, so i guessed at average lengths. 10,25,40,55,70
i added average formulas and parameters for 5. can choose type and length.

this isn't quite what you asked for, but hopefully it is a starting point.
i don't understand the purpose of having a bunch of similarly color shaded lines, starting and stopping at the same bar. might as well just have 1 line.
i think it gives more information to see line colors changing independently. to see 1 or 2 change color, to indicate something might happen soon.
i kept the plot color rules from the madrid study. it checks the price change of each line, bar to bar, and compares the shortest length average to the longest one. from those 2 conditions, it creates 4 color possibilities ( + flat).

line colors,
green , short length is moving up , line change is up
blue , short length is moving up , line change is down
gray , price changes are the same
yellow , short length is moving down , line change is up
red , short length is moving down , line change is down

there are 5 labels, one for each line, that
..match the color of the line
..describe the type and length of the average ( EMA10 )



Ruby:
# avg_ribbon_5x_colors_00

# Q
#https://usethinkscript.com/threads/a-5-ma-ribbon-with-dynamic-trend-based-coloring.12983/

# ref - copy the line color rules from here
# https://usethinkscript.com/threads/madrid-moving-average-ribbons-for-thinkorswim.3122/
# Madrid Moving Average Ribbons for ThinkorSwim


def na = Double.NaN;
def bn = BarNumber();

# last bar  ( most recent)
#def lastbar = !isnan(close[0]) and isnan(close[-1]);

# up , up_rev , down_rev , down
DefineGlobalColor("up", color.green);
DefineGlobalColor("up_rev", color.blue);
DefineGlobalColor("flat", color.gray);
DefineGlobalColor("down_rev", color.yellow);
DefineGlobalColor("down", color.red);

# GlobalColor("up")
# GlobalColor("up_rev")
# GlobalColor("flat")
# GlobalColor("down_rev")
# GlobalColor("down")

#-------------------------

# ma1 should be the shortest length average
# ma5 should be the longest length average

def price = close;

input ma1_len = 10;
input ma1_type =  AverageType.EXPONENTIAL;
def ma1 = MovingAverage(ma1_type, price, ma1_len);

input ma2_len = 25;
input ma2_type =  AverageType.EXPONENTIAL;
def ma2 = MovingAverage(ma2_type, price, ma2_len);

input ma3_len = 40;
input ma3_type =  AverageType.EXPONENTIAL;
def ma3 = MovingAverage(ma3_type, price, ma3_len);

input ma4_len = 55;
input ma4_type =  AverageType.EXPONENTIAL;
def ma4 = MovingAverage(ma4_type, price, ma4_len);

input ma5_len = 70;
input ma5_type =  AverageType.EXPONENTIAL;
def ma5 = MovingAverage(ma5_type, price, ma5_len);

#def up1 = (ma1 crosses above ma5);
#def dwn1 = (ma1 crosses below ma5);

#---------------------------

input show_lines = yes;

plot z1 = if show_lines then ma1 else na;
#z1.SetDefaultColor(GetColor(1));
#z1.setlineweight(1);
z1.HideBubble();
#z1.SetStyle(Curve.MEDIUM_DASH);

plot z2 = if show_lines then ma2 else na;
#z2.SetDefaultColor(GetColor(2));
#z2.setlineweight(1);
z2.HideBubble();

plot z3 = if show_lines then ma3 else na;
#z3.SetDefaultColor(GetColor(3));
#z3.setlineweight(1);
z3.HideBubble();

plot z4 = if show_lines then ma4 else na;
#z4.SetDefaultColor(GetColor(4));
#z4.setlineweight(1);
z4.HideBubble();

plot z5 = if show_lines then ma5 else na;
#z4.SetDefaultColor(GetColor(5));
#z4.setlineweight(1);
z4.HideBubble();

#----------------------------

z1.AssignValueColor(
     if ma1 > ma1[1] and ma1 > ma5 then GlobalColor("up")
else if ma1 < ma1[1] and ma1 > ma5 then GlobalColor("up_rev")
else if ma1 < ma1[1] and ma1 < ma5 then GlobalColor("down")
else if ma1 > ma1[1] and ma1 < ma5 then GlobalColor("down_rev")
else GlobalColor("flat"));

z2.AssignValueColor(
     if ma2 > ma2[1] and ma1 > ma5 then GlobalColor("up")
else if ma2 < ma2[1] and ma1 > ma5 then GlobalColor("up_rev")
else if ma2 < ma2[1] and ma1 < ma5 then GlobalColor("down")
else if ma2 > ma2[1] and ma1 < ma5 then GlobalColor("down_rev")
else GlobalColor("flat"));

z3.AssignValueColor(
     if ma3 > ma3[1] and ma1 > ma5 then GlobalColor("up")
else if ma3 < ma3[1] and ma1 > ma5 then GlobalColor("up_rev")
else if ma3 < ma3[1] and ma1 < ma5 then GlobalColor("down")
else if ma3 > ma3[1] and ma1 < ma5 then GlobalColor("down_rev")
else GlobalColor("flat"));

z4.AssignValueColor(
     if ma4 > ma4[1] and ma1 > ma5 then GlobalColor("up")
else if ma4 < ma4[1] and ma1 > ma5 then GlobalColor("up_rev")
else if ma4 < ma4[1] and ma1 < ma5 then GlobalColor("down")
else if ma4 > ma4[1] and ma1 < ma5 then GlobalColor("down_rev")
else GlobalColor("flat"));

z5.AssignValueColor(
     if ma5 > ma5[1] and ma1 > ma5 then GlobalColor("up")
else if ma5 < ma5[1] and ma1 > ma5 then GlobalColor("up_rev")
else if ma5 < ma5[1] and ma1 < ma5 then GlobalColor("down")
else if ma5 > ma5[1] and ma1 < ma5 then GlobalColor("down_rev")
else GlobalColor("flat"));

#----------------------------

# labels
#input ma1_len = 10;
#input ma1_type =  AverageType.EXPONENTIAL;

input show_labels = yes;

addlabel(show_labels,
    (if ma1_type == AverageType.simple then "MA"
else if ma1_type == AverageType.EXPONENTIAL then "EMA"
else if ma1_type == AverageType.hull then "HULL"
else if ma1_type == AverageType.WEIGHTED then "WT"
else if ma1_type == AverageType.WILDERS then "WILD"
else "-") + ma1_len
, z1.TakeValueColor());

addlabel(show_labels,
    (if ma2_type == AverageType.simple then "MA"
else if ma2_type == AverageType.EXPONENTIAL then "EMA"
else if ma2_type == AverageType.hull then "HULL"
else if ma2_type == AverageType.WEIGHTED then "WT"
else if ma2_type == AverageType.WILDERS then "WILD"
else "-") +  ma2_len
, z2.TakeValueColor());

addlabel(show_labels,
    (if ma3_type == AverageType.simple then "MA"
else if ma3_type == AverageType.EXPONENTIAL then "EMA"
else if ma3_type == AverageType.hull then "HULL"
else if ma3_type == AverageType.WEIGHTED then "WT"
else if ma3_type == AverageType.WILDERS then "WILD"
else "-") +  ma3_len
, z3.TakeValueColor());

addlabel(show_labels,
    (if ma4_type == AverageType.simple then "MA"
else if ma4_type == AverageType.EXPONENTIAL then "EMA"
else if ma4_type == AverageType.hull then "HULL"
else if ma4_type == AverageType.WEIGHTED then "WT"
else if ma4_type == AverageType.WILDERS then "WILD"
else "-") +  ma4_len
, z4.TakeValueColor());

addlabel(show_labels,
    (if ma5_type == AverageType.simple then "MA"
else if ma5_type == AverageType.EXPONENTIAL then "EMA"
else if ma5_type == AverageType.hull then "HULL"
else if ma5_type == AverageType.WEIGHTED then "WT"
else if ma5_type == AverageType.WILDERS then "WILD"
else "-") +  ma5_len
, z5.TakeValueColor());

#--------------------------

# ref
#https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Tech-Analysis/MovingAverage

# https://tlc.thinkorswim.com/center/reference/thinkScript/Constants/AverageType
# ..AverageTypes..
# EXPONENTIAL
# HULL
# SIMPLE
# WEIGHTED
# WILDERS

#

1KZ1JV2.jpg

HItfla3.jpg

TmGJ7qL.jpg


showing different average types
Gy8mLrc.jpg


-----------------------
sites for picking colors

pick 2 colors and a quantity and generate a list of colors between them
https://colordesigner.io/gradient-generator

https://www.w3schools.com/colors/colors_picker.asp
 
Last edited:
please bear with me , as i ask some questions, to help clarify your request.

i am confused by gradient. gradient implies 1 thing changing, as in 1 line changing to many colors.
but i think you want 5 lines, each one a different SHADE of red or green.

why didn't you post the code for fig.1, then we would have a starting point with your settings?

what are your preferred default settings for the averages? length, type

if fig.4 is what you want, why not use it?
if fig.4 is close to what you want, then why didn't you post the code for it, for others to have a starting point?


-----------------------
here are the links you mentioned

Madrid Moving Average Ribbons for ThinkorSwim , by Xiuying
https://usethinkscript.com/threads/madrid-moving-average-ribbons-for-thinkorswim.3122/

MovAvgExpRibbon
https://tlc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/M-N/MovAvgExpRibbon

-----------------------


i copied that madrid study and modified it.
you didn't mention any of your settings, so i guessed at average lengths. 10,25,40,55,70
i added average formulas and parameters for 5. can choose type and length.

this isn't quite what you asked for, but hopefully it is a starting point.
i don't understand the purpose of having a bunch of similarly color shaded lines, starting and stopping at the same bar. might as well just have 1 line.
i think it gives more information to see line colors changing independently. to see 1 or 2 change color, to indicate something might happen soon.
i kept the plot color rules from the madrid study. it checks the price change of each line, bar to bar, and compares the shortest length average to the longest one. from those 2 conditions, it creates 4 color possibilities ( + flat).

line colors,
green , short length is moving up , line change is up
blue , short length is moving up , line change is down
gray , price changes are the same
yellow , short length is moving down , line change is up
red , short length is moving down , line change is down

there are 5 labels, one for each line, that
..match the color of the line
..describe the type and length of the average ( EMA10 )



Ruby:
# avg_ribbon_5x_colors_00

# Q
#https://usethinkscript.com/threads/a-5-ma-ribbon-with-dynamic-trend-based-coloring.12983/

# ref - copy the line color rules from here
# https://usethinkscript.com/threads/madrid-moving-average-ribbons-for-thinkorswim.3122/
# Madrid Moving Average Ribbons for ThinkorSwim


def na = Double.NaN;
def bn = BarNumber();

# last bar  ( most recent)
#def lastbar = !isnan(close[0]) and isnan(close[-1]);

# up , up_rev , down_rev , down
DefineGlobalColor("up", color.green);
DefineGlobalColor("up_rev", color.blue);
DefineGlobalColor("flat", color.gray);
DefineGlobalColor("down_rev", color.yellow);
DefineGlobalColor("down", color.red);

# GlobalColor("up")
# GlobalColor("up_rev")
# GlobalColor("flat")
# GlobalColor("down_rev")
# GlobalColor("down")

#-------------------------

# ma1 should be the shortest length average
# ma5 should be the longest length average

def price = close;

input ma1_len = 10;
input ma1_type =  AverageType.EXPONENTIAL;
def ma1 = MovingAverage(ma1_type, price, ma1_len);

input ma2_len = 25;
input ma2_type =  AverageType.EXPONENTIAL;
def ma2 = MovingAverage(ma2_type, price, ma2_len);

input ma3_len = 40;
input ma3_type =  AverageType.EXPONENTIAL;
def ma3 = MovingAverage(ma3_type, price, ma3_len);

input ma4_len = 55;
input ma4_type =  AverageType.EXPONENTIAL;
def ma4 = MovingAverage(ma4_type, price, ma4_len);

input ma5_len = 70;
input ma5_type =  AverageType.EXPONENTIAL;
def ma5 = MovingAverage(ma5_type, price, ma5_len);

#def up1 = (ma1 crosses above ma5);
#def dwn1 = (ma1 crosses below ma5);

#---------------------------

input show_lines = yes;

plot z1 = if show_lines then ma1 else na;
#z1.SetDefaultColor(GetColor(1));
#z1.setlineweight(1);
z1.HideBubble();
#z1.SetStyle(Curve.MEDIUM_DASH);

plot z2 = if show_lines then ma2 else na;
#z2.SetDefaultColor(GetColor(2));
#z2.setlineweight(1);
z2.HideBubble();

plot z3 = if show_lines then ma3 else na;
#z3.SetDefaultColor(GetColor(3));
#z3.setlineweight(1);
z3.HideBubble();

plot z4 = if show_lines then ma4 else na;
#z4.SetDefaultColor(GetColor(4));
#z4.setlineweight(1);
z4.HideBubble();

plot z5 = if show_lines then ma5 else na;
#z4.SetDefaultColor(GetColor(5));
#z4.setlineweight(1);
z4.HideBubble();

#----------------------------

z1.AssignValueColor(
     if ma1 > ma1[1] and ma1 > ma5 then GlobalColor("up")
else if ma1 < ma1[1] and ma1 > ma5 then GlobalColor("up_rev")
else if ma1 < ma1[1] and ma1 < ma5 then GlobalColor("down")
else if ma1 > ma1[1] and ma1 < ma5 then GlobalColor("down_rev")
else GlobalColor("flat"));

z2.AssignValueColor(
     if ma2 > ma2[1] and ma1 > ma5 then GlobalColor("up")
else if ma2 < ma2[1] and ma1 > ma5 then GlobalColor("up_rev")
else if ma2 < ma2[1] and ma1 < ma5 then GlobalColor("down")
else if ma2 > ma2[1] and ma1 < ma5 then GlobalColor("down_rev")
else GlobalColor("flat"));

z3.AssignValueColor(
     if ma3 > ma3[1] and ma1 > ma5 then GlobalColor("up")
else if ma3 < ma3[1] and ma1 > ma5 then GlobalColor("up_rev")
else if ma3 < ma3[1] and ma1 < ma5 then GlobalColor("down")
else if ma3 > ma3[1] and ma1 < ma5 then GlobalColor("down_rev")
else GlobalColor("flat"));

z4.AssignValueColor(
     if ma4 > ma4[1] and ma1 > ma5 then GlobalColor("up")
else if ma4 < ma4[1] and ma1 > ma5 then GlobalColor("up_rev")
else if ma4 < ma4[1] and ma1 < ma5 then GlobalColor("down")
else if ma4 > ma4[1] and ma1 < ma5 then GlobalColor("down_rev")
else GlobalColor("flat"));

z5.AssignValueColor(
     if ma5 > ma5[1] and ma1 > ma5 then GlobalColor("up")
else if ma5 < ma5[1] and ma1 > ma5 then GlobalColor("up_rev")
else if ma5 < ma5[1] and ma1 < ma5 then GlobalColor("down")
else if ma5 > ma5[1] and ma1 < ma5 then GlobalColor("down_rev")
else GlobalColor("flat"));

#----------------------------

# labels
#input ma1_len = 10;
#input ma1_type =  AverageType.EXPONENTIAL;

input show_labels = yes;

addlabel(show_labels,
    (if ma1_type == AverageType.simple then "MA"
else if ma1_type == AverageType.EXPONENTIAL then "EMA"
else if ma1_type == AverageType.hull then "HULL"
else if ma1_type == AverageType.WEIGHTED then "WT"
else if ma1_type == AverageType.WILDERS then "WILD"
else "-") + ma1_len
, z1.TakeValueColor());

addlabel(show_labels,
    (if ma2_type == AverageType.simple then "MA"
else if ma2_type == AverageType.EXPONENTIAL then "EMA"
else if ma2_type == AverageType.hull then "HULL"
else if ma2_type == AverageType.WEIGHTED then "WT"
else if ma2_type == AverageType.WILDERS then "WILD"
else "-") +  ma2_len
, z2.TakeValueColor());

addlabel(show_labels,
    (if ma3_type == AverageType.simple then "MA"
else if ma3_type == AverageType.EXPONENTIAL then "EMA"
else if ma3_type == AverageType.hull then "HULL"
else if ma3_type == AverageType.WEIGHTED then "WT"
else if ma3_type == AverageType.WILDERS then "WILD"
else "-") +  ma3_len
, z3.TakeValueColor());

addlabel(show_labels,
    (if ma4_type == AverageType.simple then "MA"
else if ma4_type == AverageType.EXPONENTIAL then "EMA"
else if ma4_type == AverageType.hull then "HULL"
else if ma4_type == AverageType.WEIGHTED then "WT"
else if ma4_type == AverageType.WILDERS then "WILD"
else "-") +  ma4_len
, z4.TakeValueColor());

addlabel(show_labels,
    (if ma5_type == AverageType.simple then "MA"
else if ma5_type == AverageType.EXPONENTIAL then "EMA"
else if ma5_type == AverageType.hull then "HULL"
else if ma5_type == AverageType.WEIGHTED then "WT"
else if ma5_type == AverageType.WILDERS then "WILD"
else "-") +  ma5_len
, z5.TakeValueColor());

#--------------------------

# ref
#https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Tech-Analysis/MovingAverage

# https://tlc.thinkorswim.com/center/reference/thinkScript/Constants/AverageType
# ..AverageTypes..
# EXPONENTIAL
# HULL
# SIMPLE
# WEIGHTED
# WILDERS

#

1KZ1JV2.jpg

HItfla3.jpg

TmGJ7qL.jpg


showing different average types
Gy8mLrc.jpg


-----------------------
sites for picking colors

pick 2 colors and a quantity and generate a list of colors between them
https://colordesigner.io/gradient-generator

https://www.w3schools.com/colors/colors_picker.asp

Thank you so much for your help! This is looking awesome.

(1) You are right, my misnomer with "gradient" — I was manually assigning the colors to each MA in a gradient-like color scheme, from darker to lighter hue of that selected color.

(2) Here is the [very basic] code of the current purple one I am using:

Code:
input ma1 = 9;
input ma2 = 20;
input ma3 = 50;
input ma4 = 100;
input ma5 = 200;
input offset = 0;

def c = close;
def n = double.nan;

plot sma1 = if !isnan(c) then simplemovingavg(c,ma1)[offset] else n;
sma1.setdefaultcolor(color.cyan);
sma1.hidebubble();
plot sma2 = if !isnan(c) then simplemovingavg(c,ma2)[offset] else n;
sma2.setdefaultcolor(createcolor(0,51,51));
sma2.hidebubble();
plot sma3 = if !isnan(c) then simplemovingavg(c,ma3)[offset] else n;
sma3.setdefaultcolor(color.magenta);
sma3.hidebubble();
plot sma4 = if !isnan(c) then simplemovingavg(c,ma4)[offset] else n;
sma4.setdefaultcolor(createcolor(0,34,34));
sma4.hidebubble();
plot sma5 = if !isnan(c) then simplemovingavg(c,ma5)[offset] else n;
sma5.setdefaultcolor(createcolor(0,34,34));
sma5.hidebubble();

I suppose the ideal color gradient would look like this:


I do like having the ability to manually change the colors of each MA in the study settings/customization options. But I am not sure if it's both possible to retain that ability, while also having it automatically change colors when the trend changes. (I have seen some studies where it says "This plot's colors are dynamically set." So I am wondering if that would apply in this situation as well. It would be great to be able to have the chart color change based on trend, but be able to manually set what those individual MA colors are, too.

I really like what you did with the transitional blue and yellow, as the trend is changing. I would definitely opt to keep that!
I also love the addition of the Moving Average bubbles up top.

(3) I would say I mostly use Exponential and Simple MAs, 9, 20, 50, 100, 200 lengths. But I have also been experimenting with Hull MAs recently.

(4) Figure 4 was me pasting together two screenshots of charts where I had a manually changed the purple colors in the original study to red, and then green, and screenshotted it each time. So it's not actually changing on it's own. Sorry for the confusion on that!

Thank you again!
 
Thank you so much for your help! This is looking awesome.

(1) You are right, my misnomer with "gradient" — I was manually assigning the colors to each MA in a gradient-like color scheme, from darker to lighter hue of that selected color.

(2) Here is the [very basic] code of the current purple one I am using:

Code:
input ma1 = 9;
input ma2 = 20;
input ma3 = 50;
input ma4 = 100;
input ma5 = 200;
input offset = 0;

def c = close;
def n = double.nan;

plot sma1 = if !isnan(c) then simplemovingavg(c,ma1)[offset] else n;
sma1.setdefaultcolor(color.cyan);
sma1.hidebubble();
plot sma2 = if !isnan(c) then simplemovingavg(c,ma2)[offset] else n;
sma2.setdefaultcolor(createcolor(0,51,51));
sma2.hidebubble();
plot sma3 = if !isnan(c) then simplemovingavg(c,ma3)[offset] else n;
sma3.setdefaultcolor(color.magenta);
sma3.hidebubble();
plot sma4 = if !isnan(c) then simplemovingavg(c,ma4)[offset] else n;
sma4.setdefaultcolor(createcolor(0,34,34));
sma4.hidebubble();
plot sma5 = if !isnan(c) then simplemovingavg(c,ma5)[offset] else n;
sma5.setdefaultcolor(createcolor(0,34,34));
sma5.hidebubble();

I suppose the ideal color gradient would look like this:


I do like having the ability to manually change the colors of each MA in the study settings/customization options. But I am not sure if it's both possible to retain that ability, while also having it automatically change colors when the trend changes. (I have seen some studies where it says "This plot's colors are dynamically set." So I am wondering if that would apply in this situation as well. It would be great to be able to have the chart color change based on trend, but be able to manually set what those individual MA colors are, too.

I really like what you did with the transitional blue and yellow, as the trend is changing. I would definitely opt to keep that!
I also love the addition of the Moving Average bubbles up top.

(3) I would say I mostly use Exponential and Simple MAs, 9, 20, 50, 100, 200 lengths. But I have also been experimenting with Hull MAs recently.

(4) Figure 4 was me pasting together two screenshots of charts where I had a manually changed the purple colors in the original study to red, and then green, and screenshotted it each time. So it's not actually changing on it's own. Sorry for the confusion on that!

Thank you again!


will read thru this tonight...

can use this combined with if then and colors to plot different colors based on different conditions

https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Look---Feel/AssignValueColor
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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