Skip to main content

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

BlockDescription
starting_balanceThe balance when the strategy started running
current_balanceThe current balance including unrealised P/L
available_balanceThe overall liquid balance available for trading
available_strategy_balanceThe portion of balance allocated to this strategy
set_available_strategy_balanceSet 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

BlockDescription
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

BlockDescription
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)

BlockDescription
stop_lossStop loss price set at position open
take_profitTake profit price set at position open
trailing_stopTrailing stop distance (lock in profits as price moves favorably)
trailing_limitTrailing limit distance (Margin only — pending entry that follows price)
limitLimit price for the entry order
time_in_forceOrder duration: GTC (default), IOC, or FOK
target_marketRoute the order to a different exchange/symbol/timeframe
name_orderAssign a custom name to the order for tracking
How SL/TP placement works in live mode

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

BlockDescription
comparisonCompare two values using operators: greater than, less than, equals, etc.
logical_andTrue only if both conditions are true
logical_orTrue if either condition is true
is_falseTrue if the condition is false (inverts a boolean)

Control

BlockDescription
execute_ifRun a set of blocks only if a condition is true
is_first_runBoolean — 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_strategyPause the strategy (stops executing but keeps state)
strategy_resumeResume a paused strategy
strategy_exitExit the strategy and close trades — choose All, only In Profit, or only In Loss
max_drawdownSet a maximum drawdown limit. When hit, either Pause or Exit the strategy automatically
schedule_actionSchedule blocks to run after a time interval. Can run Once or Repeat on a loop

Market Data

BlockDescription
current_priceThe current market price for a specified symbol
bid_priceThe current bid (best buy offer) price
ask_priceThe current ask (best sell offer) price
last_candle_valueA specific part of the last completed candle: Open, High, Low, or Close
consecutive_candles_colorBoolean — 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.
sourceDefine a data source by timeframe, exchange, and symbol — used as input to other blocks

Order Metrics

BlockDescription
order_volumeCumulative volume of filled or unfilled orders
filled_ordersCount of orders that have been completely filled
unfilled_ordersCount of orders still waiting to fill
order_statusCheck if an order is in a specific state: Filled, Unfilled, or Partial

Trade Metrics

BlockDescription
active_tradesNumber of currently open trades for this strategy
total_tradesTotal number of trades this strategy has executed
last_trade_detailsPrice, volume, or direction of the most recent trade
average_entry_priceAverage entry price across all open positions
unrealized_profit_lossTotal unrealised P/L across open positions
user_active_tradesActive trades across all of your strategies (not just this one)
get_sys_flagCheck if a system event fired: Stop Loss, Take Profit, Trailing Stop, or Liquidation
reset_sys_flagReset system trigger flags — individually or all at once
last_trigger_typeThe type of the last trigger event (stop loss, take profit, etc.)
last_trigger_symbolThe symbol that triggered the last event
last_trigger_priceThe price at which the last trigger fired
last_trigger_pnlThe realised P/L from the last trigger event
convert_assetConvert an amount from one asset to another at current prices

Time Metrics

BlockDescription
time_since_startHow long the strategy has been running, in Seconds, Minutes, or Hours

Values and Flags

BlockDescription
value_inputInput a numerical value (can be chained with other blocks)
set_variableStore a value in a named variable (number, string, or dynamic value)
get_variableRead the value of a named variable
set_flagSet a named flag to True or False
flag_is_setCheck if a named flag is True or False
notify_userSend a custom notification message to yourself

Margin Trading

Mode-specific read-only helpers. Actions (open, close, update, etc.) live under Trading.

BlockDescription
get_total_margin_usedTotal collateral locked across all margin positions

Futures Trading

Mode-specific read-only helpers. Actions live under Trading.

BlockDescription
get_futures_funding_rateCurrent funding rate for the symbol (periodic payment between longs and shorts)
get_futures_mark_priceCurrent mark price used for liquidation calculations

Math

BlockDescription
math_operationBasic arithmetic: add, subtract, multiply, divide
powerRaise a number to a power
moduloRemainder after division
sqrtSquare root
absAbsolute value
maxMaximum of a set of numbers
minMinimum of a set of numbers
factorialFactorial (n!)
logBase-10 logarithm
lnNatural logarithm
trigTrigonometric functions: sin, cos, tan
meanAverage of a set of numbers
medianMedian of a set of numbers
std_devStandard deviation
roundRound to a number of decimal places
floorRound down to nearest integer
ceilRound up to nearest integer
randomGenerate a random number within a range
clampConstrain a number between a minimum and maximum