When watching market quotes, you might need immediate calculation of certain studies for one or several symbols. You can use the thinkScript® integration feature in Custom Quotes for that purpose.
How to Find It:
1. Click the MarketWatch tab and choose Quote from the sub-tab row.
2. Add as many symbols as you wish to the Symbol column. In order to do that, click the empty cell in the bottom of the column and type symbol's name in it.
3. Right-click on the upper row of the watchlist and choose Customize... from the menu.
4. Add a Custom item (or several) to the current set - one for each value to be calculated. Click the "script" icon next to it to call the Custom Quote Formula editor window.
Now you are ready to create a study whose values will be displayed in your watchlist. For pre-defined studies, the interface allows you to specify the study plot whose values will be analyzed, input parameters, and aggregation period - these can be set in the right section of the editor window. For custom studies, aggregation period can be set using the Aggregation list. Also, make sure you are using a convenient name for the study, which can be specified within the Column name string.
To add a 60 day simple moving average (SMA), use the following script:
After that, choose "Day" from the Aggregation list and set the
length input parameter equal to 60. Note that once a pre-defined study is added, you can replace it with another one by choosing the corresponding name from the Study list which is now active.
You can also use a custom study. Consider the following example:
def period1 = 40;
def period2 = 10;
plot a = Momentum(length = period1) - Momentum(length = period2);
This script calculates the difference between 40 and 10 period Momentum values. As you can see, the standard thinkScript® syntax is also supported in Custom Quotes formulas.
Once you have set the Custom Quote formula, click OK; study values will appear in the column with the corresponding name. Note that you can adjust calculation rules by right-clicking the column name and choosing Edit formula from the menu.
Custom Quotes are also available for watchlists in Watchlist gadget, Scan results, and Option view at All Products under the Trade tab.
In Custom Quotes, plot values are displayed using the same number of decimal digits as in tick size with a trailing zero. This can be avoided by using the AddLabel() function for the output and then formatting it with the AsText() function. Note, however, that in this case the output will be perceived as text, which means that the column will be sorted alphanumerically. For example, in the alphanumerical sorting, 1111 is less than 12, so please pay attention to that if you choose the formatted output.
The following script will display SMA values with four decimal digits:
AddLabel(yes, AsText(Average(close, 10), "%1$.4f"));
When in Custom Quotes, thinkScript® usage is somewhat different from that in studies and strategies. Here is the list of peculiarities:
Functions AssignValueColor(), SetDefaultColor(), AssignBackgroundColor(), AddLabel() have specific usage.
Studies must have exactly one plot.
Recursive variables and range-dependent functions (i.e., those dealing with data from the whole chart; example: HighestAll). Note that in this case your formula will be calculated on a certain time frame depending on chosen aggregation period (see the table below).
|Aggregation period||Time interval|
|1 Minute||1 Day|
|2 Minutes||2 Days|
|3 Minutes||3 Days|
|4 Minutes||4 Days|
|5 Minutes||5 Days|
|10 Minutes||5 Days|
|15 Minutes||5 Days|
|20 Minutes||10 Days|
|30 Minutes||10 Days|
|1 Hour||20 Days|
|2 Hours||90 Days|
|4 Hours||180 Days|
|1 Day||1 Year|
|2 Days||2 Years|
|3 Days||2 Years|
|4 Days||2 Years|
|1 Week||3 Years|
|1 Month||10 Years|
|Opt Exp||10 Years|