You are using an out of date browser. It may not display this or other websites correctly.

You should upgrade or use an alternative browser.

You should upgrade or use an alternative browser.

- Thread starter tomsk
- Start date

do you make your own line or use a indicator for that

I draw my own lines.do you make your own line or use a indicator for that

okI draw my own lines.

@tomsk Hello, I use the ZigZagPercent indicator in TOS. I take the 14 period Avg Percent True Range and multiply it by 2.5 and use that sum as the reversal amount.

How can I replicate that with your inputs:

input PercentAmount = .01;

input RevAmount = .05;

input ATRreversal = 3.0;

input ATRlength = 5;

Thank you for your help

MTV

How can I replicate that with your inputs:

input PercentAmount = .01;

input RevAmount = .05;

input ATRreversal = 3.0;

input ATRlength = 5;

Thank you for your help

MTV

Last edited:

D

fantastic work. thank you for sharing.

I hope I don't bother you, but I would like to know if it is possible to add to the indicator a bubble that shows the % of retracement between one swing and another, and finally, if it is possible to add a plot as targets that marks some % selected as target (e.g. 61,8% y 100%).

I have been trying to do some of that but my knowledge is very basic and it always gives me error in the calculations and plots that I do.

Thank you for your time and I hope it can be done!

zigzag /harmonic pattern, can someone please convert it for TOS?

Code:

```
// © LucemAnb
//@version=4
//@author=lucemanb
//
// THIS CODE IS BASED FROM THE MT4 ZIGZAG INDICATOR
// THE ZIGZAG SETTINGS FOR THE MAIN ONE ON TRADINGVIEW DO NOT WORK THE SAME AS MT4
// I HOPE U LOVE IT
//
// Ping me for donations, Collaborations or Support
study("ZigZag++", "ZigZag++ Lucem Anb", true, format.price)
Depth = input(12, "Depth", input.integer, minval=1, step=1)
Deviation = input(5, "Deviation", input.integer, minval=1, step=1)
mtf_val = input("", "Resolution", input.resolution)
line_thick = input(4, "Line Thickness", input.integer, minval=1, maxval=4)
p = input("Lime", "Up Color", options=["Red", "Lime", "Orange", "Teal", "Yellow", "White", "Black"])
q = input("Red", "Down Color", options=["Red", "Lime", "Orange", "Teal", "Yellow", "White", "Black"])
display_a = input(true, "Display Background Direction Changes?")
repaint = input(true, "Repaint Levels")
var lastlow = 0.0
var lasthigh = 0.0
data(x) => security(syminfo.tickerid, mtf_val!="" ? mtf_val : timeframe.period, x)
cc(x) => x=="Red"?color.red:x=="Lime"?color.lime:x=="Orange"?color.orange:x=="Teal"?
color.teal:x=="Yellow"?color.yellow:x=="Black"?color.black:color.white
col(c) => c>0 ? (cc(p)) : c<0 ? (cc(q)) : na
getLow(x, y, z, a) =>
ll = y
v = data(x)
m = v==ll or data(z) - v > a*syminfo.mintick
if v!=ll
ll := v
if m
v := 0.0
[v,ll]
getHigh(x, y, z, a) =>
lh = y
v = data(x)
m = v==lh or v - data(z) > a*syminfo.mintick
if v!=lh
lh := v
if m
v := 0.0
[v,lh]
[v,e] = getLow(lowest(Depth), lastlow, low, Deviation)
lastlow := e
zBB = v != 0.0
[v1,e1] = getHigh(highest(Depth), lasthigh, high, Deviation)
lasthigh := e1
zSS = v1 != 0.0
d = 0, zigzagHigh = 0, zigzagLow = 0
d := zBB ? 1 : zSS ? -1 : nz(d[1], 0)
virtualLow = zigzagLow[1] + 1
if not zBB or (zBB and d == d[1] and low > low[virtualLow])
zigzagLow := nz(zigzagLow[1]) + 1
virtualHigh = zigzagHigh[1] + 1
if not zSS or (zSS and d == d[1] and high < high[virtualHigh])
zigzagHigh := nz(zigzagHigh[1]) + 1
direction_changed = d!=d[1]
x1 = bar_index-zigzagLow
x2 = bar_index-zigzagHigh
y1 = low[zigzagLow]
y2 = high[zigzagHigh]
if not repaint and d!=d[1]
line zigzag = line.new(x1[1], y1[1], x2[1], y2[1], color=col(d[1]*-1), style=line.style_solid, width=line_thick)
if repaint
line zigzag = line.new(x1, y1, x2, y2, color=col(d*-1), style=line.style_solid, width=line_thick)
if (d == d[1])
line.delete(zigzag[1])
bgcolor(display_a ? col(-d) : na, editable=false, title="Direction Changes")
alertcondition(direction_changed, "Direction Changed", 'Zigzag on {{ticker}} direction changed at {{time}}')
alertcondition(direction_changed and d<0, "Bullish Direction", 'Zigzag on {{ticker}} bullish direction at {{time}}')
alertcondition(direction_changed and d>0, "Bearish Direction", 'Zigzag on {{ticker}} bearish direction at {{time}}')
```

