HighLow ZigZag

freedom Traders

New member
I was wondering if someone can set an alarm for me please. I tried many times but didn't succeed. I also noticed it doesn't print the dot right away,can someone hel please. It was posted by someone i can't remember. It would a great piece to add on a chart.

Code:
#Begin code
#updated by BonBon - swing_back and _swing_forward (February 4, 2021)
def bubbles = yes;
input swing_back = 45;
input swing_forward = 45;
input maxbars = 50;
input showlevels = Yes;
def sb = swing_back;
def sf = swing_forward;
def na = Double.NaN;

def Offset = 8; # high(period = "day")and low(period = "day" ) and close(period = "day" ) * 0.03;
def bubblelocation = bubbles[Offset];

def lfor = Lowest(low, sf)[-sf]; #Remember that a negative number inside the square brackets means "after" this bar. So, the above line is defining "lfor" as being the lowest value of the two bars after this bar.
def lback = Lowest(low, sb)[1]; #This line of code is defining "lback" as the lowest value of the eight bars before this one.

##############################
#Finally, this line is actually defining what a "swing low" is. It says, if the low of this bar is lower than the two bars after this one AND the low of this bar is also lower than or equal to the lowest of the previous eight bars, then this bar is a swing low.

def swinglow = if low < lfor and low <= lback then 1 else 0;
plot sl = if swinglow then low else na;
sl.SetPaintingStrategy(PaintingStrategy.POINTS);
sl.SetDefaultColor(Color.WHITE);
sl.SetLineWeight(4);


def hfor = Highest(high, sf)[-sf];
def hback = Highest(high, sb)[1];

def swinghigh = if high > hfor and high >= hback then 1 else 0;
plot sh = if swinghigh then high else na ;
sh.SetDefaultColor(Color.WHITE);
sh.SetPaintingStrategy(PaintingStrategy.POINTS);
sh.SetLineWeight(4);

ll);
#End code
 
Solution
as far as alert sounds, this will help
https://usethinkscript.com/threads/please-help-me-with-this-code-swing-high-low.6584/#post-63788

for comparing highs this might help

Code:
input barsback = 8;

# check if current high is higher than prev x bars
# these will be 1 or 0 , true or false
def ishigher = ( high > highest( high[1], barsback) );
def islower = ( low < lowest[1], barsback) );

then use ishigher as the trigger variable in 1 alert function, and use islower in the other alert.
edit your post by cutting out your code and pasting it back in using code tags. then it will appear in a sub window. click the symbol at top , </> , of the edit post window. read about them from these links.

help
https://usethinkscript.com/help/

help bb codes
https://usethinkscript.com/help/bb-codes/

.......

this is the code i use for alerts.
a higher pitch sound for a signal moving up and a lower pitch sound for a signal moving down.
replace the variables a and b, with your boolean variables. which i'm guessing are swinglow and swinghigh.

Code:
#up
alert(a, "up", alert.bar, sound.ding);
#down
alert(b, "down", alert.bar, sound.bell);
#
hal_alert
 
Last edited:

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

Is it possible to have a high pitch sound for a new (data high) in the last X number of bars and a low pitch sound (like a Gong) for a new low in the last X number of bars. I would appreciate this and I am sure others would also. As I am very new to TOS scripting I have no clue how to start or even if it is possible. Thanks Ahead of time for any help with this great idea.
 
Last edited:
as far as alert sounds, this will help
https://usethinkscript.com/threads/please-help-me-with-this-code-swing-high-low.6584/#post-63788

for comparing highs this might help

Code:
input barsback = 8;

# check if current high is higher than prev x bars
# these will be 1 or 0 , true or false
def ishigher = ( high > highest( high[1], barsback) );
def islower = ( low < lowest[1], barsback) );

then use ishigher as the trigger variable in 1 alert function, and use islower in the other alert.
 
Solution

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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