Appendix C. Customizing Hints and Annotations

When constructing new studies, it may be helpful to add hints or annotations to your scripts. Hints provide a refresher on the purpose of an input, while annotations provide additional information about how an input should be used. Both thinkScript® functionalities help reduce script complexity and calculation errors.

Creating Hints

Hints must be added before any declaration. To declare hints, use the pound sign (#) followed by the word hint

Here is an example:

#hint: <b>Hints</b> \n This study demonstrates hints. \n <li>And hints for inputs as well.</li>
#hint length: <b>Nothing</b> depends on this parameter.

input price = close;
input length = 12;

plot Data = price;

This script defines two hints: one for the study itself and one for the length input. Study specific hints can be viewed by right clicking your study and selecting the Info option, while input specific hints are displayed under the Edit Studies and Strategies dialog window.

Note that to add a hint to an input, #hint must be followed by the input name. In this case, we defined a hint for length, followed by a colon (:). This lets thinkScript® know you’re ready to write the actual text for your hint.

Formatting Hints

There are also options for hint formatting: 

  • Use the <b></b> tag to target text you wish to display in bold.
  • Use the escape sequence \n to add a new line. 
  • Use the <li></li> tags to break down a description into a list.

Thermo Mode Visualization

Adding hints is also a means of defining default values for Thermo Mode visualization. To do this you need to use thermo instead of hint.

Here’s an example:

#thermo plot : Data
#thermo input : length
#thermo minValue : 10
#thermo maxValue : 50
#thermo minColor : 0, 0, 255
#thermo maxColor : 255, 255, 255

input length = 35;
plot Data = Average(close, length);

In this example, when Thermo Mode is enabled, thinkScript® plots the Simple Moving Average of close price with user-defined parameters:

  • Data is the plot for our Thermo visualization.
  • length sets the lookback period.
  • minValue and maxValue define the lower and upper limits, respectively.
  • minColor and maxColor determine the color of the lowest and highest values (blue and white, respectively). 

Consider including thermo hints in studies with multiple inputs and plots. This practice will help you identify values intended to be used in Thermo Mode.

Creating Annotations

Annotations provide additional information on how inputs are treated by the thinkScript® compiler, without directly affecting script calculation logic. Annotated data eliminates certain runtime errors caused by data type or format mismatches and improves the graphical interface for input adjustments.

Annotations must be added before the input declaration. To declare annotations, use the at sign (@) followed by a supported annotation type.

Here's an example:

@Date
input beginDate = 20231106;
@Date
input endDate = 20231226;

AddLabel(yes, CountTradingDays(beginDate, endDate));

This script adds a chart label that displays the number of elapsed trading days between beginDate and endDate. We start by declaring a date annotation using @Date and define our inputs as integers in the YYYYMMDD format. Each annotation marks one input. 

By using date annotation, we tell thinkScript® to treat our inputs as dates rather than numbers. This allows us to change input values with the built-in date picker in the Edit Studies and Strategies window. 

You may also like
MomentumPercentDiff
The Momentum Percent Diff is a momentum-based technical indicator. Unlike the regular Momentum ...
WilliamsAD
The Williams Accumulation/Distribution study is used to determine either the marketplace is ...
ATR
The Average True Range (ATR) study calculates the average true price range over a time period. ...