Stacking MAs Watchlist Column Help

SeeminglyBD

New member
Can someone please take a look at this code and let me know what I am doing wrong? All I am trying to do is have a green box if the bullish signal is fired within 3 bars and a red box if the bearish signal is fired within 3 bars, all else black box. I don't need the 1 or the NaN in black boxes. Thanks for taking a look. This is a free indicator on Satyland.com



script Saty_Pivot_Ribbon {
# Saty Pivot Ribbon
# Copyright (C) 2022 Saty Mahajan
#
# A 3 EMA Ribbon system that simplifies measuring and using emas for trend and support/resistance.
# Special thanks to Ripster for his education and EMA Clouds which inspired this indicator.

# Settings
input Fast_EMA = 8;
input Pivot_EMA = 21;
input Slow_EMA = 34;
input Highlight_Fast = no;
input Highlight_Pivot = no;
input Highlight_Slow = no;
input Show_Conviction_Arrows = yes;
input Conviction_Arrow_Size = 2;
input Fast_Conviction_EMA = 13;
input Slow_Conviction_EMA = 48;
input Show_Fast_Conviction_EMA = yes;
input Show_Slow_Conviction_EMA = yes;

# Calculations
def price = close;
def FastValue = ExpAverage(price, Fast_EMA);
def PivotValue = ExpAverage(price, Pivot_EMA);
def SlowValue = ExpAverage(price, Slow_EMA);
def Fast_Conviction_Value = ExpAverage(price, Fast_Conviction_EMA);
def Slow_Conviction_Value = ExpAverage(price, Slow_Conviction_EMA);

# Add Clouds
DefineGlobalColor("Fast Long", Color.GREEN);
DefineGlobalColor("Fast Short", Color.RED);
AddCloud(FastValue, PivotValue, GlobalColor("Fast Long"), GlobalColor("Fast Short"));
DefineGlobalColor("Slow Long", Color.CYAN);
DefineGlobalColor("Slow Short", Color.LIGHT_ORANGE);
AddCloud(PivotValue, SlowValue, GlobalColor("Slow Long"), GlobalColor("Slow Short"));

# Add Pivot Plot
DefineGlobalColor("Pivot Highlight", Color.LIGHT_GRAY);
plot Pivot = if Highlight_Pivot then PivotValue else Double.nan;
Pivot.AssignValueColor(GlobalColor("Pivot Highlight"));

# Add Fast Plot
DefineGlobalColor("Fast Highlight", Color.LIGHT_GRAY);
plot Fast = if Highlight_Fast then FastValue else Double.nan;
Pivot.AssignValueColor(GlobalColor("Fast Highlight"));

# Add Slow Plot
DefineGlobalColor("Slow Highlight", Color.LIGHT_GRAY);
plot Slow = if Highlight_Slow then SlowValue else Double.nan;
Pivot.AssignValueColor(GlobalColor("Slow Highlight"));

# Conviction Arrows (default based on 13/48)
# Read more about that combo here: http://etfhq.com/blog/2013/01/15/golden-cross-which-is-the-best/#Top
DefineGlobalColor("Bullish Conviction Arrow", Color.CYAN);
DefineGlobalColor("Bearish Conviction Arrow", Color.ORANGE);
def bullish_conviction = Fast_Conviction_Value >= Slow_Conviction_Value;
def bearish_conviction = Fast_Conviction_Value < Slow_Conviction_Value;
def bullish_conviction_confirmed = (bullish_conviction == YES and bullish_conviction[1] == NO);
def bearish_conviction_confirmed = (bearish_conviction == YES and bearish_conviction[1] == NO);
plot bullish_conviction_signal = if bullish_conviction_confirmed and Show_Conviction_Arrows then close else Double.NaN;
plot bearish_conviction_signal = if bearish_conviction_confirmed and Show_Conviction_Arrows then close else Double.NaN;
bullish_conviction_signal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
bullish_conviction_signal.AssignValueColor(GlobalColor("Bullish Conviction Arrow"));
bullish_conviction_signal.SetLineWeight(Conviction_Arrow_Size);
bullish_conviction_signal.HideBubble();
bearish_conviction_signal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
bearish_conviction_signal.AssignValueColor(GlobalColor("Bearish Conviction Arrow"));
bearish_conviction_signal.SetLineWeight(Conviction_Arrow_Size);
bearish_conviction_signal.HideBubble();
plot fast_conviction_ema_signal = if Show_Fast_Conviction_EMA then Fast_Conviction_Value else Double.NaN;
fast_conviction_ema_signal.setDefaultColor(Color.LIGHT_GRAY);
fast_conviction_ema_signal.HideBubble();
fast_conviction_ema_signal.SetLineWeight(1);
plot slow_conviction_ema_signal = if Show_Slow_Conviction_EMA then Slow_Conviction_Value else Double.NaN;
slow_conviction_ema_signal.setDefaultColor(Color.PLUM);
slow_conviction_ema_signal.HideBubble();
slow_conviction_ema_signal.SetLineWeight(1);
}
plot signal = if Saty_Pivot_Ribbon()."bullish_conviction_signal" is true within 3 bars then 1 else if Saty_Pivot_Ribbon()."bullish_conviction_signal" is false then 0 else 9;
signal.AssignValueColor(if signal == 1 then Color.White else if signal == 2 then Color.Black else Color.White);
signal.AssignValueColor(if signal == 2 then Color.Dark_Green else if signal == 1 then Color.White else Color.White);
AssignBackgroundColor(if signal == 1 then Color.Dark_Green else if signal == 2 then Color.Black else Color.White);
 

