ZigZag High Low Stats for ThinkorSwim

BenTen

BenTen

Administrative
Staff
VIP
@mdtn The script I added to my chart was the one provided by you in comment #33.
 
M

mdtn

Member
VIP
That's very strange, its possible that the one I loaded and the one I sent you are 2 different one. I will try it later tonight and let you know. Thanks Ben.
 
S

s1111

New member
Hi. Im new to this site and new to trading. I didn't have an arrow up or down. I just went thru this post and copy paste this code and added to the script . Now I have arrow.

Code:
plot HighArrow = swingHigh;
HighArrow.SetLineWeight(5);
HighArrow.SetDefaultColor(Color.RED);
HighArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

plot LowArrow = swingLow;
LowArrow.SetLineWeight(5);
LowArrow.SetDefaultColor(Color.GREEN);
LowArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
 
T

Taye

New member
VIP
Extracted idea from RDMercer's post #369 of a variant of a massive Zig Zag High Low Supply Demand study that comprises many different components

https://usethinkscript.com/threads/...-signals-for-thinkorswim.183/page-19#post-369
I heavily modified, cleaned up and extracted some interesting Zig Zag statistical information resulting in this study called Zig Zag High Low Stats. It displays the following information represented via bubbles at each of the Zig zag turning points

Label for Confirmed/Unconfirmed Status of Current Zigzag
Price Change between Zigzags
Price at Zigzag High/Low
Bar Count between Zigzags
Volume at Zigzag Reversals

Here's the study - you might like to load this study on a Daily chart of AAPL, AMZN or your favorite ticker
You can turn off any information you don't want via the user interface

Code:
# ZigZag High Low Stats
# tomsk
# 11.16.2019

# V1.0 - 11.16.2019 - tomsk - Initial release of ZigZag High Low Stats

# Extracted idea from RDMercer's post #369 of a variant of a massive
# Zig Zag High Low Supply Demand study that comprises many different
# components
#
# https://usethinkscript.com/threads/trend-reversal-indicator-with-signals-for-thinkorswim.183/page-19#post-369
#
# I heavily modified, cleaned up and extracted some interesting Zig Zag statistical information resulting in this study called Zig Zag High
# Low Stats. It displays the following information represented via bubbles at each of the Zig zag turning points
#
# Label for Confirmed/Unconfirmed Status of Current Zigzag
# Price Change between Zigzags
# Price at Zigzag High/Low
# Bar Count between Zigzags
# Volume at Zigzag Reversals

input showBubblesChange = no;   # Price Change between Zigzags
input showBubblesPrice = no;    # Price at Zigzag High/Low
input showBubblesBarCount = no; # Bar Count between Zigzags
input showBubblesVolume = no;   # Volume at Zigzag Reversals

input BubbleOffset = .0005;
input PercentAmount = .01;
input RevAmount = .05;
input ATRreversal = 3.0;
input ATRlength = 5;

def zz = ZigZagHighLow("price h" = high, "price l" = low, "percentage reversal" = PercentAmount,
"absolute reversal" = RevAmount, "atr length" = ATRlength, "atr reversal" = ATRreversal);

def ReversalAmount = if (close * PercentAmount / 100) > Max(RevAmount < ATRreversal * reference ATR(ATRlength), RevAmount)
                     then (close * PercentAmount / 100)
                     else if RevAmount < ATRreversal * reference ATR(ATRlength)
                          then ATRreversal * reference ATR(ATRlength)
                          else RevAmount;
# Zig Zag Specific Data

def zzSave = if !IsNaN(zz) then zz else GetValue(zzSave, 1);
def chg = (if zzSave == high then high else low) - GetValue(zzSave, 1);
def isUp = chg >= 0;
def isConf = AbsValue(chg) >= ReversalAmount or (IsNaN(GetValue(zz, 1)) and GetValue(isConf, 1));

# Price Change Specific Data

def xxHigh = if zzSave == high then high else xxHigh[1];
def chgHigh = high - xxHigh[1];
def xxLow = if zzSave == low then low else xxLow[1];
def chgLow = low - xxLow[1];

# Bar Count Specific Data

def zzCount = if zzSave[1] != zzSave then 1 else if zzSave[1] == zzSave then zzCount[1] + 1 else 0;
def zzCountHiLo = if zzCountHiLo[1] == 0 and (zzSave == high or zzSave == low) then 1
                  else if zzSave == high or zzSave == low then zzCountHiLo[1] + 1
                  else zzCountHiLo[1];
def zzHiLo = if zzSave == high or zzSave == low then zzCountHiLo else zzCountHiLo + 1;
def zzCountHigh = if zzSave == high then zzCount[1] else Double.NaN;
def zzCountLow  = if zzSave == low then zzCount[1] else Double.NaN;

