Watchlist Columns colors

atsummer

New member
I have a script that is a watchlist column indicator that I have added but it has six columns with different colors when the condition
changes. I'm trying to convert the six different scripts into one custom column indicator with changes in colors as the condition changes.
Below is the script I am trying to convert to only one script, I've played around with it but can't get it to do my desired result. If possible I would like to add
custom labels in this script also. Does any member have any ideas or help?
Thanks

plot myVariable = SimpleMovingAvg("length" = 50)."SMA" is less than SimpleMovingAvg("length" = 200)."SMA" and close is greater than SimpleMovingAvg("length" = 50)."SMA" and close is greater than SimpleMovingAvg("length" = 200)."SMA";
AssignBackgroundColor(if myVariable then color.YELLOW else Color.WHITE);
plot myVariable = close is less than SimpleMovingAvg("length" = 50)."SMA" and
close is less than SimpleMovingAvg("length" = 200)."SMA";
AssignBackgroundColor( if myVariable then Color.DARK_RED else Color.WHITE);
plot myVariable = SimpleMovingAvg("length" = 50)."SMA" is greater than SimpleMovingAvg("length" = 200)."SMA" and close is greater than SimpleMovingAvg("length" = 50)."SMA" and close is greater than SimpleMovingAvg("length" = 200)."SMA";
AssignBackgroundColor(if myVariable then color.GREEN else Color.WHITE);
plot myVariable = SimpleMovingAvg("length" = 50)."SMA" is greater than SimpleMovingAvg("length" = 200)."SMA" and close is less than SimpleMovingAvg("length" = 50)."SMA" and close is less than SimpleMovingAvg("length" = 200)."SMA";
AssignBackgroundColor(if myVariable then color.RED else Color.WHITE);
plot myVariable = SimpleMovingAvg("length" = 50)."SMA" is less than SimpleMovingAvg("length" = 200)."SMA" and close is greater than SimpleMovingAvg("length" = 50)."SMA" and close is less than SimpleMovingAvg("length" = 200)."SMA";
AssignBackgroundColor(if myVariable then color.GRAY else Color.WHITE);
plot myVariable = SimpleMovingAvg("length" = 50)."SMA" is greater than SimpleMovingAvg("length" = 200)."SMA" and close is less than SimpleMovingAvg("length" = 50)."SMA" and close is greater than SimpleMovingAvg("length" = 200)."SMA";
AssignBackgroundColor(if myVariable then color.ORANGE else Color.WHITE);
 
Solution
I have a script that is a watchlist column indicator that I have added but it has six columns with different colors when the condition
changes. I'm trying to convert the six different scripts into one custom column indicator with changes in colors as the condition changes.
Below is the script I am trying to convert to only one script, I've played around with it but can't get it to do my desired result. If possible I would like to add
custom labels in this script also. Does any member have any ideas or help?
Thanks

plot myVariable = SimpleMovingAvg("length" = 50)."SMA" is less than SimpleMovingAvg("length" = 200)."SMA" and close is greater than SimpleMovingAvg("length" = 50)."SMA" and close is greater than...
I have a script that is a watchlist column indicator that I have added but it has six columns with different colors when the condition
changes. I'm trying to convert the six different scripts into one custom column indicator with changes in colors as the condition changes.
Below is the script I am trying to convert to only one script, I've played around with it but can't get it to do my desired result. If possible I would like to add
custom labels in this script also. Does any member have any ideas or help?
Thanks

plot myVariable = SimpleMovingAvg("length" = 50)."SMA" is less than SimpleMovingAvg("length" = 200)."SMA" and close is greater than SimpleMovingAvg("length" = 50)."SMA" and close is greater than SimpleMovingAvg("length" = 200)."SMA";
AssignBackgroundColor(if myVariable then color.YELLOW else Color.WHITE);
plot myVariable = close is less than SimpleMovingAvg("length" = 50)."SMA" and
close is less than SimpleMovingAvg("length" = 200)."SMA";
AssignBackgroundColor( if myVariable then Color.DARK_RED else Color.WHITE);
plot myVariable = SimpleMovingAvg("length" = 50)."SMA" is greater than SimpleMovingAvg("length" = 200)."SMA" and close is greater than SimpleMovingAvg("length" = 50)."SMA" and close is greater than SimpleMovingAvg("length" = 200)."SMA";
AssignBackgroundColor(if myVariable then color.GREEN else Color.WHITE);
plot myVariable = SimpleMovingAvg("length" = 50)."SMA" is greater than SimpleMovingAvg("length" = 200)."SMA" and close is less than SimpleMovingAvg("length" = 50)."SMA" and close is less than SimpleMovingAvg("length" = 200)."SMA";
AssignBackgroundColor(if myVariable then color.RED else Color.WHITE);
plot myVariable = SimpleMovingAvg("length" = 50)."SMA" is less than SimpleMovingAvg("length" = 200)."SMA" and close is greater than SimpleMovingAvg("length" = 50)."SMA" and close is less than SimpleMovingAvg("length" = 200)."SMA";
AssignBackgroundColor(if myVariable then color.GRAY else Color.WHITE);
plot myVariable = SimpleMovingAvg("length" = 50)."SMA" is greater than SimpleMovingAvg("length" = 200)."SMA" and close is less than SimpleMovingAvg("length" = 50)."SMA" and close is greater than SimpleMovingAvg("length" = 200)."SMA";
AssignBackgroundColor(if myVariable then color.ORANGE else Color.WHITE);

