Repaints ZigZag High Low Stats for ThinkorSwim

Repaints

tomsk

Well-known member
VIP
acaution.png

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
 
Last edited by a moderator:
I use the zigZagSign indicator on TOS to look at ES futures rotations. I want to make an alert that tells me when the zigZagSign indicator is greater than 20 in either direction (positive or negative). My strategy is in scales. I can safely spread out my orders and not look at the chart much in low volatility environment and rarely get squeezed, but in high volatility like right now, the rips can be too big and I like to focus on 20+ handle moves, but I want an alert so I don't have to check the chart every 5 mins as my schedule doesn't allow it.

Picture below shows the rotations chart setup I use. It is a 10 tick range chart, and the ZigZagSign is set at 4 handles. But again, I want an alert when it is higher than 20 handles in either direction (Green arrow on the picture). I tried to use the Thinkscript wizard but it did not have the zigzagSign indicator in there. How could I code this, any help?

Here's a link to the picture since the forum wont let me post it for some reason.
 
Hello,

Can you take the zigzag tos indicator so that it will automatically update using the following equations answer as the reversal amount?

Take the 14 period APTR of the stock and multiply it by 2.5 to get the reversal amount.

I see a lock on the code so I don't really know what this means. However, this is a pretty good mechanical system for swing trading.

Any help/advice is greatly appreciated.
 
Code:
def   price               = close;

def   priceH              = high;    # swing high

def   priceL              = low;     # swing low

input ATRreversalfactor   = 3.0;#Hint ATRreversalfactor: 3 is standard, adjust 



input ATRlength           = 5;#Hint ATRlength: 5 is standard, adjust to whatever 



input zigzagpercent       = 0.80;#LAR original is 0.2, but modified in testing 



input zigzagamount        = .15;

def ATR                   = reference ATR(length = ATRlength);

def reversalAmount        = if (close * zigzagpercent / 100) > Max

(zigzagamount < ATRreversalfactor * ATR, zigzagamount) then 

(close * zigzagpercent / 100) else if zigzagamount < ATRreversalfactor * ATR then 

ATRreversalfactor * ATR else zigzagamount;

input showSupplyDemand    = {Off, default Arrow, Pivot};

input showArrows          = yes; #orignal by LAR was no

input useAlerts           = no; #orignal by LAR was no

 

#Original TOS ZigZag code Modified by Linus

def barNumber = BarNumber();

def barCount = HighestAll(If(IsNaN(price), 0, barNumber));



rec state = {default init, undefined, uptrend, downtrend};

rec minMaxPrice;



if (GetValue(state, 1) == GetValue(state.init, 0)) {

    minMaxPrice = price;

    state = state.undefined;

} else if (GetValue(state, 1) == GetValue(state.undefined, 0)) {

    if (price <= GetValue(minMaxPrice, 1) - reversalAmount) {

        state = state.downtrend;

        minMaxPrice = priceL;

    } else if (price >= GetValue(minMaxPrice, 1) + reversalAmount) {

        state = state.uptrend;

        minMaxPrice = priceH;

    } else {

        state = state.undefined;

        minMaxPrice = GetValue(minMaxPrice, 1);

    }

} else if (GetValue(state, 1) == GetValue(state.uptrend, 0)) {

    if (price <= GetValue(minMaxPrice, 1) - reversalAmount) {

        state = state.downtrend;

        minMaxPrice = priceL;

    } else {

        state = state.uptrend;

        minMaxPrice = Max(priceH, GetValue(minMaxPrice, 1));

    }

} else {

    if (price >= GetValue(minMaxPrice, 1) + reversalAmount) {

        state = state.uptrend;

        minMaxPrice = priceH;

    } else {

        state = state.downtrend;

        minMaxPrice = Min(priceL, GetValue(minMaxPrice, 1));

    }

}



def isCalculated = GetValue(state, 0) != GetValue(state, 1) and barNumber >= 1;

def futureDepth =  barCount - barNumber;

def tmpLastPeriodBar;

