Repaints ZigZag Wave Count For Higher Highs, Higher Lows For ThinkOrSwim

Repaints

ShinJ

New member
Is there a way to display the price change of the wave in zigzag, but not simply by calculating high minus low, so that we have only one value at the top/bottom, but in gradual cumulative wave style (like in Weis Volume wave), where the change value is added with each bar that makes a new high or low?

Thanks

gQC8jZF.png
 
Last edited by a moderator:

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

ZigZag Wave Count For Higher Highs, Higher Lows For ThinkOrSwim

Here is a start at a wave ("W") count for higher highs, higher lows. This counts the changes as shown in chgzzoth at the respective highs/lows. If the next bubble is higher then it will accumulate it. If not, it will start over. Rather than using chgzzoth, you might be interested in some other number. Take a look at the debug label to see how other computations can be derived in place of chgzzoth.
Capture.jpg
Ruby:
declare upper;

input price = close;
input reversalAmount = 1.0;
input reversalMode = {default price, percent};

def mode = if  reversalMode ==  reversalMode.price then ZigZagTrendSign(price = price, reversalAmount = reversalAmount) else ZigZagTrendPercent(price = price, reversalAmount = reversalAmount);

def inflection = if reversalMode == reversalMode.price then if !IsNaN(ZigZagSign(price = price, reversalAmount = reversalAmount)) then 1 else 0 else if !IsNaN(ZigZagPercent(price = price, reversalAmount = reversalAmount)) then 1 else 0;
rec trend = if inflection == 1 and mode == -1 then 1 else if inflection == 1 and mode == 1 then -1 else trend[1];

plot wave =  if  reversalMode ==  reversalMode.price then ZigZagSign(price = price, reversalAmount = reversalAmount, "show bubbles" = Yes) else ZigZagPercent(price = price, reversalAmount = reversalAmount);
wave.EnableApproximation();
wave.AssignValueColor(if trend[1] == 1 then color.red else color.red);
wave.SetDefaultColor(Color.RED);
wave.SetLineWeight(1);

def zzoth    = if !IsNaN(wave) then wave else zzoth[1];
def chgzzoth = AbsValue(zzoth[1] - zzoth);
def count    = if !IsNaN(wave) then BarNumber() else count[1];

input show_price_bubble  = yes;
input show_change_bubble = yes;
input show_count_bubble  = yes;
input show_wave_bubble   = yes;
input bubbleoffset       = .0005;

AddChartBubble(!IsNaN(wave) and show_count_bubble,
                if zzoth>zzoth[1]
                then high * (1 + bubbleoffset)
                else low * (1 - bubbleoffset) ,
                "Bars: " + (count - count[1]),
                color.yellow,
                if zzoth>zzoth[1] then yes else no);

AddChartBubble(!IsNaN(wave) and show_change_bubble,
                if zzoth>zzoth[1]
                then high * (1 + bubbleoffset)
                else low * (1 - bubbleoffset)   ,
                "Chg: " + AsText(chgzzoth) ,
                Color.CYAN,
                if zzoth>zzoth[1] then yes else no);                               

AddChartBubble(!IsNaN(wave) and show_price_bubble,
                if zzoth>zzoth[1]
                then high * (1 + bubbleoffset)
                else low * (1 - bubbleoffset)   ,
                (if wave == close then "C:   " else "C:    ") + AsText(wave) ,
                if !isnan(wave) > !isnan(wave[1]) then Color.GREEN else Color.RED,
                if zzoth>zzoth[1] then yes else no);

#Prior Bubbles defined--------------------------------------------
def zzoth1 = if zzoth!=zzoth[1] then zzoth[1] else zzoth1[1];
def zzoth2 = if zzoth1!=zzoth1[1] then zzoth1[1] else zzoth2[1];
def zzoth3 = if zzoth2!=zzoth2[1] then zzoth2[1] else zzoth3[1];
input debug = no;
addlabel(debug,zzoth+" "+zzoth1+" "+zzoth2);

#Waves where higher high or lower high are cumulative
def wavehighext = if zzoth>zzoth[1] and zzoth>zzoth2 then wavehighext[1]+chgzzoth else if zzoth>zzoth[1] and zzoth<=zzoth2 then 0 else wavehighext[1];


addchartBubble(!IsNaN(wave) and show_wave_bubble,
                if zzoth>zzoth[1]
                then high * (1 + bubbleoffset)
                else double.nan   ,
                (if wave == close then "W:   " else "W:    ") + AsText(wavehighext) ,
                if !isnan(wave) > !isnan(wave[1]) then Color.GREEN else Color.RED,
                if zzoth>zzoth[1] then yes else no);

def wavelowext = if zzoth<zzoth[1] and zzoth>zzoth2 then wavelowext[1]+chgzzoth else if zzoth<zzoth[1] and zzoth<=zzoth2 then 0 else wavelowext[1];

addchartBubble(!IsNaN(wave) and show_wave_bubble,
                if zzoth<zzoth[1]
                then low * (1 - bubbleoffset)
                else double.nan   ,
                (if wave == close then "W:   " else "W:    ") + AsText(wavelowext) ,
                if !isnan(wave) > !isnan(wave[1]) then Color.GREEN else Color.RED,
                if zzoth>zzoth[1] then yes else no);
 
Last edited by a moderator:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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