When watching market quotes, you may need to calculate certain studies for one or several symbols. You can use the thinkScript® feature called Custom Quotes for that purpose.
Accessing Custom Quotes
- Navigate to the MarketWatch tab and choose Quotes.
- Add as many symbols as you wish to the Symbol column. To do that, click the empty cell at the bottom of the column and type the symbol name in it.
- Right-click a table header and select Customize...
- Add a numbered Custom item (Custom 1, Custom 2, etc.) to the current set. You must add one item for each value you want to calculate. This will automatically open the Custom Quote Formula editor window for new items. To edit an existing custom item, click on the script icon before its name in the right-hand pane.
- If necessary, name your column in the Column name field.
- Click the aggregation button (by default, D) to specify a period to be used in the calculations.
- Click and select a price type from the FX Price Type dropdown: this will set the price type for forex symbols. Available options are bid, ask, mark, and last.
- Use Condition Wizard to create a simple formula or thinkScript Editor to create a thinkScript-based custom quote of any complexity.
- Once you're finished with the configurations:
- Select Apply to see the configurations without closing the Custom Quote Formula window.
- Select OK to save the configuration and exit the Custom Quote Formula editor.
- Select Cancel to discard your configurations and exit the Custom Quote Formula editor.
Example 1 (Condition Wizard)
To use a 60 day exponential moving average (EMA) as the quote formula, do the following in the Custom Quote Formula window:
- Make sure that the aggregation period is set to Day (shown as D next to the Column name field).
- Click Edit in the condition row. This will open the Edit Condition window.
- In the top dropdown, select Study and choose MovAvgExponential from the study lookup list. Set the length input parameter to 60.
- In the right-hand pane, select as value. This will prompt Condition Wizard to use study values instead of creating a Boolean condition.
- Click Save. This will redirect you back to the Custom Quote Formula window.
- Click OK to save the changes and close the window. The exponential moving average will then be used in the custom quote you’ve created.
For more information on how to create conditions and studies in Condition Wizard, refer to the Condition Wizard page.
Example 2 (thinkScript Editor)
You can also use custom study values as quotes. In this example, we'll use the difference between 40 and 10 period Momentum values as the quote formula.
1. Navigate to the thinkScript Editor tab and paste the following script:
def period1 = 40;
def period2 = 10;
plot a = Momentum(length = period1) - Momentum(length = period2);
2. Click OK to save the changes and close the window.
Value Formatting
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"));
Specific Usage
The usage of thinkScript in Custom Quotes has some distinctive rules:
- You can use bid and ask functions.
- 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) are supported, but formulas are calculated based on the selected aggregation period (see 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 |