if (isCalculated) {

    if (futureDepth >= 1 and GetValue(state, 0) == GetValue(state, -1)) {

        tmpLastPeriodBar = fold lastPeriodBarI = 2 to futureDepth + 1 with 

lastPeriodBarAcc = 1

            while lastPeriodBarAcc > 0

            do if (GetValue(state, 0) != GetValue(state, -lastPeriodBarI))

                then -lastPeriodBarAcc

                else lastPeriodBarAcc + 1;

    } else {

        tmpLastPeriodBar = 0;

    }

} else {

    tmpLastPeriodBar = Double.NaN;

}



def lastPeriodBar = if (!IsNaN(tmpLastPeriodBar)) then -AbsValue

(tmpLastPeriodBar) else -futureDepth;



rec currentPriceLevel;

rec currentPoints;

if (state == state.uptrend and isCalculated) {

    currentPriceLevel =

        fold barWithMaxOnPeriodI = lastPeriodBar to 1 with barWithMaxOnPeriodAcc 

= minMaxPrice

            do Max(barWithMaxOnPeriodAcc, GetValue(minMaxPrice, 

barWithMaxOnPeriodI));

    currentPoints =

        fold maxPointOnPeriodI = lastPeriodBar to 1 with maxPointOnPeriodAcc = 

Double.NaN

            while IsNaN(maxPointOnPeriodAcc)

            do if (GetValue(priceH, maxPointOnPeriodI) == currentPriceLevel)

                then maxPointOnPeriodI

                else maxPointOnPeriodAcc;

} else if (state == state.downtrend and isCalculated) {

    currentPriceLevel =

        fold barWithMinOnPeriodI = lastPeriodBar to 1 with barWithMinOnPeriodAcc 

= minMaxPrice

            do Min(barWithMinOnPeriodAcc, GetValue(minMaxPrice, 

barWithMinOnPeriodI));

    currentPoints =

        fold minPointOnPeriodI = lastPeriodBar to 1 with minPointOnPeriodAcc = 

Double.NaN

            while IsNaN(minPointOnPeriodAcc)

            do if (GetValue(priceL, minPointOnPeriodI) == currentPriceLevel)

                then minPointOnPeriodI

                else minPointOnPeriodAcc;

} else if (!isCalculated and (state == state.uptrend or state == 

state.downtrend)) {

    currentPriceLevel = GetValue(currentPriceLevel, 1);

    currentPoints = GetValue(currentPoints, 1) + 1;

} else {

    currentPoints = 1;

    currentPriceLevel = GetValue(price, currentPoints);

}



plot "ZZ$" = if (barNumber == barCount or barNumber == 1) then if state == 

state.uptrend then priceH else priceL else if (currentPoints == 0) then 

currentPriceLevel else Double.NaN;



rec zzSave =  if !IsNaN("ZZ$") then if (barNumber == barCount or barNumber == 1) 

then if IsNaN(barNumber[-1]) and  state == state.uptrend then priceH else priceL 

else currentPriceLevel else GetValue(zzSave, 1);



def chg = (if barNumber == barCount and currentPoints < 0 then priceH else if 

barNumber == barCount and currentPoints > 0 then priceL else currentPriceLevel) 

- GetValue(zzSave, 1);



def isUp = chg >= 0;

rec isConf = AbsValue(chg) >= reversalAmount or (IsNaN(GetValue("ZZ$", 1)) and 

GetValue(isConf, 1));



"ZZ$".EnableApproximation();

"ZZ$".DefineColor("Up Trend", Color.GREEN);

"ZZ$".DefineColor("Down Trend", Color.RED);

"ZZ$".DefineColor("Undefined", Color.DARK_ORANGE);

"ZZ$".AssignValueColor(if !isConf then "ZZ$".Color("Undefined") else if isUp 

then "ZZ$".Color("Up Trend") else "ZZ$".Color("Down Trend"));

"ZZ$".SetLineWeight(2);

DefineGlobalColor("Unconfirmed", Color.DARK_ORANGE);

