Script contexts

When you save a script in the Run Script widget, you can give it a "context". This makes it available in a specific place within the Sway Charts Pro platform, rather than being part of the list of scripts for general use.

For example, you can set up a script so that it is included on the action menu for a trade or order (in the Trade List component, or from the chart marker for an open trade or pending order).

Scripts which have a context receive information about that context in their Framework.privateSettings, as described below.

9.1 Quote Board script context

Scripts which are assigned to the Quote Board context are displayed under the widget's Tools menu. For example, you could create a script which doubles up any open position on markets currently listed in the quote board.

The script receives the following information in its Framework.privateSettings about the current contents of the quote board:

9.2 Trade List script context

Scripts which are assigned to the Trade List context are displayed under the widget's Tools menu. For example, you could create a script which calculates a technical indicator and closes any trade based on the indicator value for its market.

(Note: scripts can also be assigned to the Order Menu context. This causes them to be displayed under the All/Filtered Orders and Selected Orders sub-menus of the Tools menu.)

The script receives the following information in its Framework.privateSettings about the current contents of the trade list:

9.3 Chart script context

Scripts which are assigned to the Chart context are displayed under a chart's settings menu.

The script receives the following information in its Framework.privateSettings about the current chart:

9.4 Order Menu script context

Scripts which are assigned to the Order Menu context are displayed in the following places within Sway Charts Pro:

· In the trade list widget, under the All/Filtered Orders and Selected Orders sub-menus of the Tools menu

· In the pop-up action menu for an individual order in the trade list grid

· In the pop-up action menu for an order from its marker on a trade chart

The script receives the following information in its Framework.privateSettings about the applicable orders. The orders[] array will contain a single ID if used from the action menu of a chart marker or individual entry in the trade list grid. The array may contain multiple orders if used from the Tools menu of the trade list.

Last updated