Attachments

  • Watchlist.jpg
    Watchlist.jpg
    75.6 KB · Views: 131
Solution
Can someone please take a look at this code and let me know what I am doing wrong? All I am trying to do is have a green box if the bullish signal is fired within 3 bars and a red box if the bearish signal is fired within 3 bars, all else black box. I don't need the 1 or the NaN in black boxes. Thanks for taking a look. This is a free indicator on Satyland.com



script Saty_Pivot_Ribbon {
# Saty Pivot Ribbon
# Copyright (C) 2022 Saty Mahajan
#
# A 3 EMA Ribbon system that simplifies measuring and using emas for trend and support/resistance.
# Special thanks to Ripster for his education and EMA Clouds which inspired this indicator.

# Settings
input Fast_EMA = 8;
input Pivot_EMA = 21;
input Slow_EMA = 34;
input Highlight_Fast =...
Can someone please take a look at this code and let me know what I am doing wrong? All I am trying to do is have a green box if the bullish signal is fired within 3 bars and a red box if the bearish signal is fired within 3 bars, all else black box. I don't need the 1 or the NaN in black boxes. Thanks for taking a look. This is a free indicator on Satyland.com



script Saty_Pivot_Ribbon {
# Saty Pivot Ribbon
# Copyright (C) 2022 Saty Mahajan
#
# A 3 EMA Ribbon system that simplifies measuring and using emas for trend and support/resistance.
# Special thanks to Ripster for his education and EMA Clouds which inspired this indicator.

# Settings
input Fast_EMA = 8;
input Pivot_EMA = 21;
input Slow_EMA = 34;
input Highlight_Fast = no;
input Highlight_Pivot = no;
input Highlight_Slow = no;
input Show_Conviction_Arrows = yes;
input Conviction_Arrow_Size = 2;
input Fast_Conviction_EMA = 13;
input Slow_Conviction_EMA = 48;
input Show_Fast_Conviction_EMA = yes;
input Show_Slow_Conviction_EMA = yes;

# Calculations
def price = close;
def FastValue = ExpAverage(price, Fast_EMA);
def PivotValue = ExpAverage(price, Pivot_EMA);
def SlowValue = ExpAverage(price, Slow_EMA);
def Fast_Conviction_Value = ExpAverage(price, Fast_Conviction_EMA);
def Slow_Conviction_Value = ExpAverage(price, Slow_Conviction_EMA);

# Add Clouds
DefineGlobalColor("Fast Long", Color.GREEN);
DefineGlobalColor("Fast Short", Color.RED);
AddCloud(FastValue, PivotValue, GlobalColor("Fast Long"), GlobalColor("Fast Short"));
DefineGlobalColor("Slow Long", Color.CYAN);
DefineGlobalColor("Slow Short", Color.LIGHT_ORANGE);
AddCloud(PivotValue, SlowValue, GlobalColor("Slow Long"), GlobalColor("Slow Short"));

# Add Pivot Plot
DefineGlobalColor("Pivot Highlight", Color.LIGHT_GRAY);
plot Pivot = if Highlight_Pivot then PivotValue else Double.nan;
Pivot.AssignValueColor(GlobalColor("Pivot Highlight"));

# Add Fast Plot
DefineGlobalColor("Fast Highlight", Color.LIGHT_GRAY);
plot Fast = if Highlight_Fast then FastValue else Double.nan;
Pivot.AssignValueColor(GlobalColor("Fast Highlight"));

# Add Slow Plot
DefineGlobalColor("Slow Highlight", Color.LIGHT_GRAY);
plot Slow = if Highlight_Slow then SlowValue else Double.nan;
Pivot.AssignValueColor(GlobalColor("Slow Highlight"));

# Conviction Arrows (default based on 13/48)
# Read more about that combo here: http://etfhq.com/blog/2013/01/15/golden-cross-which-is-the-best/#Top
DefineGlobalColor("Bullish Conviction Arrow", Color.CYAN);
DefineGlobalColor("Bearish Conviction Arrow", Color.ORANGE);
def bullish_conviction = Fast_Conviction_Value >= Slow_Conviction_Value;
def bearish_conviction = Fast_Conviction_Value < Slow_Conviction_Value;
def bullish_conviction_confirmed = (bullish_conviction == YES and bullish_conviction[1] == NO);
def bearish_conviction_confirmed = (bearish_conviction == YES and bearish_conviction[1] == NO);
plot bullish_conviction_signal = if bullish_conviction_confirmed and Show_Conviction_Arrows then close else Double.NaN;
plot bearish_conviction_signal = if bearish_conviction_confirmed and Show_Conviction_Arrows then close else Double.NaN;
bullish_conviction_signal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
bullish_conviction_signal.AssignValueColor(GlobalColor("Bullish Conviction Arrow"));
bullish_conviction_signal.SetLineWeight(Conviction_Arrow_Size);
bullish_conviction_signal.HideBubble();
bearish_conviction_signal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
bearish_conviction_signal.AssignValueColor(GlobalColor("Bearish Conviction Arrow"));
bearish_conviction_signal.SetLineWeight(Conviction_Arrow_Size);
bearish_conviction_signal.HideBubble();
plot fast_conviction_ema_signal = if Show_Fast_Conviction_EMA then Fast_Conviction_Value else Double.NaN;
fast_conviction_ema_signal.setDefaultColor(Color.LIGHT_GRAY);
fast_conviction_ema_signal.HideBubble();
fast_conviction_ema_signal.SetLineWeight(1);
plot slow_conviction_ema_signal = if Show_Slow_Conviction_EMA then Slow_Conviction_Value else Double.NaN;
slow_conviction_ema_signal.setDefaultColor(Color.PLUM);
slow_conviction_ema_signal.HideBubble();
slow_conviction_ema_signal.SetLineWeight(1);
}
plot signal = if Saty_Pivot_Ribbon()."bullish_conviction_signal" is true within 3 bars then 1 else if Saty_Pivot_Ribbon()."bullish_conviction_signal" is false then 0 else 9;
signal.AssignValueColor(if signal == 1 then Color.White else if signal == 2 then Color.Black else Color.White);
signal.AssignValueColor(if signal == 2 then Color.Dark_Green else if signal == 1 then Color.White else Color.White);
AssignBackgroundColor(if signal == 1 then Color.Dark_Green else if signal == 2 then Color.Black else Color.White);



i don't know what the original code looked like and what you changed, so i will just list some observations,


...this is way overly complicated for just wanting to know when 1 average is above another.

...there is no need to use script { } , the code is called just once. and there are no parameters.
...code within a script {} only generates a number. it doesn't draw anything.
......it can't define colors within it, can't draw clouds, can't define shapes,...

...for a column, there are too many plots. only 1 is used in column studies ( and/or addlabel() )

...the final plot is referencing the wrong variable. bullish_conviction_signal is a price level, not a boolean value. so it's name is confusing.
......plot signal = if Saty_Pivot_Ribbon()."bullish_conviction_signal" ....
......bullish_conviction is the boolean variable (true/false)


i disabled most of the uneeded code and changed a couple lines.
when i change a line, i disable the original, then copy and modify it , so someone can see the revisions.

i just loaded is as a chart study, and it is changing the background color. i didn't study the logic to see if the colors are right.


Code:
# col_mod_Saty_Pivot_Ribbon_0


# ??
# someone tried to chg this to be a col ?
# not sure what orig looked like


#https://usethinkscript.com/threads/watchlist-column-help.13172/
#Watchlist Column Help
# SeeminglyBD  Start dateToday at 5:42 AM

#Can someone please take a look at this code and let me know what I am doing wrong? All I am trying to do is have a green box if the bullish signal is fired within 3 bars and a red box if the bearish signal is fired within 3 bars, all else black box. I don't need the 1 or the NaN in black boxes. Thanks for taking a look. This is a free indicator on Satyland.com



#script Saty_Pivot_Ribbon {

# Saty Pivot Ribbon
# Copyright (C) 2022 Saty Mahajan
#
# A 3 EMA Ribbon system that simplifies measuring and using emas for trend and support/resistance.
# Special thanks to Ripster for his education and EMA Clouds which inspired this indicator.

# Settings
    input Fast_EMA = 8;
    input Pivot_EMA = 21;
    input Slow_EMA = 34;
#input Highlight_Fast = no;
#input Highlight_Pivot = no;
#input Highlight_Slow = no;
    input Show_Conviction_Arrows = yes;
    input Conviction_Arrow_Size = 2;
    input Fast_Conviction_EMA = 13;
    input Slow_Conviction_EMA = 48;
    input Show_Fast_Conviction_EMA = yes;
    input Show_Slow_Conviction_EMA = yes;

# Calculations
    def price = close;
    def FastValue = ExpAverage(price, Fast_EMA);
    def PivotValue = ExpAverage(price, Pivot_EMA);
    def SlowValue = ExpAverage(price, Slow_EMA);
    def Fast_Conviction_Value = ExpAverage(price, Fast_Conviction_EMA);
    def Slow_Conviction_Value = ExpAverage(price, Slow_Conviction_EMA);

# Add Clouds
#    DefineGlobalColor("Fast Long", Color.GREEN);
#    DefineGlobalColor("Fast Short", Color.RED);
#    AddCloud(FastValue, PivotValue, GlobalColor("Fast Long"), GlobalColor("Fast Short"));
#    DefineGlobalColor("Slow Long", Color.CYAN);
#    DefineGlobalColor("Slow Short", Color.LIGHT_ORANGE);
#    AddCloud(PivotValue, SlowValue, GlobalColor("Slow Long"), GlobalColor("Slow Short"));

# Add Pivot Plot
#    DefineGlobalColor("Pivot Highlight", Color.LIGHT_GRAY);
#    plot Pivot = if Highlight_Pivot then PivotValue else Double.NaN;
#    Pivot.AssignValueColor(GlobalColor("Pivot Highlight"));

# Add Fast Plot
#    DefineGlobalColor("Fast Highlight", Color.LIGHT_GRAY);
#    plot Fast = if Highlight_Fast then FastValue else Double.NaN;
#    Pivot.AssignValueColor(GlobalColor("Fast Highlight"));

# Add Slow Plot
#    DefineGlobalColor("Slow Highlight", Color.LIGHT_GRAY);
#    plot Slow = if Highlight_Slow then SlowValue else Double.NaN;
#    Pivot.AssignValueColor(GlobalColor("Slow Highlight"));

# Conviction Arrows (default based on 13/48)
# Read more about that combo here: http://etfhq.com/blog/2013/01/15/golden-cross-which-is-the-best/#Top
#    DefineGlobalColor("Bullish Conviction Arrow", Color.CYAN);
#    DefineGlobalColor("Bearish Conviction Arrow", Color.ORANGE);
    def bullish_conviction = Fast_Conviction_Value >= Slow_Conviction_Value;
    def bearish_conviction = Fast_Conviction_Value < Slow_Conviction_Value;
    def bullish_conviction_confirmed = (bullish_conviction == yes and bullish_conviction[1] == no);
    def bearish_conviction_confirmed = (bearish_conviction == yes and bearish_conviction[1] == no);

#    plot bullish_conviction_signal = if bullish_conviction_confirmed and Show_Conviction_Arrows then close else Double.NaN;
#    plot bearish_conviction_signal = if bearish_conviction_confirmed and Show_Conviction_Arrows then close else Double.NaN;

#    bullish_conviction_signal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
#    bullish_conviction_signal.AssignValueColor(GlobalColor("Bullish Conviction Arrow"));
#    bullish_conviction_signal.SetLineWeight(Conviction_Arrow_Size);
#    bullish_conviction_signal.HideBubble();
#    bearish_conviction_signal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
#    bearish_conviction_signal.AssignValueColor(GlobalColor("Bearish Conviction Arrow"));
#    bearish_conviction_signal.SetLineWeight(Conviction_Arrow_Size);
#    bearish_conviction_signal.HideBubble();
#    plot fast_conviction_ema_signal = if Show_Fast_Conviction_EMA then Fast_Conviction_Value else Double.NaN;
#    fast_conviction_ema_signal.SetDefaultColor(Color.LIGHT_GRAY);
#    fast_conviction_ema_signal.HideBubble();
#    fast_conviction_ema_signal.SetLineWeight(1);
#    plot slow_conviction_ema_signal = if Show_Slow_Conviction_EMA then Slow_Conviction_Value else Double.NaN;
#    slow_conviction_ema_signal.SetDefaultColor(Color.PLUM);
#    slow_conviction_ema_signal.HideBubble();
#    slow_conviction_ema_signal.SetLineWeight(1);

#}


#plot signal = if Saty_Pivot_Ribbon()."bullish_conviction_signal" is true within 3 bars then 1 else if Saty_Pivot_Ribbon()."bullish_conviction_signal" is false then 0 else 9;
#signal.AssignValueColor(if signal == 1 then Color.WHITE else if signal == 2 then Color.BLACK else Color.WHITE);
#signal.AssignValueColor(if signal == 2 then Color.DARK_GREEN else if signal == 1 then Color.WHITE else Color.WHITE);

def signal = if bullish_conviction is true within 3 bars then 1 else if bullish_conviction is false then 0 else 9;

AssignBackgroundColor(if signal == 1 then Color.DARK_GREEN else if signal == 2 then Color.BLACK else Color.WHITE);
#
 
Solution

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
396 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