thinkScript Editor

thinkScript® Editor is an advanced code editor that allows you to create your own thinkScript®-based studies and strategies. In this editor, you can:

  • compose and edit your code
  • highlight syntax
  • format your code
  • use integrated thinkScript® library
  • save your scripts and use version control system

Access to thinkScript® Editor

To access thinkScript® Editor:

  1. Click Studies above the chart. Choose Edit Studies…
  2. Click Create... below the list of available studies. To create a strategy, do the same on the Strategies tab. To edit an existing study or strategy, click on the scroll icon before its title. 

Main components

In the thinkScript® Editor window, you will see the following:

1. Name text field. Use this field to properly name your study or strategy.

2. Share button. Use this button if you would like to create a link by which your study or strategy will be available to others.

3. Toolbar. The toolbar contains four buttons:

  • Undo. Click to undo your last action. You can undo up to 50 last actions.
  • Reformat code. Click this button to make your code more readable.
  • Options. Click this button to access the Options menu. In this menu, you can turn on and off auto-complete functionality, change font settings, or discard all setting changes.
  • Help on thinkScript®. Click this button to open Learning Center in your default browser.

4. Text editor. Type your code in the text editor. The editor automatically parses your code as you type: valid elements are highlighted according to their syntax role. Invalid elements are shown in red; you can find details on the errors in your script directly below it.

Note: When your code is empty or contains a single valid condition or expression, you can use Condition Wizard, an interface that allows you to create conditions or logical expressions without using thinkScript.

5. Reference library/Inspector. Using the library tree, you can find all the existing thinkScript® entities: functions, constants, reserved words, etc. In addition, you can find existing studies. Clicking on any name on this list will display a description in the description box below the tree. Double-clicking on any name will insert it into the text editor.

Inspector, by default, shows you a virtual numpad and a dropdown that allows you to insert an existing study name in your code. This view mode is shown when the text cursor is in whitespace. When the text cursor is placed inside a study or function name, Inspector displays a panel that allows you to modify input parameters of that study or strategy.

6. Change History/Save area. This area allows you to save your script and manage its versioning. See details below.

Change History

Change History is a functionality that allows you to store multiple versions of a script, label some of the versions, and revert changes. Here is how you can use it:

  1. Every time you make changes to your script and click OK, the system stores your script version in Change History. To view the list of the stored versions, click on the Change History dropdown below your script.
  2. You can view the code of each version in Change History; however, you cannot edit it. Only current version can be edited.
  3. You can restore any of the versions in Change History, i.e., make it the current version that can be edited. To do so, select the version you would like to restore and click Restore this version.
    Note: this will erase any changes you’ve made in the current version. Consider clicking OK first to store the current version. You can also click Undo to undo restoring a past version.
  4. Consider labeling your script versions so you will be able to tell one from another. To do so, select a version you would like to label and click on the label icon. Type in the desirable label and click OK. The label will be displayed next to this version’s name on the list.
    Note: you can only have up to ten labeled versions. In addition, you can have up to 20 unlabeled ones. The system automatically replaces older unlabeled versions when this limit is reached. Always label the most important versions.
  5. To remove a label from a version, click on the Change History dropdown and navigate to Remove label. Click on the version with the label you would like to remove.
  6. You can save any of the versions as a new study or strategy. To do so, select the version you would like to save in the Change History dropdown and click Save as new script... Specify the name of the study or strategy and click Save.

Note: when you add a study or strategy with a script that has multiple versions, the system will calculate it based on its current-version script. If you would like to calculate it based on another version, consider restoring that version as the current one or saving it under a different name.