DefineGlobalColor("Up", Color.GREEN);

DefineGlobalColor("Down", Color.RED);

 

#Arrows



def zzL = if !IsNaN("ZZ$") and state == state.downtrend then priceL else 

GetValue(zzL, 1);



def zzH = if !IsNaN("ZZ$") and state == state.uptrend then priceH else GetValue

(zzH, 1);



def dir = CompoundValue(1, if zzL != zzL[1] then 1 else if zzH != zzH[1] then -1 

else dir[1], 0);



def signal = CompoundValue(1,

    if dir > 0 and low > zzL then

        if signal[1] <= 0 then 1 else signal[1]

    else if dir < 0 and high < zzH then

        if signal[1] >= 0 then -1 else signal[1]

    else signal[1]

, 0);



plot U1 = showArrows and signal > 0 and signal[1] <= 0;

U1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);

U1.SetDefaultColor(Color.GREEN);

U1.SetLineWeight(4);



plot D1 = showArrows and signal < 0 and signal[1] >= 0;

D1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

D1.SetDefaultColor(Color.RED);

D1.SetLineWeight(4);



Alert(useAlerts and U1, "ZIG-UP", Alert.BAR, Sound.Bell);

Alert(useAlerts and D1, "ZAG-DOWN", Alert.BAR, Sound.Chimes);



#Supply Demand Areas

def idx = if showSupplyDemand == showSupplyDemand.Pivot then 1 else 0;

def rLow;

def rHigh;



if barNumber() == 1 {

    rLow = Double.NaN;

    rHigh = Double.NaN;

} else if signal crosses 0 {

    rLow = low[idx];

    rHigh = high[idx];

} else {

    rLow = rLow[1];

    rHigh = rHigh[1];

}



plot HighLine = if showSupplyDemand and !IsNaN(close) then rHigh else 

Double.NaN;

HighLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

HighLine.AssignValueColor(if signal > 0 then Color.GREEN else Color.RED);



plot LowLine = if showSupplyDemand and !IsNaN(close) then rLow else Double.NaN;

LowLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

LowLine.AssignValueColor(if signal > 0 then Color.GREEN else Color.RED);



def hlUp = if signal > 0 then HighLine else Double.NaN;

def hlDn = if signal < 0 then HighLine else Double.NaN;



AddCloud(hlUp, LowLine, Color.GREEN, Color.GREEN);

AddCloud(hlDn, LowLine, Color.RED, Color.RED);



## END CODE
 
I look for either a cyan candle for swing low in conjunction with the smi crossing above the average smi and I like it -30 or below. The opposite is for the pink candle high.
I downloaded tomsk's ZigZag indicator but don't see the cyan and pink candles like you do. What am I doing wrong? Thanks!
 
I downloaded tomsk's ZigZag indicator but don't see the cyan and pink candles like you do. What am I doing wrong? Thanks!
@Tradervic The colored candles come from this

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);
# End Swing High and Swing Low
 
So I will need to delete what I downloaded and upload what you just posted? Thank you so much for your reply.
 
So I will need to delete what I downloaded and upload what you just posted? Thank you so much for your reply.
I don't use the high and low lines. I just use the cyan and pink candles along with trend lines for my trading. Be aware that if a cyan or pink candle is exceeded the color goes away and a new one will appear. I always look for confirmation once the colors appear. I also use the colors in conjunction with the True Momentum Oscillator. I'm happy to show you a chart if that will help. I trade a 3m and 9m but certainly this is applicable to higher timeframes.
 
I don't use the high and low lines. I just use the cyan and pink candles along with trend lines for my trading. Be aware that if a cyan or pink candle is exceeded the color goes away and a new one will appear. I always look for confirmation once the colors appear. I also use the colors in conjunction with the True Momentum Oscillator. I'm happy to show you a chart if that will help. I trade a 3m and 9m but certainly this is applicable to higher timeframes.
can i see the chart
 

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

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
235 Online
Create Post

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