> ## Documentation Index
> Fetch the complete documentation index at: https://docs.luxalgo.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Actions

**Actions** are elements tied to a user set condition producing a specific effect when the assigned condition is true.

<Info>
  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.
</Info>

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](/docs/toolkits/alert-scripting/actions-methods)

***

## @long

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

### Syntax

```js theme={null}
@long(limit, stop, alert_message)
```

### Arguments

**limit** (float): Optional. Limit price for the order. Accepts data placeholders as values. If specified, a limit order is created.

**stop** (float): Optional. Stop price for the order. Accepts data placeholders as values. If specified, a stop order is created.

<Note>
  If both `limit` and `stop` are specified, a stop-limit order is created.
</Note>

**alert\_message** (string): Optional. Alert message sent when the order is opened. Data placeholders can be used within the message, these will be replaced by their corresponding value when the alert triggers.

### Examples

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

```js theme={null}
// Go long with a limit order at the previous high
@long(limit = {high[1]}) = {close} > {open}
```

```js theme={null}
// Go long with a stop order at the previous low
@long(stop = {low[1]}) = {close} > {open}
```

```js theme={null}
// Go long with a stop-limit order
@long(limit = {high[1]}, stop = {low[1]}) = {close} > {open}
```

```js theme={null}
// Go long with an alert message containing the entry price
@long(alert_message = "Long entry at {close}") = {close} > {open}
```

### Remarks

<Note>
  By default a long 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.
</Note>

***

## @short

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

### Syntax

```js theme={null}
@short(limit, stop, alert_message)
```

### Arguments

**limit** (float): Optional. Limit price for the order. Accepts data placeholders as values. If specified, a limit order is created.

**stop** (float): Optional. Stop price for the order. Accepts data placeholders as values. If specified, a stop order is created.

<Note>
  If both `limit` and `stop` are specified, a stop-limit order is created.
</Note>

**alert\_message** (string): Optional. Alert message sent when the order is opened. Data placeholders can be used within the message, these will be replaced by their corresponding value when the alert triggers.

### Examples

```js theme={null}
// Go short when the price is lower than the opening price
@short() = {close} < {open}
```

```js theme={null}
// Go short with a limit order at the previous low
@short(limit = {low[1]}) = {close} < {open}
```

```js theme={null}
// Go short with a stop order at the previous high
@short(stop = {high[1]}) = {close} < {open}
```

```js theme={null}
// Go short with a stop-limit order
@short(limit = {low[1]}, stop = {high[1]}) = {close} < {open}
```

```js theme={null}
// Go short with an alert message containing the entry price
@short(alert_message = "Short entry at {close}") = {close} < {open}
```

### Remarks

<Note>
  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.
</Note>

***

## @exit\_long

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

### Syntax

```js theme={null}
@exit_long(qty, alert_message)
```

### 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.

**alert\_message** (string): Optional. Alert message sent when the order is closed. Data placeholders can be used within the message, these will be replaced by their corresponding value when the alert triggers.

### Examples

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

```js theme={null}
// 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]}
```

```js theme={null}
// Exit 50% of the long position 
// when price is below the price 14 bars ago
@exit_long(50%) = {close} < {close[14]}
```

```js theme={null}
// Exit long position with an alert message containing the exit price
@exit_long(alert_message = "Long exit at {close}") = {close} < {close[14]}
```

### Remarks

<Note>
  By default, a long position is exited at the opening of the next bar. You can enable "fill on bar close" from **PROPERTIES** → **FILL ORDERS** to trigger the exit at the bar close instead.
</Note>

***

## @exit\_short

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

### Syntax

```js theme={null}
@exit_short(qty, alert_message)
```

### 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.

**alert\_message** (string): Optional. Alert message sent when the order is closed. Data placeholders can be used within the message, these will be replaced by their corresponding value when the alert triggers.

### Examples

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

```js theme={null}
// 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]}
```

```js theme={null}
// Exit 50% of the short position 
// when the high price is above previous low price
@exit_short(50%) = {high} > {low[1]}
```

```js theme={null}
// Exit short position with an alert message containing the exit price
@exit_short(alert_message = "Short exit at {close}") = {high} > {low[1]}
```

### Remarks

<Note>
  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 **PROPERTIES** → **FILL ORDERS**.
</Note>

***

## @exit\_all

The `@exit_all` action closes **all open positions** (long or short and scripted/unscripted) when the associated condition is true.

### Syntax

```js theme={null}
@exit_all()
```

### Examples

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

### Remarks

<Note>
  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 **PROPERTIES** → **FILL ORDERS**.
</Note>

***

## @start\_date

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

### Syntax

```js theme={null}
@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

```js theme={null}
@long = {close} > {open}
@short = {close} < {open}

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

### Remarks

<Note>
  The **Timezone** setting does not affect this placeholder. Default timezone for this placeholder is UTC-0.
</Note>

***

## @end\_date

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

### Syntax

```js theme={null}
@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

```js theme={null}
@long = {close} > {open}
@short = {close} < {open}

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

### Remarks

<Note>
  The **Timezone** setting does not affect this placeholder. Default timezone for this placeholder is UTC-0.
</Note>

***

## @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

```js theme={null}
@only_scripted()
```

### Examples

```js theme={null}
// Only use the scripted strategy for the backtest
@only_scripted() = true
```