how did you copy those code lines? from word or..?
haven't seen lines like those before, separating codes.

next time , post each code, in their own code window, by clicking on </> in the new post header

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

your 2nd rule is different. i assumed you didn't copy all of it, so when i redid it, i made it like the other 5.

how to,
pull out similar things, assign to variables.
reference the variables to make the rule formulas.
combine at the end, to determine what is displayed

it uses 2 averages in 6 formulas, so pull out the 2 average functions and assign to 2 variables.

i made this as a chart study. should be able to load it in a column.


Code:
# column_combine_test_lower_01

def na = double.nan;
def bn = barnumber();

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

def price = close;

input ma1_len = 50;
#input ma1_type =  AverageType.EXPONENTIAL;
input ma1_type =  AverageType.simple;
def ma1 = MovingAverage(ma1_type, price, ma1_len);

input ma2_len = 200;
input ma2_type =  AverageType.simple;
def ma2 = MovingAverage(ma2_type, price, ma2_len);


#-----------------------------
#def var1 = SimpleMovingAvg("length" = 50)."SMA" is less than SimpleMovingAvg("length" = 200)."SMA" and close is greater than SimpleMovingAvg("length" = 50)."SMA" and close is greater than SimpleMovingAvg("length" = 200)."SMA";
#AssignBackgroundColor(if myVariable then Color.YELLOW else Color.WHITE);
def c1 = ma1 < ma2 and close > ma1 and close > ma2;
#-----------------------------

#  ?? missing a condition ?
#def var2 = close is less than SimpleMovingAvg("length" = 50)."SMA" and close is less than SimpleMovingAvg("length" = 200)."SMA";
#AssignBackgroundColor( if myVariable then Color.DARK_RED else Color.WHITE);
# added a condition to compare ma1 to ma2
def c2 = ma1 < ma2 and close < ma1 and close < ma2;

#-----------------------------
#def var3 = SimpleMovingAvg("length" = 50)."SMA" is greater than SimpleMovingAvg("length" = 200)."SMA" and close is greater than SimpleMovingAvg("length" = 50)."SMA" and close is greater than SimpleMovingAvg("length" = 200)."SMA";
#AssignBackgroundColor(if myVariable then Color.GREEN else Color.WHITE);
def c3 = ma1 > ma2 and close > ma1 and close > ma2;

#-----------------------------
#def var4 = SimpleMovingAvg("length" = 50)."SMA" is greater than SimpleMovingAvg("length" = 200)."SMA" and close is less than SimpleMovingAvg("length" = 50)."SMA" and close is less than SimpleMovingAvg("length" = 200)."SMA";
#AssignBackgroundColor(if myVariable then Color.RED else Color.WHITE);
def c4 = ma1 > ma2 and close < ma1 and close < ma2;

#-----------------------------
#def var5 = SimpleMovingAvg("length" = 50)."SMA" is less than SimpleMovingAvg("length" = 200)."SMA" and close is greater than SimpleMovingAvg("length" = 50)."SMA" and close is less than SimpleMovingAvg("length" = 200)."SMA";
#AssignBackgroundColor(if myVariable then Color.GRAY else Color.WHITE);
def c5 = ma1 < ma2 and close > ma1 and close < ma2;

#-----------------------------
#def var6 = SimpleMovingAvg("length" = 50)."SMA" is greater than SimpleMovingAvg("length" = 200)."SMA" and close is less than SimpleMovingAvg("length" = 50)."SMA" and close is greater than SimpleMovingAvg("length" = 200)."SMA";
#AssignBackgroundColor(if myVariable then Color.ORANGE else color.WHITE);                                                                                       
def c6 = ma1 > ma2 and close < ma1 and close > ma2;

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

addlabel(1,
(if c1 then "1"
else if c2 then "2"
else if c3 then "3"
else if c4 then "4"
else if c5 then "5"
else if c6 then "6"
else "-")
, color.black);

AssignBackgroundColor(
     if c1 then Color.YELLOW
else if c2 then Color.DARK_RED
else if c3 then Color.GREEN
else if c4 then Color.RED
else if c5 then Color.GRAY
else if c6 then Color.ORANGE
else color.WHITE); 


# -----------------
# if a test study on a chart

