Trading Toolbox. Learn thinkScript. ThinkorSwim: FAQ. Premium Indicators. Bitcoin Indicator. Theta Gang Indicators. Download ThinkorSwim. Log in. Install the app. Is this content inappropriate? Report this Document. Flag for inappropriate content. Download now.
ThinkScript User Manual. Related titles. Carousel Previous Carousel Next. Jump to Page. Search inside document. Email us at support thinkorswim.
Put simply, thinkScript is a way to manipulate the closing, opening, high and low price of a stock or index, as well as the trading volume and volatility of a stock or index with a formula and then display the results on a chart. Like building blocks, each element of thinkScript is, in itself, fairly simple but combining them together can yield some complex and powerful results. To begin using the thinkScript editor for studies, go to the Charts tab, click 'Studies' in the upper right corner of the page and select 'Edit Studies'.
This will open the 'Edit Studies' window. To use thinkScript to make a study of your own you now have two choices: To create a new study by fine-tuning an existing study, first find a study in the 'Available studies' list marked by the icon.
Next click on the Blue Bullet next to the chosen study and click 'Copy This will open the 'New study' editor with the chosen study's definition preloaded. To create your own study from scratch, simply click the 'New study' button in the bottom left corner of the 'Edit Studies' window.
Also, thinkScript code is not case-sensitive. These commands control the basic behavior of your thinkScript study. There are three current uses for declare: declare upper; This command places your study in the main chart window on top of the pricing bars. You want an upper study if your study plot falls more or less within the same range as pricing.
By default, all studies created with thinkScript are upper studies and you don't have to make this declaration. You want a lower study if your study is some complex value in the range of , i. Every study contains at least on plot declaration without one, nothing would be displayed on the chart. For it to work, you must give the data you are trying to plot a name and then define what that data will represent.
For example, if you want to plot the closing price of a stock, you can't simply write plot close; That won't work. This let's you construct complex formulas from simpler elements. In this case, SMA itself is not displayed on the chart because there is no plot declaration to do so. An input is like a def that can be adjusted in the 'Edit Studies' window or in the 'Format Study' dialog found by right-clicking on a study line right on the graph. Rec is short for "recursion".
You can specify these parameters in any order. Function Definitions AbsValue calculates the absolute value of some value. If you do not specify a length for the data set, the default number of bars is The first parameter is the data type to compare on. First, it can be used on the right side of an equation bu using 3 parameters: a condition, a true value and a false value.
Like between, the 'if' function will most likely be used as a test for a larger study. For example, data. This actually gives you a 20 day moving average. If you do not specify a length for the data set, the default 12 bars of data is used.
If the chart displays one year of data, totalsum will add up year. If you are looking at one month of data, totalsum will add up one month. In an application or software such an input is called a 'select box'. You can create a select box in thinkScript by using a construction known as an 'enum'. In this case it's 'Mon'. In order to do something more powerful with the results of your select box rather than simply operate on the numeric value 0,1, Accessing Data From Another Symbol To access data from another symbol in your code, append the name of the symbol in quotes and parentheses to the data type you want to use.
Using Historical Data To access a value from a previous bar of data, you can use what is called [offset] syntax. Please note: in thinkScript, a positive number is used to refer to data in the past. Negative numbers will give you bars in the future when working from historical data. Referencing Pre-Defined Studies thinkScript allows you to reference studies that are already available on the Charts tab in your code.
You use the reference keyword to do this. So long as the study name is followed by parentheses, you don't need to include the word 'reference'. You can change the parameters of the study within reference by inputting them between parentheses. To see the input parameters of a particular study, click on that study in the 'Edit Studies' section of the Charts tab.
You will see the available parameters listed in the study properties section. However, you can specify the plot you want to reference, as well.
You are even able to combine many technical indicators in one by referencing them in your code or just using functions that represent the most popular studies such as simple or exponential moving average. You can find them here. Each tutorial comes with a quiz so you can check your knowledge. How do I learn to script? Manual plus trial and error plus looking at other code plus desire. Good luck. Upvote 1 Downvote. I am asking because I read the manual and didn't see it and respectfully asking for advice on how to read the manual different than what I did.
I don't think it is there. I can be wrong, that is why I am here. I disagree with you respectfully. I will assume it didn't explain it to you either, but you learned it from trial and error and asking others who stumbled upon the solution with good luck. I owe you one. MerryDay Administrative Staff member. DanielManahan No thinkscript has no robust manual. ToS started as a simple plot scripting code. What traders have managed to make it do, is mostly undocumented and amazing. The good news is that the format of the scripting is consistent.
Now that you have learn the if--then-else format.
0コメント