Update 2-18-10: v3–Added optional lines for plotting after the swing points:
As part of some work I have been doing, I needed a way to identify swing highs and swing lows. What is a swing high / low? It depends on your definition, but basically a swing high is the highest high looking a few bars back and a few bars forward. A swing low is the lowest low looking a few back and a few forward. The more bars you include in the series, the more significant the swing, but the confirmation comes further from the actual swing point. Say you wanted to define a swing high as this:
A bar high that is higher than the highs of the two bars just before it AND higher than the highs of the two bars just after it.
The thinkscript code might look like this:
Def swinghigh = if high > high[1] and high > high[2] and high > high[-1] and high > high[-2] then 1 else 0;
The code for a swing low is similar. This method is a pain because it requires you to hard code the swing period. If you want to change to a different number of bars, you have to modify the source code. Note that the confirmation of a swing point does not come until 2 bars after the swing high in this case. If you wanted to extend the swing check to 3 bars before and after, you would add the checks for a high > high[3] and high > high [-3]. The resulting swing will be more significant, but the signal comes 3 bars after the fact.
To plot the swing high you could do something like this:
Plot sh = if swinghigh then high else double.nan;
sh.setstyle(curve.points);
This would paint a dot on all the swing highs, and nothing everywhere else. The code for swing lows is similar. So now you know how to create your own swing high / swing low indicator. Free education; you provide the sweat equity. If you have any questions on making your own, leave a comment and I’ll be glad to help out!
I spent a couple of hours last night figuring out how to make the indicator generalized, meaning that you can input any number of bars to define your swing period, and the code finds the highs and lows for you without modding the indicator source code. This makes it easier to change on the fly for backtesting or responding to market volatility. Here’s what it looks like:
My pain + my brain = your gain! Become a donor and you can download my complete generalized swing point script file, ready to be imported into Think Desktop. This is part of my new “Teach for free, Work for fee” philosophy. If you donate, be sure to email me and let me know what you donated for so I can send it to you! All my files (many for free and some for donors only, including the Swing Points) are at my Google site: http://sites.google.com/site/prospectus/welcome
Tags: swing_high, swing_low, Thinkscript
April 29, 2009 at 2:46 pm
can you post some backtest results?
April 29, 2009 at 2:58 pm
I ran some quick backtests today and quickly noted the results on Twitter. Look back through my updates from today on my twitter feed.
Bottom line is that simply fading the swing point as soon as you get the signal is worse than 50/50 for intraday trading on ES. That said, I don’t think that this indicator is suited for an entry signal on it’s own. Maybe in combination with other support/resistance levels, or just to measure divergences in MACD or some other indicator. Possibly you could measure average cycle length and try to anticipate the next swing point. There’s a lot of places this idea could go to try to find a profitable system, but it’s a lot like panning for gold. Most of the time you will find nothing but mud.
April 29, 2009 at 3:14 pm
will do! thanks!
April 29, 2009 at 3:19 pm
Very true, I’ve been jotting down ideas but still nothing certain. I figure if you can manage 51% win rate with, lets say, a 50 pt/tick stop and 100 tgt it should prove profitable but i have yet to find a system that has a 51% win rate
April 30, 2009 at 11:10 pm
Has been following your work since you coded some paintbars for QuoteTracker – thank you for all you’ve done.
You and Eric (thinkscripter) are the most valuable part of TOS programming group 🙂
DavidDT
If you day trade – stop by at http://chat.paltalk.com/g2/paltalk/1192843448 – a lot of TOS refugees in there 🙂
May 6, 2009 at 6:22 pm
[…] Divergence Indicator for Think or Swim By Prospectus Following on the heels of my Swing Points indicator, I wrote an indicator that looks for divergences between the MACD and price. Every time […]
May 21, 2009 at 10:02 am
[…] it’s not complicated to write your own if you already have a swing points logic built, like I outlined previously. I’ll walk through the additional steps […]
May 26, 2009 at 11:47 am
/Hey, just to say thank you for the indicator, i have been hearing of it but i have not got the opportunity to have a look at it or used it for test drive. Could you pleas let me know if i can download it to my plateform to demo trade?.
May 26, 2009 at 4:58 pm
Thanks for your interest. I don’t have a demo version of the indicator, unfortunately. Here’s why:
I have people waiting in line for me to do custom projects for them. Since they pay me for my work, they get top priority on my time. Also, my donor scripts I publish here are usually outgrowths of some of the custom work that I have done. It’s not fair to those who have chipped in a few bucks to just give away what they have either completely paid for or contributed to. Nor is it fair to me to simply give away the products of my labor, skill (debatable) and my investment of time.
I have written tutorials and offered to answer questions, though, in the interests of freely teaching those who want to learn how to program with Thinkscript. Since I haven’t really gotten any questions, either my tutorial is so comprehensive that anyone can reproduce my indicators, or nobody really cares to learn, or some of both.
Bottom line is this: Try to write your own indicator and ask questions, and I’ll be glad to teach freely. Donate to my blog ($20 would be great) and you can download the donor scripts like all my other donors (Thanks, all!). Like in my earlier post, I teach for free, and work for fee.
If neither of these options works for you, try freethinkscript.com, as they are all about giving things away. Make sure to give them my regards. 🙂
September 28, 2009 at 6:08 am
$20 for a do loop !
September 28, 2009 at 7:00 am
I wish it were that easy! We could do so much more with Thinkscript if we could use loops.
September 28, 2009 at 7:13 am
Fair point 🙂
September 29, 2009 at 7:30 am
I am very interested in your chart indicator program on swing high/swing low. Can you give me a link to your tutorial? I have not heard of ThinkScript. How do you insert the code into a chart? I am afraid I am a real newbie and would appreciate all the help I can get. I don’t have a problem with a donation.
September 30, 2009 at 8:04 am
Ron,
I’ll make a “complete n00b’s guide to Thinkscript” and post it on the blog.
November 11, 2009 at 3:24 pm
Hi,
Ron said exactly what I was thinking… How do you insert the code?
Prospectus, is there a noobie’s guide to ToS… can you post a link to it?
Thanks!
AndyC
November 11, 2009 at 4:54 pm
I’ve been working on one, but it’s half done in my blog drafts. Maybe I should release as is and add later.
December 17, 2009 at 11:29 pm
I like to get SMMA done in thinkscript. That is the smooth moving average. Would you do it for me for a fee? Thanks
Mahesh
February 3, 2010 at 12:39 pm
Hi, I am interested in the indicator. Does the indictor work for emini and other futures? Would you give instruction and help on installations, and maybe free updates in future? Thank you.
February 3, 2010 at 12:45 pm
Yes, it works on any symbol that Think or Swim has. I can help you set it up if you need it. Blog donors only have to donate once.
February 5, 2010 at 1:17 pm
Hi, How do I contact you for the download? Could you send it to my email adress? Thank you.
February 5, 2010 at 1:23 pm
I sent my donation to your website. Please check it.
March 26, 2010 at 10:38 am
I wonder if this script can be used for intraday play…any idea what timeframe is better for this indicator?…May be we could combined with Trader-X idea in playing Opening Range with script you’ve made last year to identify the Target price…
April 20, 2010 at 2:07 am
Is there a version 4 of this? The link for v3 doesn’t seem to be working…
May 5, 2010 at 2:26 am
What if the 8/2 values could change in relation to MACD’s performance? For example, as MACD hovers in and around the 0 during lower volatility, the swing points look for larger movements.
May 22, 2010 at 8:12 am
First, love your site.
RE: Swing High, Swing Low Indicator.
This is FRACTAL Trading…….Check out Chaos Trading and Bill Williams. You could combine this indicator with his alligator indicator and AO indicator.
Enjoy you
July 11, 2010 at 6:11 pm
I wonder if you would use the rec feature to plot the additional lines until a new swing high or low is met. My non coder self tried putting rec in front of the plot lines and shut the code down.
Thanks for any clues in advance,
July 11, 2010 at 7:52 pm
It’s in there now if you choose “show levels” or something like that from the inputs. Unless I haven’t published that update?
August 26, 2010 at 12:39 am
I believe that despite your yeoman effort, your swing hi and lo definition is incorrect. I think that you got as close to scripting a fairly loose definition as as possible without having to get an army of programmers to write the script. Really, though, your work is great. Try this link http://www.medianline.com/articles/ then go to the article titled “Identifying Swing Highs and Swing Lows”. This guy is no BS.
August 26, 2010 at 7:28 am
I think there’s no canonical definition of many trading terms. One man’s swing high is another man’s higher high. The definition in that article you linked is very technically rigorous, but as far as I’m concerned it’s useless for actual trading. By the time you have a “confirmed” swing high, you’ve missed the entire move down. This is especially true for index futures, as they back and fill a lot more than they trend intraday. My indicator should be called “potential swing highs and lows” since you are making an educated guess that the high of two bars ago will pan out to be a local high. You might end up being wrong, but that’s the game.
In the end it’s all semantics I guess. And what’s more, none of it is even in the top 5 most important, foundational things to be successful at trading!
August 26, 2010 at 11:05 am
Hey Prospectus, nice to see that someone read my post. Your take on this was my first take on the stricter definition as well, but as I watched this man, Tim Morge show the trades develop, and how he uses the swings and pseudo swings, then it makes sense. Believe me this method is definitely NOT useless, and it absolutely IS one of the first rules of trading: reduce risk and protect capital. This man is one of the few real deals out there, he was a whale trading for institutions and himself for nearly 40 years and one of the few remaining first students of Dr. Andrews (Andrew’s pitchfork)until he retired. He has free Monday sessions that are worth every minute and that is where one can see it work. Now speaking of waiting to develop, yes, you may miss a few moves by his method but you will dramatically increase the odds of not getting whipsawed thereby protecting capital and reducing risk. He calls developing swings, pseudo swings but still uses them somewhat to see the structure developing, but until a swing is confirmed it simply is not a swing. So many times what many believe to be a swing will be a hicup and then the move continues on its original path drawing them into committing prematurely the wrong way. That’s the reason for confirmation. The confirmations allow you to see the pattern. The swings I’ve seen other people use may never alternate – they may have two or three swing highs in succession without a swing low to separate them. Now how can that be valid? Another site was saying, “if it looks like a swing high, it’s a swing high”. That’s quite cavalier. Such loose ways of trading separate the successful traders from the flashes that are in the pan. The details make the difference. I hate that it does because I have trouble being precise in my trading like many others, but I’ve seen the difference it makes. I hope that you do well however you trade, but please give it another thought.
August 26, 2010 at 1:42 pm
Prospectus, Hi again. I did you a disservice by not giving you the name of another article that should be read along with the other one I named. This one explains the swings and pseudo swings and how to use them much better with great examples. The article can be found in the same location http://www.medianline.com/articles/, and it’s titled: “Swing Highs and Swing Lows: Are We There Yet?”
November 10, 2012 at 4:43 am
Hi: I am new at Thinkscript and would like to know if you can help in
duplicating the input price variable in the ZIGZAG study. I just want to have the curve go from the lower and to the high. As you know it actually does it but if you choose high it does not go to the very low of the candle at the other extreme
April 30, 2013 at 7:12 pm
Hi, How do I contact you for the download? Could you send it to my email address ? Thank you. Paul.
April 30, 2013 at 7:35 pm
Just click the donate button on the blog and I’ll send the password to you. Donate what you think the indicator is worth to you. Here’s the link if the button is hard to find:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3232548
January 2, 2016 at 5:39 am
Stop asking for free everything. Remember when someone writes code you got to honor and pay for his credit if he/she demands. Here this guy is not asking a hefty dollars for indicators, so why to whine. Other options are , It takes little effort to learn scripting from Thinkscript manual , instead of sitting on couch potato and watching sitcom.
February 7, 2016 at 1:50 pm
Hi.. I made a second donation for your super cool H/L pivots. How do I get it now? Thanks! .
February 7, 2016 at 1:56 pm
Email me readtheprospectus at gmail
>
April 7, 2017 at 2:59 pm
Hi Prospectus. Are you still there? Do you have the code for…
* Swing High / Swing Low Indicator for Think or Swim
*Update 2-18-10: v3–Added optional lines for plotting after the swing points:
Does the actual source code come with it?
Please let me know. Thank you.
April 7, 2017 at 3:03 pm
I’m still here. The code is for donors to the blog. The download link is here: https://sites.google.com/site/prospectus/welcome/released-thinkscript-studies/Pro_SwingPointsv3STUDY.zip?attredirects=0&d=1
All the source code is included. TOS doesn’t support third party compiled code, so source is the only way it works.
>
June 13, 2017 at 7:56 am
How do I email you after I have donated? Is there a minimum amount?
Thanksl
June 13, 2017 at 8:03 am
There’s no minimum. Whatever it’s worth to you. You can always reach me at readtheprospectus at gmail.
June 13, 2017 at 11:48 am
okay thanks. just donated and sent you an email.
May 17, 2018 at 8:45 pm
Right Broker
Swing High / Swing Low Indicator for Think or Swim | Read the Prospectus
June 14, 2018 at 9:58 pm
Have you given any thought to adding a wave count to our Swing High / Swing Low Indicator for Think or Swim?
September 13, 2018 at 2:12 pm
Hi , Do you have any scripts similar to swing high/low of PRS signal in Trading View ?
November 19, 2018 at 12:17 am
[…] average price. I talked about VWAPs more here. The idea for this indicator is to use Swing Points to define the period where we start tracking the volume-weighted value. The chart above shows it […]
July 3, 2019 at 2:46 pm
Pretty! This has been an extremely wonderful post. Thank you for providing this info.
November 12, 2019 at 4:01 pm
I’m interested in this indicator. Are you still active and accepting donations so I can get it?
November 12, 2019 at 4:39 pm
Yes, thank you! Check your email
>
May 22, 2020 at 11:25 am
Hey Prospectus,
Do you have an indicator that alerts you when a swing low takes out a previous swing low? And vice versus for swing highs? Thanks.
Nelson
June 11, 2020 at 1:54 pm
Hello, How did you get the white lines to extend out of the dots? Cant figure it out.
September 2, 2020 at 12:40 pm
was wondering the code for Added optional lines for plotting after the swing points:?
March 12, 2021 at 7:32 pm
Can I have the codes for the swing high swing low Indicator please
September 21, 2022 at 5:23 pm
Hello,
I am interested in this indicator and would like to donate. Could you please email back and let me know if you’re still active?
There are two things i am primarily looking for in this indicator.
1. Look back and look ahead bar count.
2. Connect the swing high and swing low with trend lines to plot the market structure.
Thank you!
September 22, 2022 at 6:41 am
I’m still here. You can put whatever you want for swing forward and swing back, it’s an input variable. It doesn’t plot trendlines automatically though.
<
div dir=”ltr”>
<
blockquote type=”cite”>