# Volume Specific Data

def vol = if BarNumber() == 0 then 0 else volume + vol[1];
def vol1 = if BarNumber() == 1 then volume else vol1[1];
def xxVol = if zzSave == high or zzSave == low then TotalSum(volume) else xxVol[1];
def chgVol =  if xxvol - xxVol[1] + vol1 == vol then vol else xxVol - xxVol[1];

# Zigzag Status Label

AddLabel(BarNumber() != 1, (if isConf then "Confirmed " else "Unconfirmed ") + "ZigZag: " + chg + "  ATRrev " + Round(reference ATR(ATRlength) * ATRreversal, 2) + "  RevAmt " + Round(ReversalAmount, 2), if !isConf then Color.Dark_Orange else if isUp then Color.Green else Color.Red);

# Zig Zag Plot

plot zzp = if isUp <= 1 then zz else Double.NaN;
zzp.AssignValueColor(if isUp then Color.Green else if !isUp then Color.Red else Color.Dark_Orange);
zzp.SetStyle(Curve.FIRM);
zzp.EnableApproximation();
zzp.HideBubble();

# Bubbles

# Price Change between Zigzags

AddChartBubble(showBubblesChange and !IsNaN(zz) and BarNumber() != 1, if isUp then high * (1 + BubbleOffset) else low * (1 - BubbleOffset), "$" + Round(chg, 2), if isUp and chgHigh > 0 then Color.Green else if isUp and chgHigh < 0 then Color.Red else if isUp then Color.Yellow else if !isUp and chgLow > 0 then Color.Green else if !isUp and chgLow < 0 then Color.Red else Color.Yellow, isUp);

# Price at Zigzag High/Low

AddChartBubble(showBubblesPrice and !IsNaN(zz) and BarNumber() != 1, if isUp then high * (1 + BubbleOffset) else low * (1 - BubbleOffset), if isUp then "$" + high else "$" + low, if isUp and chgHigh > 0 then Color.Green else if isUp and chgHigh < 0 then Color.Red else if isUp then Color.Yellow else if !isUp and chgLow > 0 then Color.Green else if !isUp and chgLow < 0 then Color.Red else Color.Yellow, isUp);

# Bar Count between Zigzags

AddChartBubble(showBubblesBarCount and !IsNaN(zz) and BarNumber() != 1, if isUp then high * (1 + BubbleOffset) else low * (1 - BubbleOffset), if zzSave == high then zzCountHigh else zzCountLow, if isUp and chgHigh > 0 then Color.Green else if isUp and chgHigh < 0 then Color.Red else if isUp then Color.Yellow else if !isUp and chgLow > 0 then Color.Green else if !isUp and chgLow < 0 then Color.Red else Color.Yellow, if isUp then yes else no);

# Volume at Zigzag Reversals

AddChartBubble(showBubblesVolume and !IsNaN(zz) and BarNumber() != 1, if isUp then high * (1 + bubbleoffset) else low * (1 - bubbleoffset), chgVol, if isUp and chghigh > 0 then Color.Green else if isUp and chghigh < 0 then Color.Red else if isUp then Color.Yellow else if !isUp and chglow > 0 then Color.Green else if !isUp and chglow < 0 then Color.Red else Color.Yellow, if isUp then yes else no);

# End ZigZag High Low Stats
I really like this study. Great work. Does it repaint? or would you wait until candle closes for confirmation.
Thanks.
 
BenTen

BenTen

Administrative
Staff
VIP
@Taye Anything with ZigZag will always repaint.
 
T

Thomas

Active member
VIP
Here is my chart/This is my gun/FullMetalJacket......it is as clean as I can keep it,....I have many indicators in the studies, most are necessary labels. Savage was kept because I like the bit of assistance close to turns as well as Hi_Low. I draw trendlines by hand, but thought the IronrodSMI was an enhancement,...lines up well with the repainted reversal arrow......but is for a price reader,.. a candle lover, tea leaves,...they tell you all you need to know. I like simple/ KISS
https://tos.mx/ztmJu7z
 
MerryDay

MerryDay

Active member
VIP
@Thomas
I enjoy this forum because contributors like you share their setups.

You use this ZigZag, Trend Reversal, and Swing High/Low. They are possibly the three most viewed indicators on the forum. They are all repainting indicators.

I am trying to understand how people use repainting indicators. A trader using repainting Hurst Bands told me they only use the current timeframe and therefore it doesn't matter that the history repaints. But the current candle repaints also.

ZigZag, Trend Reversal, and Swing High/Low all are designed to find a stock's lowest point thus signaling a good entry point but then the stock drops lower and it erases all those signals and says "oops didn't mean it." Not so good for you if you just bought in and the stock drops like a rock.

