This is a collection of handy thinkscripts for use on the thinkorswim (TOS)trading platform. There are two types of ThinkScript:
![Thinkscript How To Reference Volcomp Thinkscript How To Reference Volcomp](/uploads/1/2/5/6/125699266/443675047.jpg)
Thinkorswim Group, Inc. Bio-Reference Laboratories, Inc.
- ThinkScripts
These scripts are full powered and intended for use on charts,scan queries, and conditional orders. The instructions forimporting/exporting ThinkScripts applies to these scripts. - Custom Quote Scripts
These scripts are intended for use on watchlists, anywherea custom quote can be inserted as a column, and scan queries.To use these, the user must copy and paste the code into acustom quote thinkscript code area. TOS offers 20 custom quoteslots.
The workflow for ThinkScripts and Custom Quote Scripts can be made muchmore fluid once TOS enables features open to builtin scripts to usercreated scripts. These are features such as the
#Wizard
keyword, directreferencing of user created scripts (not just builtinscripts), not creating a copy of referenced thinkscript code when referencingthem as a condition in a custom script (this causes changes in the originalto not propagate to the custom script), etc.What ThinkScripts Are Available?
PM Rank
Calculates the percentile rank for the current value of the selectedFundamental Data (IV, Price, etc.) as it compares to its range over auser or chart specified number of periods (FIVE_MIN, DAY, etc).It is essentially
Calculates the percentile rank for the current value of the selectedFundamental Data (IV, Price, etc.) as it compares to its range over auser or chart specified number of periods (FIVE_MIN, DAY, etc).It is essentially
(value-lowest)/(highest-lowest)
. This script can beused as a plot and as a label.PM Percent Change
Calculates the percent change in value from now and N periods ago where:
Calculates the percent change in value from now and N periods ago where:
- value is any data type enumerated by Fundamental Data such asCLOSE, IV, etc.,
- N is any user specified lookback length, and
- period is any user or chart selected aggregation periodsuch as FIVE_MIN, DAY, etc.
This script can be used as a plot and as a label.
PM Show OHLC
Plots the previous day's OHLC and today's OHL.
Plots the previous day's OHLC and today's OHL.
PM Sandbox
A playground to wrangle with thinkscript syntax, functions, and assumptions.
A playground to wrangle with thinkscript syntax, functions, and assumptions.
Custom Quote Scripts
PM IV Rank CQ
A bare bones distilled version of PM_Rank that only computes the IV Rankover 252 trading days rounded to one significant digit (one decimal place).Note, this script colors the value based on where it lays within the rank.Edit the code to change the lookback period and rank coloring thresholdsto fit your needs.
A bare bones distilled version of PM_Rank that only computes the IV Rankover 252 trading days rounded to one significant digit (one decimal place).Note, this script colors the value based on where it lays within the rank.Edit the code to change the lookback period and rank coloring thresholdsto fit your needs.
PM Price Rank CQ
A bare bones distilled version of PM_Rank that only computes the Price Rankover 252 trading days rounded to one significant digit (one decimal place).Note, this script colors the value based on where it lays within the rank.Edit the code to change the lookback period and rank coloring thresholdsto fit your needs.
A bare bones distilled version of PM_Rank that only computes the Price Rankover 252 trading days rounded to one significant digit (one decimal place).Note, this script colors the value based on where it lays within the rank.Edit the code to change the lookback period and rank coloring thresholdsto fit your needs.
PM Rank CQ
A bare bones distilled version of PM_Rank with less user input controls. Itcalculates the percentile rank over 252 trading days for desired fundamentaldata (IV, O, H, L, C, Volume, etc.). Note, this script colors the value basedon where it lays within the rank. Edit the input data source or the lookbackperiod and rank coloring thresholds to fit your needs.
A bare bones distilled version of PM_Rank with less user input controls. Itcalculates the percentile rank over 252 trading days for desired fundamentaldata (IV, O, H, L, C, Volume, etc.). Note, this script colors the value basedon where it lays within the rank. Edit the input data source or the lookbackperiod and rank coloring thresholds to fit your needs.
This one is intended to be imported as a study and referenced for customquote scripts and scan queries. Once TOS fixes workflow issues, this willbe the preferred method so there will be one source file for Rank relatedcomputations. Until then, it's easier/faster to use the rank specific cqscripts above.
PM Rank Coloring CQ
This is an example script to show how one can enable the coloring of dataif the core script is referenced. As of 2013-11-09, the TOS limitationswill essentially copy the core script code into a custom script using the
This is an example script to show how one can enable the coloring of dataif the core script is referenced. As of 2013-11-09, the TOS limitationswill essentially copy the core script code into a custom script using the
script { }
notation and add the coloring details below it.PM Percent Chg CQ
A bare bones distilled version of PM_PercentChg that only computes the %chgover 10 trading days rounded to one significant digit (one decimal place).Note, this script colors the value based on hi and lo alert thresholds.Edit the code to change the data type, lookback period, and alert coloringthresholds to fit your needs. Also, this script minimizes column space bynot outputting the '%' character.
A bare bones distilled version of PM_PercentChg that only computes the %chgover 10 trading days rounded to one significant digit (one decimal place).Note, this script colors the value based on hi and lo alert thresholds.Edit the code to change the data type, lookback period, and alert coloringthresholds to fit your needs. Also, this script minimizes column space bynot outputting the '%' character.
How Do I Install/Update ThinkScripts?
Downloading the script(s)
Enumerated below are a few ways to obtain these scripts:
- Clone this project in the following ways:
- Click on the
Clone in Desktop
link located on the right sidebar on GitHub - Run
git clone https://github.com/dranem05/thinkscripts-pub.git
locally
- Click on the
- Download an untracked version of these files:
- Click on the
Download ZIP
link located on the right sidebar on GitHub - Unzip the dowloaded archive to a local directory
- Click on the
- Download a specific script:
- Navigate to the file on GitHub
- Click on the source file
- Click on
Raw
to download the file
Installing
- Download this project into a local directory
- Fire up TOS
- Open up a chart
- Click on the
analysis tools
icon (looks like something dripping) - Click on
edit studies
- Click on
import
on the bottom of the left panel - Navigate to the thinkscripts directory where you dowloaded this project
It should be somewhere like:path/to/download/thinkscripts-pub.git/thinkscipts/
- Select the desired study and click open (or just double click the desired study)
The script should now be available in your TOS database.
Updating
- Get the latest version of the script
rungit pull origin
if you created a local clone of this project - Fire up TOS
- Open up a chart
- Click on the
analysis tools
icon (looks like something dripping) - Click on
edit studies
- Click on
import
on the bottom of the left panel - Navigate to the thinkscripts directory where you dowloaded this project
It should be somewhere like:path/to/download/thinkscripts-pub.git/thinkscipts/
- Select the desired study and click open (or just double click the desired study)
- You will be asked if you really want to replace the study in TOS
- Click on
Yes
Note, that the 'latest version of the script' could be local edits youmade in your local copy of the file outside of TOS. The same steps aboveallow you to update the TOS version of the script.
Exporting Changes Made via TOS's ThinkScript Editor
If you edit the thinkscripts via TOS, you can export these edits to your localcopy of this project.
- Navigate to the script via the
edit studies
window - Click on
export
- You will be asked where you would like the study to be exported
- Export to your local directory of thinkscripts
- Confirm your desire to overwrite the local copy with this new copy
If your local thinkscripts directory is a git clone location, you canuse it to maintain your own version controlled copy of the scripts.
Using/Referencing in Custom Quotes and Scan Queries
- Navigate to the
Condition Wizard
tab- For Custom Quotes
- Follow the instructions in the 'How Do I Install/UpdateCustom Quote Scripts' section up to the step just priorto clicking on the
thinksScript Editor
tab. - Click on the
Condition Wizard
tab.
- Follow the instructions in the 'How Do I Install/UpdateCustom Quote Scripts' section up to the step just priorto clicking on the
- For Scan Query Criteria
- Click on the
Scan
tab - Click on
Add Study Filter
- Click on the study selector widget
- Click on the
Custom...
option
- Click on the
- For Custom Quotes
- Click on
Edit
orAdd Condition
- Click on the study selector widget
- Click on the
Study
option - Search for the desired study
- Update input parameters if applicable
- Select which plot to use as the scripts value
- Select your comparison operator, etc.
IMPORTANT:
Once referenced, TOS essentially creates an exact copy of the referencedscript and uses this copy. Thus any changes made to the original DOES NOTPROPAGATE to the custom script. You have to re-reference the scriptto propagate any changes that were made to the original.
How Do I Install/Update Custom Quote Scripts?
Downloading and getting the latest updates from this GitHub repositoryare the same as with the regular ThinkScripts. Installing/Updating intoTOS is a bit different.
Installing
- Right click on a column name in a watchlist type of widget
(or nearly anything that looks like a table with columns) - Click on
Customize
- Under the
Available Items
left side panel, search forcustom
- Click on the scroll icon that appears to the left of any
custom
item - Click on the
thinkScript Editor
tab in the window that appears - Copy and paste the custom quote script into this window
- Rename the script from
Custom
to whatever you like - Click on
OK
Updating
- Get the latest version of the script
- Right click on a column name in a watchlist type of widget
(or nearly anything that looks like a table with columns) - Click on
Customize
- Under the
Available Items
left side panel, search for the desired script - Click on the scroll icon that appears to the left of that script
- Click on the
thinkScript Editor
tab in the window that appears - Copy and paste the updated code into the thinkScript Editor
- Click on
OK
References
License
Code is under the MIT license.