Managing Actions
Actions define what your strategy does when a transition fires — update a variable, execute a trade, or run conditional logic. Each action is a sequence of one or more steps that execute in order.
Opening the Actions Manager
- In SMITH, click the gear icon to open the Strategy Toolbar.
- Select Manage Actions.
The Actions Manager panel lists all actions in your strategy, with step summaries and usage counts.
Creating an Action
- Click New Action (or Create Action if none exist yet).
- Name the action (e.g.,
Enter_Long,Increment_Counter,Log_Exit). - Add one or more steps to define what the action does.
Action Step Types
Each step in an action is one of these types:
Operation
A direct operation on your strategy's context. Sub-types:
| Operation | What It Does |
|---|---|
| Assign | Set a variable to a specific value |
| Increment | Add a value to a numeric variable |
| Decrement | Subtract a value from a numeric variable |
| Swap | Exchange the values of two variables |
| Custom | A custom operation expression |
Values can come from three sources:
- Static — a fixed number, string, or boolean
- Context — a value from one of your strategy's variables
- Event — a value from the incoming market event payload
Predefined
Built-in actions with specialized behavior:
| Action | What It Does |
|---|---|
| Execute Trade | Records a trade execution with direction, entry price, stop-loss, and take-profit levels. |
Execute Trade works like any other action step — it runs when the transition fires (or when a conditional branch triggers it). If you want to be notified when a trade executes, you can configure an alert that triggers on the Execute Trade action.
Execute Trade in Detail
Execute Trade is the primary way strategies produce trade signals. When it fires, it captures the current market price as the entry, determines direction from your strategy context, and calculates stop-loss (SL) and take-profit (TP) levels.
Quick Primer: Pip Size, Stop Loss, and Take Profit
A pip is the smallest standard price increment for an instrument. Pip size is the numeric value of one pip — for most forex pairs like EUR/USD it's 0.0001, while for JPY pairs it's 0.01. You set pip size in your strategy's context variables so FORJ knows how to translate pip distances into actual price offsets.
Stop loss (SL) is the price level where a losing trade is closed to limit risk. Take profit (TP) is the price level where a winning trade is closed to lock in gains. Together, they define the exit boundaries of a trade.
FORJ calculates SL and TP prices by combining the entry price, your pip-based distances, the pip size, and the trade direction:
| Direction | Stop Loss | Take Profit |
|---|---|---|
| Bullish | entry − (sl_pips × pip_size) | entry + (tp_pips × pip_size) |
| Bearish | entry + (sl_pips × pip_size) | entry − (tp_pips × pip_size) |
Context Defaults
By default, Execute Trade reads these values from your strategy context:
| Context Variable | Default | Role |
|---|---|---|
direction | 'bullish' | Determines which side of entry the SL and TP are placed |
sl_pips | 30 | Distance from entry to stop loss, measured in pips |
tp_pips | 100 | Distance from entry to take profit, measured in pips |
pip_size | — | Value of one pip in price units (e.g., 0.0001) |
The entry price is always the close price of the incoming candle event.
With no overrides configured, every Execute Trade step uses these context values directly. This means you can change trading behavior at runtime — for example, an earlier action step could update sl_pips from 30 to 50 before Execute Trade fires, tightening or widening the stop dynamically.
Overriding SL and TP
For more control, you can override the stop loss, the take profit, or both. Each side has an "Override Stop Loss (SL)" and "Override Take Profit (TP)" toggle in the configuration.
When you enable an override, you choose a mode:
Absolute Price — You specify the exact SL or TP price using an operand. The operand source can be:
- Static — a literal number (e.g.,
1.0850) - Context — a variable from your strategy context
- Event — a field from the incoming event payload (e.g., the candle low)
- Indicators — an indicator output value
After resolving the operand, you can apply an optional modifier (add, subtract, multiply, divide) to fine-tune the price.
Risk-Reward Ratio — Instead of specifying a price, you set a ratio relative to the other side. For example, if your SL is set to an absolute price and your TP uses a 2:1 R:R ratio, FORJ calculates the TP as twice the distance from entry to SL, placed on the profit side. Only one side can use R:R mode at a time — the other must be absolute or use the pip-based default as the anchor.
What Execute Trade Produces
When Execute Trade fires, it emits a trade record containing:
| Field | Description |
|---|---|
| Entry price | The close price of the candle that triggered the action |
| Direction | Bullish or bearish, from context |
| SL price | The resolved stop-loss price (after overrides and modifiers) |
| TP price | The resolved take-profit price (after overrides and modifiers) |
| Timestamp | When the trade was recorded |
| Symbol | The instrument, from context |
These values are persisted as a Trade Execution record and appear in the Hearth timeline. The strategy context is also updated: trade_was_executed_on_last_state_change is set to true and last_trade_executed records the timestamp, so subsequent transitions can react to whether a trade just occurred.
Designing Different Entry and Exit Strategies
Because each Execute Trade step can have its own override configuration, you can define multiple actions with different SL/TP setups for different scenarios:
- Tight scalp entry: An action with a small absolute SL (e.g., 10 pips below the candle low) and a 2:1 R:R take profit.
- Wide swing entry: An action using the default context values of
sl_pips: 100andtp_pips: 300. - Indicator-based exit: An action where the TP is overridden with an indicator value (e.g., an upper Bollinger Band), and the SL is a fixed offset below the entry.
Combine these with conditional steps to select the right trade configuration based on market conditions at the time the transition fires.
Conditional
An if/then/else branching step. You define a set of conditions (using the same All (AND) and Any (OR) groups as guards), and then specify:
- True branch — steps that execute when the conditions pass.
- False branch — steps that execute when the conditions fail.
Both branches can contain any step type, including nested conditional steps for complex decision trees.
Example: "If tradeCount < 3, increment tradeCount and execute a trade; otherwise, do nothing."
Conditional action steps give you guard-like logic inside an action, so you can branch behavior without creating separate transitions. See Conditions — Conditions in Conditional Actions for details on how conditions work in this context.
Do Nothing
A no-op step — nothing happens, context is unchanged. Useful as a placeholder or for clarity in conditional branches.
Editing and Deleting Actions
- Edit: Click an action to expand it, then click Edit to modify its steps
- Delete: Click Delete to remove an action. If it's referenced by transitions, SMITH shows which transitions will be affected
Usage Counts
Each action shows a usage count — the number of transitions that reference it. This helps identify unused actions and understand the impact of edits.