> For the complete documentation index, see [llms.txt](https://algoalpha.gitbook.io/algoalpha-user-manual/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://algoalpha.gitbook.io/algoalpha-user-manual/premium-indicators/backtest-strategy-builder/text-scripting-rules.md).

# Text Scripting Rules

Text scripting rules are the plain-text strategy blocks that Atlas can copy into the **Backtest - Strategy Builder**. They are designed for copy-paste strategy import, not full programming.

Use this page when you want to understand exactly what the Strategy Builder accepts in the **Add Atlas Rules Below** text box.

***

### Basic Format

A rule block is made from sections. Each section has a header, then a `Trigger:` line, and optionally a `States:` line.

```
Long Entry:
Trigger: Smart Signals +▲/▲ Fires (SSA)
States: Trend Bias Is Bullish (SSA), TRC Is Trending (SSA)

Short Entry:
Trigger: Smart Signals +▼/▼ Fires (SSA)
States: Trend Bias Is Bearish (SSA), TRC Is Trending (SSA)
```

A section fires when:

```
Trigger is true AND every listed State is true
```

`Trigger:` accepts one signal. `States:` accepts comma-separated signals.

***

### Supported Sections

| Section           | Purpose                                                  |
| ----------------- | -------------------------------------------------------- |
| `Long Entry:`     | Opens a long position when its trigger and states pass.  |
| `Short Entry:`    | Opens a short position when its trigger and states pass. |
| `Exit Condition:` | Exits either side when its trigger and states pass.      |
| `Exit Long:`      | Exits long positions.                                    |
| `Long Exit:`      | Alias for `Exit Long:`.                                  |
| `Exit Short:`     | Exits short positions.                                   |
| `Short Exit:`     | Alias for `Exit Short:`.                                 |

If both `Long Entry:` and `Short Entry:` are present but no exit section is supplied, the Strategy Builder uses the opposing entry as the exit. A short entry exits an open long, and a long entry exits an open short.

***

### Trigger

`Trigger:` is the event that starts the section.

Valid:

```
Trigger: Smart Signals +▲/▲ Fires (SSA)
```

Also valid:

```
Trigger: External Signal 1
```

Not supported:

```
Trigger: Smart Signals +▲/▲ Fires (SSA), TRC Trending (SSA)
Trigger: A AND B
Trigger: A OR B
```

Only one trigger signal is accepted. If you need extra requirements, put them in `States:`.

***

### States

`States:` is a comma-separated list of conditions that must already be true when the trigger fires.

```
States: Trend Bias Is Bullish (SSA), TRC Is Trending (SSA), Price Above All Clouds (SSA)
```

This means:

```
Trend Bias Is Bullish
AND TRC Is Trending
AND Price Above All Clouds
```

Use commas, not written `AND`.

Not supported:

```
States: A AND B
States: A OR B
States: A, B OR C
States: A, NOT B
States: (A OR B), C
```

If `States:` is missing or blank, it is treated as true. That makes trigger-only rules valid.

***

### External Signals

Text rules can reference the Strategy Builder's six external signal slots:

```
External Signal 1
External Signal 2
External Signal 3
External Signal 4
External Signal 5
External Signal 6
```

They work in both `Trigger:` and `States:`.

Example:

```
Long Entry:
Trigger: External Signal 1
States: Trend Bias Is Bullish (SSA), External Signal 2
```

External signals use the settings from **Condition Setup**:

| Slot                | What it uses                       |
| ------------------- | ---------------------------------- |
| External Signal 1-3 | Source compared to another source. |
| External Signal 4-6 | Source compared to a fixed number. |

Operators include greater than, lesser than, equal to, not equal to, crossover, crossunder, cross, rising, and falling.

***

### Supported Signal Families

Text rules can use signal names from:

* Smart Signals Assistant (SSA)
* Institutional Liquidity and Price Action Concepts (ILPAC)
* Momentum Concepts (MC)
* External Signal 1-6

The parser ignores these suffixes when matching names:

```
(SSA)
(ILPAC)
(MC)
(Momentum Concepts)
[Trigger]
[State]
```

So these are equivalent:

```
Trigger: TRC Is Trending (SSA)
Trigger: TRC Is Trending
Trigger: TRC Is Trending [State] (SSA)
```

Signal names are case-insensitive.

***

### Parser Warnings

The Strategy Table includes an **Atlas Rules** row. It warns when the pasted text contains:

* unknown sections
* ignored fields
* missing triggers
* unknown trigger names
* unknown state names
* empty state items

Unknown signals evaluate as false. If a strategy is not trading after you paste rules, check the **Atlas Rules** row first.

***

### Examples

#### Trigger-only entries

```
Long Entry:
Trigger: Smart Signals ▲ Fires (SSA)

Short Entry:
Trigger: Smart Signals ▼ Fires (SSA)
```

#### Entries with state filters

```
Long Entry:
Trigger: Smart Signals +▲/▲ Fires (SSA)
States: Trend Bias Is Bullish (SSA), TRC Is Trending (SSA)

Short Entry:
Trigger: Smart Signals +▼/▼ Fires (SSA)
States: Trend Bias Is Bearish (SSA), TRC Is Trending (SSA)
```

#### External signal mixed with built-in states

```
Long Entry:
Trigger: External Signal 1
States: TRC Is Trending (SSA), Hidden Liquidity Flow Greater Than Zero (MC)

Exit Long:
Trigger: Smart Exits Long (SSA)
```

#### Shared exit condition

```
Exit Condition:
Trigger: Smart Exits Any (SSA)
```

***

### Current Limitations

Text scripting rules do not support:

* written `AND`
* `OR`
* `NOT`
* parentheses
* nested logic
* multiple triggers in one section
* direct numeric expressions like `RSI > 50`
* manual multi-step sequencing
* manual invalidation settings

For those workflows, switch off **Use Atlas** and use Manual Mode.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://algoalpha.gitbook.io/algoalpha-user-manual/premium-indicators/backtest-strategy-builder/text-scripting-rules.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