I am not being critical. I want to understand. You have been trading for many years, could you tell us how you feel these indicators can be used reliably?
 
T

Thomas

Active member
VIP
@Thomas
I enjoy this forum because contributors like you share their setups.

You use this ZigZag, Trend Reversal, and Swing High/Low. They are possibly the three most viewed indicators on the forum. They are all repainting indicators.

I am trying to understand how people use repainting indicators. A trader using repainting Hurst Bands told me they only use the current timeframe and therefore it doesn't matter that the history repaints. But the current candle repaints also.

ZigZag, Trend Reversal, and Swing High/Low all are designed to find a stock's lowest point thus signaling a good entry point but then the stock drops lower and it erases all those signals and says "oops didn't mean it." Not so good for you if you just bought in and the stock drops like a rock.

I am not being critical. I want to understand. You have been trading for many years, could you tell us how you feel these indicators can be used reliably?
I try to reduce clutter, indicators of any kind and rely on price and candles. It doesn't take long to learn to read price and maybe one trusted Indicator for assistance. No grails, I searched, except the one you wrote, understanding it and grow your account size. Several years ago, a public YouTube video became my "ah ha," moment, brought me to tears, I was struggling and saw how simple it can be, I said "yes," that's it. I watched the videos, joined the site for my education. This Iron Rod with Hi_Low indicates gives a confident picture of a reverse, if you want to overlay the zig-zag, fine but the Hi_Low is a simpler signal, incorporated price candles, manually drawn trendlines, I never trusted any indicator signal unless I wrote it in a way it was growing my account. The repainting arrows do a good job of indicating entry, maybe I have entered slightly sooner, but for nothing else, study the entry arrow position and candle formation to understand the pattern for a future entry. I'm asking myself questions of some recent information I learned, how can I accelerate, to speed growth of account. A serious athlete wants to improve quickly, difficult, what's needed is to find a way to accelerate improvement without injuries, time is one answer and chart studies. I recommend shortcuts in learning to speed up portfolio growth. Many observations led me to write notes on charts, during live markets, I papertrade different symbols other than what I personally hold, to test alternative trades. I don't journal, or deviate with useless distractions, looking at charts that don't work, creating Holy-Grails, everything else except reading candles, understanding what is happening with price. I turn off news noise, read a few trusted opinions for confirming beliefs and attack market as early as possible.
Heard this from Oliver Velez, Traders want instant success, without putting in the time, you wouldn't want a doctor operating on you without putting in the time, traders complicate, instead of making it simple enough to explain to a child. One thing I find very important are scans, the selections from which to choose from,...that's something to focus on, most here are trading weak stocks.....
 
Last edited:
MerryDay

MerryDay

Active member
VIP
@Thomas
I am obsessed w/ studying charts.
  • I agree w/ you, I haven't found a script that can compete w/ manually drawn trendlines.
  • For lows, the BTP (Buy the Dip) indicator doesn't repaint.
  • I agree w/ you: IronRod was my first indicator and whether I am using a tick chart, a 2min, or an hourly; it is a mainstay. Stochastic provides so much information and there are so many ways of displaying that but for me, the IronRod is clean and easy to read at a glance.
  • Support&Resistance for me are invaluable as they keep me out of trades not going anywhere thus increasing my ROI.
  • Multi-TimeFrame Analysis. Looking across timeframes especially for trends and ROI.
AND I LOVE labels. Like you, they help keep charts clean. I will be adding some of yours to my repertoire. Thanks again for sharing. This forum is a great place to continue to learn.
 
Last edited:
rad14733

rad14733

Well-known member
VIP
@Thomas Good write-up... It's easy to get overwhelmed with indicators to the point where you can't see the forest for the trees... I like testing and writing new indicators but also keep in mind that some indicators are great at spelling things out after-the-fact... However, few show real-time or accurately predict the future... As you alluded to, the fewer "good" indicators the better...

@MerryDay I'm really starting to like the IronRod SMI... (y)

And lest I deviate too far off-topic, I've been a fan of ZigZag indicators for quite some time...
 
D

drakoniano

New member
Hey tomsk thanks for sharing, I have several questions if you can:

1) do you know how I can change the fractal of this study? , meaning 5-bar fractal meand that IM looking sequence of candles where the highest point is surrounded by at least 2 consecutive bars with lower highs on each side. This makes it 2+1+2=5 fractal bars

2) Do you know if I can add standard dev to the study? to try to find the mode, the first standard deviation or 68% and the second sigma or 90%.

My goal is try to understand the rotations in any market,

Can you help me please??

Extracted idea from RDMercer's post #369 of a variant of a massive Zig Zag High Low Supply Demand study that comprises many different components
 

Similar threads

Top