Actions are elements tied to a user set condition producing a specific effect when the assigned condition is true.
Actions have the structure @keyword(), starting with @, with an identifier, and ().Some actions can have a condition assigned to them using =. 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. 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()

Arguments

qty (float): Optional. Number of contracts/lots/shares/units to close on exit for a long position. If the character % is present, the specified % of the long position is closed. If not provied the entire position is closed.

Examples

// Exit long position when price is below the price 14 bars ago
@exit_long() = {close} < {close[14]}
// Exit 50 contracts/lots/shares/units from the long position 
// when price is below the price 14 bars ago
@exit_long(50) = {close} < {close[14]}
// Exit 50% of the long position 
// when price is below the price 14 bars ago
@exit_long(50%) = {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()

Arguments

qty (float): Optional. Number of contracts/lots/shares/units to close on exit for a short position. If the character % is present, the specified % of the short position is closed. If not provied the entire position is closed.

Examples

// Exit short position when the high price is above previous low price
@exit_short() = {high} > {low[1]}
// Exit 50 contracts/lots/shares/units from the short position 
// when the high price is above previous low price
@exit_short(50) = {high} > {low[1]}
// Exit 50% of the short position 
// when the high price is above previous low price
@exit_short(50%) = {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 positions (long or short and scripted/unscripted) 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 scripted long and short positions, but also any other long/short condition you may have set.By default, the exit occurs at the next bar’s open unless “fill on bar close” is enabled in PROPERTIESFILL ORDERS.

@start_date

The @start_date action determines the starting date of the scripted strategy evaluation using a Datestring placeholder.

Syntax

@start_date({YYYY-MM-DDThh:mm:ss±hh:mm})

Arguments

datestring: Datestring placeholder, must comply with the ISO 8061 standard. The time and timezone are optional.

Examples

@long = {close} > {open}
@short = {close} < {open}

// Only evaluate the strategy starting 2025
@start_date({2025-01-01})

Remarks

The Timezone setting does not affect this placeholder. Default timezone for this placeholder is UTC-0.

@end_date

The @end_date action determines the starting date of the scripted strategy evaluation using a Datestring placeholder.

Syntax

@end_date({YYYY-MM-DDThh:mm:ss±hh:mm})

Arguments

datestring: Datestring placeholder, must comply with the ISO 8061 standard. The time and timezone are optional.

Examples

@long = {close} > {open}
@short = {close} < {open}

// Only evaluate the strategy prior to 2025
@end_date({2025-01-01})

Remarks

The Timezone setting does not affect this placeholder. Default timezone for this placeholder is UTC-0.

@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