#input show_lines = yes;
#plot z1 = if show_lines then ma1 else na;
#z1.setdefaultcolor(getcolor(1));
#z1.hidebubble();

#plot z2 = if show_lines then ma2 else na;
#z2.setdefaultcolor(getcolor(2));
#z2.hidebubble();

#
 
Solution

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

how did you copy those code lines? from word or..?
haven't seen lines like those before, separating codes.

next time , post each code, in their own code window, by clicking on </> in the new post header

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

your 2nd rule is different. i assumed you didn't copy all of it, so when i redid it, i made it like the other 5.

how to,
pull out similar things, assign to variables.
reference the variables to make the rule formulas.
combine at the end, to determine what is displayed

it uses 2 averages in 6 formulas, so pull out the 2 average functions and assign to 2 variables.

i made this as a chart study. should be able to load it in a column.


Code:
# column_combine_test_lower_01

def na = double.nan;
def bn = barnumber();

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

def price = close;

input ma1_len = 50;
#input ma1_type =  AverageType.EXPONENTIAL;
input ma1_type =  AverageType.simple;
def ma1 = MovingAverage(ma1_type, price, ma1_len);

input ma2_len = 200;
input ma2_type =  AverageType.simple;
def ma2 = MovingAverage(ma2_type, price, ma2_len);


#-----------------------------
#def var1 = SimpleMovingAvg("length" = 50)."SMA" is less than SimpleMovingAvg("length" = 200)."SMA" and close is greater than SimpleMovingAvg("length" = 50)."SMA" and close is greater than SimpleMovingAvg("length" = 200)."SMA";
#AssignBackgroundColor(if myVariable then Color.YELLOW else Color.WHITE);
def c1 = ma1 < ma2 and close > ma1 and close > ma2;
#-----------------------------

#  ?? missing a condition ?
#def var2 = close is less than SimpleMovingAvg("length" = 50)."SMA" and close is less than SimpleMovingAvg("length" = 200)."SMA";
#AssignBackgroundColor( if myVariable then Color.DARK_RED else Color.WHITE);
# added a condition to compare ma1 to ma2
def c2 = ma1 < ma2 and close < ma1 and close < ma2;

#-----------------------------
#def var3 = SimpleMovingAvg("length" = 50)."SMA" is greater than SimpleMovingAvg("length" = 200)."SMA" and close is greater than SimpleMovingAvg("length" = 50)."SMA" and close is greater than SimpleMovingAvg("length" = 200)."SMA";
#AssignBackgroundColor(if myVariable then Color.GREEN else Color.WHITE);
def c3 = ma1 > ma2 and close > ma1 and close > ma2;

#-----------------------------
#def var4 = SimpleMovingAvg("length" = 50)."SMA" is greater than SimpleMovingAvg("length" = 200)."SMA" and close is less than SimpleMovingAvg("length" = 50)."SMA" and close is less than SimpleMovingAvg("length" = 200)."SMA";
#AssignBackgroundColor(if myVariable then Color.RED else Color.WHITE);
def c4 = ma1 > ma2 and close < ma1 and close < ma2;

#-----------------------------
#def var5 = SimpleMovingAvg("length" = 50)."SMA" is less than SimpleMovingAvg("length" = 200)."SMA" and close is greater than SimpleMovingAvg("length" = 50)."SMA" and close is less than SimpleMovingAvg("length" = 200)."SMA";
#AssignBackgroundColor(if myVariable then Color.GRAY else Color.WHITE);
def c5 = ma1 < ma2 and close > ma1 and close < ma2;

#-----------------------------
#def var6 = SimpleMovingAvg("length" = 50)."SMA" is greater than SimpleMovingAvg("length" = 200)."SMA" and close is less than SimpleMovingAvg("length" = 50)."SMA" and close is greater than SimpleMovingAvg("length" = 200)."SMA";
#AssignBackgroundColor(if myVariable then Color.ORANGE else color.WHITE);                                                                                      
def c6 = ma1 > ma2 and close < ma1 and close > ma2;

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

addlabel(1,
(if c1 then "1"
else if c2 then "2"
else if c3 then "3"
else if c4 then "4"
else if c5 then "5"
else if c6 then "6"
else "-")
, color.black);

AssignBackgroundColor(
     if c1 then Color.YELLOW
else if c2 then Color.DARK_RED
else if c3 then Color.GREEN
else if c4 then Color.RED
else if c5 then Color.GRAY
else if c6 then Color.ORANGE
else color.WHITE);


# -----------------
# if a test study on a chart

#input show_lines = yes;
#plot z1 = if show_lines then ma1 else na;
#z1.setdefaultcolor(getcolor(1));
#z1.hidebubble();

#plot z2 = if show_lines then ma2 else na;
#z2.setdefaultcolor(getcolor(2));
#z2.hidebubble();

#
Thanks worked perfectly. Forgive my sloppiness but I'm new at this and trying to learn as I go.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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