Block Reference
A complete reference for every block available in the strategy builder. Blocks are organised into categories matching the toolbox sidebar in the editor.
Dynamic blocks
Three categories generate blocks dynamically based on what you've configured:
Indicators — A block appears for each indicator you've added (e.g. your "20-period RSI" becomes a block that outputs its current value). The block has a dropdown to select which output to read.
Signals — A block appears for each signal you've created. The dropdown lets you check if it's "triggered" or read its raw value.
Formations — A block appears for each formation you've drawn on the chart. The dropdown exposes properties like price levels depending on the formation type (line, channel, or Fibonacci).
Balances
| Block | Description |
|---|---|
| starting_balance | The balance when the strategy started running |
| current_balance | The current balance including unrealised P/L |
| available_balance | The overall liquid balance available for trading |
| available_strategy_balance | The portion of balance allocated to this strategy |
| set_available_strategy_balance | Set how much balance this strategy is allowed to use |
Trading
The unified trading blocks. One block set covers Spot, Margin, and Futures — the mode is selected once via Set Mode / Leverage and every subsequent trading block operates on that mode.
Mode and actions
| Block | Description |
|---|---|
Set Mode / Leverage (set_leverage) | Choose the active trading mode (Spot, Margin, or Futures) and default leverage. Place near the top of your strategy. Spot is the default; leverage is ignored for Spot. |
Open Position (open_position) | Open a Long or Short position in the active mode, with an amount in quote currency. Accepts an options chain (stop loss, take profit, trailing stop, limit, time in force, target market, name order). Short is rejected in Spot. |
Close Position (close_position) | Close the active-mode position. "All" closes everything; "Partial" closes the entered percent (1–99%). |
Update Stop Loss (set_position_stop_loss) | Update the stop-loss price on the current position (useful after averaging in). |
Update Take Profit (set_position_take_profit) | Update the take-profit price on the current position. |
Add Collateral (add_position_collateral) | Add collateral to the current Margin or Futures position to reduce liquidation risk. No-op in Spot. |
Position checks
| Block | Description |
|---|---|
Has Position (has_position) | True when there's an open position in the active mode. |
Position Unrealized PnL (get_position_pnl) | Unrealised profit/loss for the current position in quote currency. Returns 0 when flat. |
Liquidation Buffer (get_liquidation_buffer) | 0–100% distance from liquidation. 100 = safe, 0 = at liquidation. Only meaningful in Margin/Futures; returns 100 in Spot. |
Trade options (attach inside Open Position)
| Block | Description |
|---|---|
| stop_loss | Stop loss price set at position open |
| take_profit | Take profit price set at position open |
| trailing_stop | Trailing stop distance (lock in profits as price moves favorably) |
| trailing_limit | Trailing limit distance (Margin only — pending entry that follows price) |
| limit | Limit price for the entry order |
| time_in_force | Order duration: GTC (default), IOC, or FOK |
| target_market | Route the order to a different exchange/symbol/timeframe |
| name_order | Assign a custom name to the order for tracking |
When your strategy attaches a stop loss or take profit — either at position open or via an Update Stop Loss / Update Take Profit mid-position — BrighterTrading places it on the exchange itself when the exchange + mode combination supports native conditional orders. When it doesn't, the platform polls the price and fires the order from your strategy's runtime.
The practical difference: a native exchange-side SL/TP survives strategy pauses, restarts, and brief network drops. An in-process SL/TP only fires while the strategy is actually running, which means a paused or stopped strategy is no longer protected.
See the platform's feature support matrix in your installation for which cells (exchange × mode) currently use native vs in-process protection.
Logical
| Block | Description |
|---|---|
| comparison | Compare two values using operators: greater than, less than, equals, etc. |
| logical_and | True only if both conditions are true |
| logical_or | True if either condition is true |
| is_false | True if the condition is false (inverts a boolean) |
Control
| Block | Description |
|---|---|
| execute_if | Run a set of blocks only if a condition is true |
| is_first_run | Boolean — true only during the strategy's first execution tick. Plug into an execute_if condition to do one-time setup (set leverage, initialise variables) without writing the flag-based "setup" pattern by hand. |
| pause_strategy | Pause the strategy (stops executing but keeps state) |
| strategy_resume | Resume a paused strategy |
| strategy_exit | Exit the strategy and close trades — choose All, only In Profit, or only In Loss |
| max_drawdown | Set a maximum drawdown limit. When hit, either Pause or Exit the strategy automatically |
| schedule_action | Schedule blocks to run after a time interval. Can run Once or Repeat on a loop |
Market Data
| Block | Description |
|---|---|
| current_price | The current market price for a specified symbol |
| bid_price | The current bid (best buy offer) price |
| ask_price | The current ask (best sell offer) price |
| last_candle_value | A specific part of the last completed candle: Open, High, Low, or Close |
| consecutive_candles_color | Boolean — true when the last N candles are all the same colour (Green or Red). Useful for streak-based entry conditions. Any doji or opposite-colour candle in the window breaks the streak. |
| source | Define a data source by timeframe, exchange, and symbol — used as input to other blocks |
Order Metrics
| Block | Description |
|---|---|
| order_volume | Cumulative volume of filled or unfilled orders |
| filled_orders | Count of orders that have been completely filled |
| unfilled_orders | Count of orders still waiting to fill |
| order_status | Check if an order is in a specific state: Filled, Unfilled, or Partial |
Trade Metrics
| Block | Description |
|---|---|
| active_trades | Number of currently open trades for this strategy |
| total_trades | Total number of trades this strategy has executed |
| last_trade_details | Price, volume, or direction of the most recent trade |
| average_entry_price | Average entry price across all open positions |
| unrealized_profit_loss | Total unrealised P/L across open positions |
| user_active_trades | Active trades across all of your strategies (not just this one) |
| get_sys_flag | Check if a system event fired: Stop Loss, Take Profit, Trailing Stop, or Liquidation |
| reset_sys_flag | Reset system trigger flags — individually or all at once |
| last_trigger_type | The type of the last trigger event (stop loss, take profit, etc.) |
| last_trigger_symbol | The symbol that triggered the last event |
| last_trigger_price | The price at which the last trigger fired |
| last_trigger_pnl | The realised P/L from the last trigger event |
| convert_asset | Convert an amount from one asset to another at current prices |
Time Metrics
| Block | Description |
|---|---|
| time_since_start | How long the strategy has been running, in Seconds, Minutes, or Hours |
Values and Flags
| Block | Description |
|---|---|
| value_input | Input a numerical value (can be chained with other blocks) |
| set_variable | Store a value in a named variable (number, string, or dynamic value) |
| get_variable | Read the value of a named variable |
| set_flag | Set a named flag to True or False |
| flag_is_set | Check if a named flag is True or False |
| notify_user | Send a custom notification message to yourself |
Margin Trading
Mode-specific read-only helpers. Actions (open, close, update, etc.) live under Trading.
| Block | Description |
|---|---|
| get_total_margin_used | Total collateral locked across all margin positions |
Futures Trading
Mode-specific read-only helpers. Actions live under Trading.
| Block | Description |
|---|---|
| get_futures_funding_rate | Current funding rate for the symbol (periodic payment between longs and shorts) |
| get_futures_mark_price | Current mark price used for liquidation calculations |
Math
| Block | Description |
|---|---|
| math_operation | Basic arithmetic: add, subtract, multiply, divide |
| power | Raise a number to a power |
| modulo | Remainder after division |
| sqrt | Square root |
| abs | Absolute value |
| max | Maximum of a set of numbers |
| min | Minimum of a set of numbers |
| factorial | Factorial (n!) |
| log | Base-10 logarithm |
| ln | Natural logarithm |
| trig | Trigonometric functions: sin, cos, tan |
| mean | Average of a set of numbers |
| median | Median of a set of numbers |
| std_dev | Standard deviation |
| round | Round to a number of decimal places |
| floor | Round down to nearest integer |
| ceil | Round up to nearest integer |
| random | Generate a random number within a range |
| clamp | Constrain a number between a minimum and maximum |