Moving Averages Converge / Diverge Label

shellyonthepelli

New member
Plus
Looking for a simple green label when the WMA 8 and 16 are converging and maybe white when they are not on and it work on multiple time frames with the same study? i'm trying to set it up to work on 1 min, 2 min, 3 min, 4, min, 5 min, 6 min, 7 min, 8 min, 9min, 10 min, 15 min, 20 min, 30 min, 1h, 90 min, 2 h
 
Last edited by a moderator:
Solution
Looking for a simple green label when the WMA 8 and 16 are converging and maybe white when they are not on and it work on multiple time frames with the same study? i'm trying to set it up to work on 1 min, 2 min, 3 min, 4, min, 5 min, 6 min, 7 min, 8 min, 9min, 10 min, 15 min, 20 min, 30 min, 1h, 90 min, 2 h


here is a study that checks if the gap between 2 averages is getting closer or farther apart.
i set up 4 conditions, up and down , and whether if wma8 is above or below the other wma.
can show colored dots for each condition.
can show colored vertical test lines.
i used MovingAverage( weighted ) for WMA(). i like using that to allow changes to other average types.
it displays a colored label , based on the current bar...
Looking for a simple green label when the WMA 8 and 16 are converging and maybe white when they are not on and it work on multiple time frames with the same study? i'm trying to set it up to work on 1 min, 2 min, 3 min, 4, min, 5 min, 6 min, 7 min, 8 min, 9min, 10 min, 15 min, 20 min, 30 min, 1h, 90 min, 2 h


here is a study that checks if the gap between 2 averages is getting closer or farther apart.
i set up 4 conditions, up and down , and whether if wma8 is above or below the other wma.
can show colored dots for each condition.
can show colored vertical test lines.
i used MovingAverage( weighted ) for WMA(). i like using that to allow changes to other average types.
it displays a colored label , based on the current bar.
default wma8 and wma16

wma8 < wma16
. converge_dwn , green
. diverge_dwn , white
wma8 > wma16
. converge_up , yellow
. diverge_up , cyan


Code:
#avgs_converge_label
#https://usethinkscript.com/threads/moving-averages-converge-diverge-label.19643/
#WMA 8 and 16 label?

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

DefineGlobalColor("converge_dwn", color.green);
DefineGlobalColor("diverge_dwn", color.white);
DefineGlobalColor("converge_up", color.yellow);
DefineGlobalColor("diverge_up", color.cyan);
#GlobalColor("converge_dwn")
#GlobalColor("diverge_dwn")
#GlobalColor("converge_up")
#GlobalColor("diverge_up")


#input avg1_type = AverageType.exponential;
input avg1_type = AverageType.WEIGHTED;
input avg1_length = 8;
def avg1 = MovingAverage(avg1_type, close, avg1_length );

input avg2_type = AverageType.WEIGHTED;
input avg2_length = 16;
def avg2 = MovingAverage(avg2_type, close, avg2_length );

def xup = avg1 crosses above avg2;
def xdwn = avg1 crosses below avg2;
def gap = avg1 - avg2;

# WMA 8 and 16 are converging after a drop
def converge_dwn = avg1 < avg2 and absvalue(gap[0]) < absvalue(gap[1]);
def diverge_dwn = avg1 < avg2 and absvalue(gap[0]) > absvalue(gap[1]);
def converge_up = avg1 > avg2 and absvalue(gap[0]) < absvalue(gap[1]);
def diverge_up = avg1 > avg2 and absvalue(gap[0]) > absvalue(gap[1]);

addlabel(1, "   ", color.black);
addlabel(converge_dwn, "converge down", GlobalColor("converge_dwn"));
addlabel(diverge_dwn, "diverge down", GlobalColor("diverge_dwn"));
addlabel(converge_up, "converge up", GlobalColor("converge_up"));
addlabel(diverge_up, "diverge up", GlobalColor("diverge_up"));

input converge_dwn_dots = yes;
plot cd = if converge_dwn_dots and converge_dwn then low*0.999 else na;
cd.SetPaintingStrategy(PaintingStrategy.POINTS);
cd.SetDefaultColor(GlobalColor("converge_dwn"));
cd.setlineweight(3);
cd.hidebubble();

input diverge_dwn_dots = yes;
plot dd = if diverge_dwn_dots and diverge_dwn then low*0.999 else na;
dd.SetPaintingStrategy(PaintingStrategy.POINTS);
dd.SetDefaultColor(GlobalColor("diverge_dwn"));
dd.setlineweight(3);
dd.hidebubble();

input converge_up_dots = yes;
plot cu = if converge_up_dots and converge_up then high*1.001 else na;
cu.SetPaintingStrategy(PaintingStrategy.POINTS);
cu.SetDefaultColor(GlobalColor("converge_up"));
cu.setlineweight(3);
cu.hidebubble();

input diverge_up_dots = yes;
plot du = if diverge_up_dots and diverge_up then high*1.001 else na;
du.SetPaintingStrategy(PaintingStrategy.POINTS);
du.SetDefaultColor(GlobalColor("diverge_up"));
du.setlineweight(3);
du.hidebubble();

input show_avg_lines = yes;
plot zavg1 = if show_avg_lines then avg1 else na;
plot zavg2 = if show_avg_lines then avg2 else na;
zavg1.SetDefaultColor(Color.CYAN);
zavg1.SetLineWeight(1);
zavg1.HideBubble();
zavg2.SetDefaultColor(Color.YELLOW);
zavg2.SetLineWeight(1);
zavg2.HideBubble();

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

input test_vert_lines = no;
addverticalline(test_vert_lines and converge_dwn, "-", GlobalColor("converge_dwn"));
addverticalline(test_vert_lines and diverge_dwn, "-", GlobalColor("diverge_dwn"));
addverticalline(test_vert_lines and converge_up, "-", GlobalColor("converge_up"));
addverticalline(test_vert_lines and diverge_up, "-", GlobalColor("diverge_up"));

#https://toslc.thinkorswim.com/center/reference/thinkScript/Constants/AverageType
#input avg1_type = AverageType.exponential;
#input avg1_type = AverageType.hull;
#input avg1_type = AverageType.Simple;
#input avg1_type = AverageType.weighted;   WMA()
#input avg1_type = AverageType.wilders;
#
 

Attachments

  • img1.JPG
    img1.JPG
    66.8 KB · Views: 93
Last edited by a moderator:
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
317 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