Formatted Pivot Points for Think or Swim

UPDATE SEP 10 2009: Uploaded a new version of this indicator, called “DynamicHidingPivotsSTUDY.ts” to my Google Site, under “Released Thinkscript Studies“. This version works on any timeframe, and can do Daily, Weekly or Monthly pivots. Plus, you can show all pivots in your chart date range, or only the values for the most recent day.

UPDATE FEB 27 2009: Changed the dynamic hiding to operate on prior bar instead of current bar. Then you don’t get epileptic seizures from the hiding flipping on and off. I also had to add code to handle this hiding if you add extra bars to your chart under settings.


Think or Swim recently included automatic pivot points as a new indicator. Excellent! But you can’t change the formatting of them, so you get only dots, and you have to manually turn the levels on or off if you don’t want to see all of them. Bogus! Oh well, easy enough to write your own Thinkscript to handle formatting.

I like my pivot point line to be gray, and the support lines green, the resistance lines red. I also like dash size and line thickness to denote level (e.g. S1, S2, S3). Finally, I want the pivots to dynamically hide and show themselves based on where price is currently. I find it useful to plot R1, PP and S1 at the same time, and fit those levels to the screen. This helps to keep a proper sense of scale for the day’s probable range. But if price goes up above R1 or R2, fitting all those levels to the chart washes out the price action. This Thinkscript lets me fit studies to the chart, but only show levels I’m interested in based on where price is currently located. There is an input to switch dynamic hiding off, so you can easily see all levels if you want to:


Tags: , ,

11 Responses to “Formatted Pivot Points for Think or Swim”

  1. AVIAT72 Says:

    Do you know if the “reference studyname.variable” method works for user defined studies also? Does the variable have to be a plotted variable or can it be an internal variable. I have a plot in a user defined study which I want to access in another study but can not do it.

  2. Prospectus Says:

    I haven’t been able to get that to work, so I think no. Just reproduce the code in your new study. It’s a pain, but it’s the only way right now.

  3. AVIAT72 Says:

    Thanks for confirming that Prospectus.

    Do you have any code handy which can get the High/Low/Close for the Real Time Hours of the previous trading day?

    In general, if you want to perform calculations using price data from previous Day(s) what is the best methodology when you are plotting on intra-day charts>

  4. AVIAT72 Says:

    BTW Found It!

  5. Prospectus Says:

    You can use these (off the top of my head, so check it for bugs):

    Def priorclose=Close(timeframe=”Day”)[1];
    Def priorhigh=High(timeframe=”Day”)[1];
    Def priorlow=Low(timeframe=”Day”)[1];

    These will return the values from the regular market hours only, as defined for what it is (stocks, futures).

    I need to update this pivot point study to use this method. I have one on my local studies, just haven’t updated this blog post.

  6. Tutorial: Formatting Plots Using Thinkscript for Think or Swim « Read the Prospectus Says:

    […] ENTIRE plot based on the results of the “if” test in real time. This is what I do in my Formatted Pivot Points indicator to do dynamic […]

  7. Dynamic-Hiding Pivot Points « Read the Prospectus Says:

    […] Pivot Points By Prospectus I updated this post on Formatted Pivot Points. I uploaded a new version of this indicator, called “DynamicHidingPivotsSTUDY.ts” to my […]

  8. Breakshot Says:

    Hi! Nice convenient implementation of the much used study. No more disabling of pivot lines because they wash up the screen!

    I have just a quick question however, is it possible to add middle lines between S2, S1, PP, R1, R2… etc

    I think that would prove especially useful for FOREX markets…


  9. Joseph Says:

    I LOVE this Prospectus….THANK YOU!!!!

  10. day trading Says:

    Have you ever considered creating an e-book or guest authoring on other sites?
    I have a blog based upon on the same ideas you discuss and would love to have you share some
    stories/information. I know my audience would value
    your work. If you are even remotely interested, feel free to send
    me an email.

  11. Kim Wagner Says:

    Would you be interested and/or available to convert some vba coding into thinkscript language for me?? I would be greatly appreciative! Shoot me an email and let me know. Thanks so much!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: