Actions are elements tied to a user set condition producing a specific effect when the assigned condition is true.
Actions always have the structure @keyword() = ..., starting with @, with an identifier, and ().= will assign to the action a condition. When the assigned condition is true the action will trigger.
Like functions in classical programming languages, actions can have arguments located within (), adding further degrees of control over the action.
All actions arguments are optional.
Actions used for scripted alerts are also available for scripted strategies, however, this page only lists the actions that are exclusively used for scripted strategies. To see a list of other actions, see scripted alerts actions

@long

The @long action allows entering a long position when the associated condition is true.

Syntax

@long()

Examples

// Go long when the price is greater than the opening price
@long() = {close} > {open}

Remarks

By default a long position is entered at the opening of the next bar. Using “fill on bar close” from the settings in PROPERTIESFILL ORDERS will open a position at the close of the bar the condition is true.

@short

The @short action allows entering a short position when the associated condition is true.

Syntax

@short()

Examples

// Go long when the price is lower than the opening price
@short() = {close} < {open}

Remarks

By default a short position is entered at the opening of the next bar. Using “fill on bar close” from the settings in PROPERTIES -> FILL ORDERS will open a position at the close of the bar the condition is true.

@exit_long

The @exit_long action closes all open long positions when the associated condition is true.

Syntax

@exit_long()

Examples

// Exit long position when price is below the price 14 bars ago
@exit_long() = {close} < {close[14]}

Remarks

By default, a long position is exited at the opening of the next bar. You can enable “fill on bar close” from PROPERTIESFILL ORDERS to trigger the exit at the bar close instead.

@exit_short

The @exit_short action closes all open short positions when the associated condition is true.

Syntax

@exit_short()

Examples

// Exit short position when high price is above previous low price
@exit_short() = {high} > {low[1]}

Remarks

By default, a short position is exited at the opening of the next bar. To exit at the close of the bar where the condition is true, enable “fill on bar close” from PROPERTIESFILL ORDERS.

@exit_all

The @exit_all action closes all open position (long or short) when the associated condition is true.

Syntax

@exit_all()

Examples

// Exit all positions when the closing price is above the previous high price
@exit_all() = {close} > {high[1]}

Remarks

This exits both long and short positions. By default, the exit occurs at the next bar’s open unless “fill on bar close” is enabled in PROPERTIESFILL ORDERS.

@only_scripted

The @only_scripted action determines if only scripted entries/exits should be considered during the backtest. If true it will ignore any other entry condition set in the other Backtester settings.

Syntax

@only_scripted()

Examples

// Only use the scripted strategy for the backtest
@only_scripted() = true