Last edited by a moderator:

They appear at real time but will repaint if violated

Hello experts,

Hope all is keeping safe. I am wondering if we have a way to automatically plot ANDREWS pitchforks based on SWINGS - say using some ZIG ZAG setting to detect the pivots and then using them to automatically plot Andrews. This site has shown it work.

Done manually:

please advise...

Hope all is keeping safe. I am wondering if we have a way to automatically plot ANDREWS pitchforks based on SWINGS - say using some ZIG ZAG setting to detect the pivots and then using them to automatically plot Andrews. This site has shown it work.

Done manually:

please advise...

Last edited:

I love the candlestick color identification of the swing high and swing low throughout the chart. Visually is great to see high and low.

When I am add ing more indicators to the upper chart, the chart can be eyes soring. I am trying to change different color of the lines but still very cluttering on the chart.

Is it possible to not display the swing high and low lines, only keep the magenta, and cyan candlestick coloring.

Thank you!

Code:

```
# Swing High and Swing Low
# tomsk
# 11.18.2019
# As requested by chillc15 I have modified [USER=1174]@RobertPayne[/USER] code to include SwingHigh
# points which are now plotted in CYAN with the swing high points painted in PINK.
# So now you have both swing high and low on your charts
# +------------------------------------------------------------+
# | Example: How to extend levels to the right of the chart |
# | Robert Payne |
# | https://funwiththinkscript.com |
# +------------------------------------------------------------+
# SWING LOW
# define swing low points
input length = 10;
def bn = BarNumber();
def lastBar = HighestAll(if IsNaN(close) then 0 else bn);
def offset = Min(length - 1, lastBar - bn);
def swingLow = low < Lowest(low[1], length - 1) and low == GetValue(Lowest(low, length), -offset);
# identify the very last swing low point
def lowPointOneBarNumber = HighestAll(if swingLow then bn else 0);
def lowPointOneValue = if bn == lowPointOneBarNumber then low else lowPointOneValue[1];
plot low1 = if bn < lowPointOneBarNumber then Double.NaN else lowPointOneValue;
low1.SetDefaultColor(Color.LIGHT_RED);
# identify the 2nd to last swing low point
def lowPointTwoBarNumber = HighestAll(if swingLow and bn < lowPointOneBarNumber then bn else 0);
def lowPointTwoValue = if bn == lowPointTwoBarNumber then low else lowPointTwoValue[1];
plot low2 = if bn < lowPointTwoBarNumber then Double.NaN else lowPointTwoValue;
low2.SetDefaultColor(Color.Light_RED);
# just keep doing ths for as many lines as you want to add to the chart
# identify then 3rd to last swingHigh point low
def lowPointThreeBarNumber = HighestAll(if swingLow and bn < lowPointTwoBarNumber then bn else 0);
def lowPointThreeValue = if bn == lowPointThreeBarNumber then low else lowPointThreeValue[1];
plot low3 = if bn < lowPointThreeBarNumber then Double.NaN else lowPointThreeValue;
low3.SetDefaultColor(Color.Light_RED);
# identify then 4th to last swingHigh point low
def lowPointFourBarNumber = HighestAll(if swingLow and bn < lowPointThreeBarNumber then bn else 0);
def lowPointFourValue = if bn == lowPointFourBarNumber then low else lowPointFourValue[1];
plot low4 = if bn < lowPointFourBarNumber then Double.NaN else lowPointFourValue;
low4.SetDefaultColor(Color.Light_RED);
# identify then 5th to last swingHigh point low
def lowPointFiveBarNumber = HighestAll(if swingLow and bn < lowPointFourBarNumber then bn else 0);
def lowPointFiveValue = if bn == lowPointFiveBarNumber then low else lowPointFiveValue[1];
plot low5 = if bn < lowPointFiveBarNumber then Double.NaN else lowPointFiveValue;
low5.SetDefaultColor(Color.Light_RED);
# identify then 6th to last swingHigh point low
def lowPointSixBarNumber = HighestAll(if swingLow and bn < lowPointFiveBarNumber then bn else 0);
def lowPointSixValue = if bn == lowPointSixBarNumber then low else lowPointSixValue[1];
plot low6 = if bn < lowPointSixBarNumber then Double.NaN else lowPointSixValue;
low6.SetDefaultColor(Color.Light_RED);
# identify then 7th to last swingHigh point low
def lowPointSevenBarNumber = HighestAll(if swingLow and bn < lowPointSixBarNumber then bn else 0);
def lowPointSevenValue = if bn == lowPointSevenBarNumber then low else lowPointSevenValue[1];
plot low7 = if bn < lowPointSevenBarNumber then Double.NaN else lowPointSevenValue;
low7.SetDefaultColor(Color.Light_RED);
# identify then 8th to last swingHigh point low
def lowPointEightBarNumber = HighestAll(if swingLow and bn < lowPointSevenBarNumber then bn else 0);
def lowPointEightValue = if bn == lowPointEightBarNumber then low else lowPointEightValue[1];
plot low8 = if bn < lowPointEightBarNumber then Double.NaN else lowPointEightValue;
low8.SetDefaultColor(Color.Light_RED);
# identify then 9th to last swingHigh point low
def lowPointNineBarNumber = HighestAll(if swingLow and bn < lowPointEightBarNumber then bn else 0);
def lowPointNineValue = if bn == lowPointNineBarNumber then low else lowPointNineValue[1];
plot low9 = if bn < lowPointNineBarNumber then Double.NaN else lowPointNineValue;
low9.SetDefaultColor(Color.Light_RED);
# identify then 10th to last swingHigh point low
def lowPointTenBarNumber = HighestAll(if swingLow and bn < lowPointNineBarNumber then bn else 0);
def lowPointTenValue = if bn == lowPointTenBarNumber then low else lowPointTenValue[1];
plot low10 = if bn < lowPointTenBarNumber then Double.NaN else lowPointTenValue;
low10.SetDefaultColor(Color.Light_RED);
# SWING HIGH
# define swing high points
def swingHigh = high > Highest(high[1], length - 1) and high == GetValue(Highest(high, length), -offset);
# identify the very last swing high point
def highPointOneBarNumber = HighestAll(if swingHigh then bn else 0);
def highPointOneValue = if bn == highPointOneBarNumber then high else highPointOneValue[1];
plot high1 = if bn < highPointOneBarNumber then Double.NaN else highPointOneValue;
high1.SetDefaultColor(Color.CYAN);
# identify the 2nd to last swing high point
def highPointTwoBarNumber = HighestAll(if swingHigh and bn < highPointOneBarNumber then bn else 0);
def highPointTwoValue = if bn == highPointTwoBarNumber then high else highPointTwoValue[1];
plot high2 = if bn < highPointTwoBarNumber then Double.NaN else highPointTwoValue;
high2.SetDefaultColor(Color.CYAN);
# just keep doing ths for as many lines as you want to add to the chart
def highPointThreeBarNumber = HighestAll(if swingHigh and bn < highPointTwoBarNumber then bn else 0);
def highPointThreeValue = if bn == highPointThreeBarNumber then high else highPointThreeValue[1];
plot high3 = if bn < highPointThreeBarNumber then Double.NaN else highPointThreeValue;
high3.SetDefaultColor(Color.CYAN);
def highPointFourBarNumber = HighestAll(if swingHigh and bn < highPointThreeBarNumber then bn else 0);
def highPointFourValue = if bn == highPointFourBarNumber then high else highPointFourValue[1];
plot high4 = if bn < highPointFourBarNumber then Double.NaN else highPointFourValue;
high4.SetDefaultColor(Color.CYAN);
def highPointFiveBarNumber = HighestAll(if swingHigh and bn < highPointFourBarNumber then bn else 0);
def highPointFiveValue = if bn == highPointFiveBarNumber then high else highPointFiveValue[1];
plot high5 = if bn < highPointFiveBarNumber then Double.NaN else highPointFiveValue;
high5.SetDefaultColor(Color.CYAN);
def highPointSixBarNumber = HighestAll(if swingHigh and bn < highPointFiveBarNumber then bn else 0);
def highPointSixValue = if bn == highPointSixBarNumber then high else highPointSixValue[1];
plot high6 = if bn < highPointsixBarNumber then Double.NaN else highPointsixValue;
high6.SetDefaultColor(Color.CYAN);
def highPointSevenBarNumber = HighestAll(if swingHigh and bn < highPointSixBarNumber then bn else 0);
def highPointSevenValue = if bn == highPointSevenBarNumber then high else highPointSevenValue[1];
plot high7 = if bn < highPointSevenBarNumber then Double.NaN else highPointSevenValue;
high7.SetDefaultColor(Color.CYAN);
def highPointEightBarNumber = HighestAll(if swingHigh and bn < highPointSevenBarNumber then bn else 0);
def highPointEightValue = if bn == highPointEightBarNumber then high else highPointEightValue[1];
plot high8 = if bn < highPointEightBarNumber then Double.NaN else highPointEightValue;
high4.SetDefaultColor(Color.CYAN);
def highPointNineBarNumber = HighestAll(if swingHigh and bn < highPointEightBarNumber then bn else 0);
def highPointNineValue = if bn == highPointNineBarNumber then high else highPointNineValue[1];
plot high9 = if bn < highPointNineBarNumber then Double.NaN else highPointNineValue;
high4.SetDefaultColor(Color.CYAN);
def highPointTenBarNumber = HighestAll(if swingHigh and bn < highPointNineBarNumber then bn else 0);
def highPointTenValue = if bn == highPointTenBarNumber then high else highPointTenValue[1];
plot high10 = if bn < highPointTenBarNumber then Double.NaN else highPointTenValue;
high4.SetDefaultColor(Color.CYAN);
# ADJUST CANDLE COLORS
# change candle colors just to make it easier to see what we are working with
#AssignPriceColor(if swingLow then Color.cyan else if swingHigh then Color.mageNTA else Color.current);
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);
# End Swing High and Swing Low
```

Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|

ZigZag High Low with Supply & Demand Zones for ThinkorSwim | Indicators | 86 | ||

T | ZigZag based on number of bars | Questions | 8 | |

Help with the ZigZag | Questions | 6 | ||

E | ZigZag based on points rather than percentages? | Questions | 0 | |

E | ZigZag based on points rather than percentages? | Indicators | 0 |