Risk notice: Blueprint nodes can generate automated trading actions, but a node combination does not guarantee profit. Before live trading, backtest first, then validate with paper trading or small size. Do not enable withdrawal permission on exchange API keys.
1. How Blueprints Work
A blueprint is an event-driven strategy flowchart. An executable blueprint usually contains these node groups:
- Event nodes: Decide when the strategy runs, such as startup, each candle, each Tick, a timer, or an order receipt.
- Market nodes: Read the current mounted symbol, candles, latest price, order book, account, and position.
- Indicator nodes: Calculate technical indicators from candles or numeric series.
- Signal/logic nodes: Convert indicators and prices into boolean conditions for entry, exit, or chart output.
- Risk nodes: Add rate limits, kill switches, minimum quantity checks, maximum position limits, cooldowns, stop loss, and take profit rules.
- Order/function nodes: Generate entry, exit, close, cancel, and strategy exit rule actions.
- State nodes: Store variables, maintain counters, persist state, and detect signal changes.
- Tool nodes: Run expressions, cast types, calculate arithmetic, normalize values, and round precision.
- Chart nodes: Display indicator lines, horizontal lines, backgrounds, markers, tables, and order markers on the chart.
A typical strategy chain looks like this:
OnBar / OnBarClose
-> Symbol Selector
-> Get OHLCV
-> Indicator nodes
-> Signal/logic nodes
-> Risk nodes
-> strategy.entry / strategy.close / order nodesIf the execution timeframe is 15m but the market filter uses 1h data, configure it like this:
event.on_bar(timeframe=15m)
-> market.symbol_selector
-> market.get_ohlcv(timeframe=1h, limit=200)
-> 1h indicators and filters
-> 15m execution chain2. Ports, Connections, and Parameters
Each node consists of input ports, output ports, and parameters.
Flow Types
Value Types
Compile and Connection Rules
- A blueprint must contain at least one event source node, otherwise it will not run.
- Data flow must be acyclic. If data nodes form a loop, compilation fails.
- If event flow forms a loop, add
logic.gatefor throttling, otherwise high-frequency repeated triggers may occur. - Data port types must match. If types do not match, insert
tool.cast_number,tool.cast_integer, ortool.cast_bool. - A normal input port allows only one connection. Ports that support multiple connections are marked in the node definition.
- Order nodes must connect
eventIn; without an event trigger, they will not execute. - When a blueprint contains order nodes, connect at least one risk node to
riskInputs. The compiler may warn that order nodes exist without risk nodes or that order nodes have no risk input. market.symbol_selectoroutputs the symbol from the current backtest, mount, or debug context. It is suitable for reusable blueprint templates, and avoids hardcoding a symbol in the template.market.get_ohlcvwithtimeframe=runtimefollows the runtime timeframe. For higher-timeframe filters, explicitly select1h,15m, or another timeframe.
3. High-Frequency Strategy Guidelines
High-frequency or high-turnover strategies should control trigger frequency and order frequency first:
- Prefer
event.on_barorevent.on_bar_closeas the main trigger. Useevent.on_tickonly when Tick-level reaction is explicitly required. - If you use
event.on_tickor a shortevent.on_timer, add one or more oflogic.gate,risk.max_order_rate, andlogic.once_per_bardownstream. - If you do not want repeated entries on the same candle, use
logic.once_per_barorstate.last_signal. - Avoid repeatedly requesting a large candle count at Tick level. Set
market.get_ohlcv.limitbased on indicator needs; 100-300 is usually enough. - Execution timeframe and decision timeframe can be separated. For example: 15m execution with 1h filtering means the event node uses
15m, while the market node uses1h. - For live trading chains, keep
risk.kill_switch,risk.order_validation,risk.max_position_size, andrisk.max_order_rateconnected by default. - For strategies that pause after losses, add
risk.cooldown_after_lossorrisk.daily_consecutive_loss_cooldown.
4. Event Nodes
Event nodes are blueprint execution entry points. Without an event node, market, indicator, logic, and order nodes will not form runtime frames.
5. Market Nodes
Market nodes read symbol, candles, prices, account, and position data from the current runtime context.
6. Indicator Nodes
Most indicator nodes receive ohlcvSeries and output the current bar value. For multi-timeframe filters, set Get OHLCV.timeframe to the target timeframe.
7. Signal and Logic Nodes
Signal nodes usually output booleans. Logic nodes combine conditions or control event flow.
Expression node notes:
bool.expression,math.expression, andtool.number_exprsupport dynamic variable counts.variableCountranges from 1 to 32.- Variables default to
a/b/c...; use aliases such asclose,emaFast, oratrto make expressions readable. - Boolean expressions are suitable for `close > ema and rsi order node riskInputs
## 9. Function Nodes and Order Nodes
Function nodes are Pine Script-style trading functions. They output `eventOut`, `triggered`, and `label`, which makes them suitable for chaining. Order nodes are terminal action nodes and are usually placed at the end of the trading chain.
### Function Nodes
| Node ID | Name | Main inputs | Main outputs | Key parameters | Purpose and notes |
| ----------------------- | ------------------- | --------------------------------------- | ---------------------------- | ------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| `strategy.entry` | strategy.entry | `eventIn/when/symbol/riskInputs/plot` | `eventOut/triggered/label` | `enabled`, `entryId`, `direction`, `orderType`, `qtyMode`, `qty`, `limitOffsetPct`, `comment` | Generates long or short entry intent when `when` is true. `entryId` is a strategy tag, not an exchange order ID. |
| `strategy.cancel` | strategy.cancel | `eventIn/when/riskInputs/plot` | `eventOut/triggered/label` | `enabled`, `orderId`, `comment` | Cancels a specified exchange order. Live cancellation usually requires the real `orderId`. |
| `strategy.close` | strategy.close | `eventIn/when/symbol/riskInputs/plot` | `eventOut/triggered/label` | `enabled`, `entryId`, `orderType`, `qtyMode`, `qty`, `limitOffsetPct`, `comment` | Closes the current symbol position by all, quantity, or percent. |
| `strategy.cancel_all` | strategy.cancel_all | `eventIn/when/riskInputs/plot` | `eventOut/triggered/label` | `enabled`, `comment` | Generates cancel-all intent when the condition is true. |
| `strategy.close_all` | strategy.close_all | `eventIn/when/symbol/riskInputs/plot` | `eventOut/triggered/label` | `enabled`, `orderType`, `limitOffsetPct`, `comment` | Closes all positions for the current symbol when the condition is true. |
| `strategy.exit` | strategy.exit | `eventIn/when/symbol/riskInputs/plot` | `eventOut/triggered/label` | `exitId`, `fromEntry`, `stop`, `limit`, `profit`, `loss`, `trailPoints`, `trailOffset` | Pine-style exit rule with stop loss, take profit, and trailing stop settings. |
### Order Nodes
| Node ID | Name | Main inputs | Output | Key parameters | Purpose and notes |
| ------------------------ | -------------------- | --------------------------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| `strategy.entry_block` | Strategy Entry Block | `eventIn/longCondition/shortCondition/symbol/riskInputs/plot` | None | `orderType`, `qtyMode`, `qty`, `preferLongWhenBoth`, `longLabel`, `shortLabel` | Strategy-level entry block that accepts both long and short conditions. If both trigger, the preferred side can be configured. |
| `strategy.exit_block` | Strategy Exit Block | `eventIn/longCondition/shortCondition/symbol/riskInputs/plot` | None | `orderType`, `qtyMode`, `qty`, `longLabel`, `shortLabel` | Strategy-level exit block that generates close intents directly from long/short exit conditions. |
| `order.place_market` | Place Market Order | `eventIn/sideInput/riskInputs/plot` | None | `side=buy/sell/auto`, `qtyMode=fixed/percent/quantity`, `qty` | Generates market order intent.`qty` is currently interpreted as USDT amount; `percent` uses a percent of available funds. |
| `order.place_limit` | Place Limit Order | `eventIn/sideInput/riskInputs/plot` | None | `side`, `qtyMode`, `qty`, `priceOffsetPct` | Generates limit order intent. BUY offsets downward, SELL offsets upward. |
| `order.cancel_order` | Cancel Order | `eventIn/riskInputs/plot` | None | `orderId` | Cancels a specified exchange order. |
| `order.close_position` | Close Position | `eventIn/riskInputs/plot` | None | `qtyMode=all/quantity/percent`, `qty`, `orderType`, `priceOffsetPct`, `reduceOnly=true` | Closes the current position. Defaults to reduce-only. |
| `order.set_tpsl` | Set TP/SL | `eventIn/riskInputs/plot` | None | `stopLossPct=1.0`, `takeProfitPct=2.0` | Sets take profit and stop loss intent for a position or order. |
Order chain example:OnBarClose(15m).out
-> Edge Trigger.eventIn
Compare.result
-> Edge Trigger.condition
Edge Trigger.eventOut
-> strategy.entry.eventIn
Symbol Selector.symbol
-> strategy.entry.symbol
risk.max_order_rate.intent
risk.max_position_size.intent
risk.stop_take_rule.intent
-> strategy.entry.riskInputs
## 10. State Nodes
State nodes remember variables and signals during runtime. Use `persistent_*` when the value must survive restarts.
| Node ID | Name | Main inputs | Main outputs | Parameters | Purpose and notes |
| ------------------------ | ----------------- | ----------------------- | ---------------------------------- | --------------------------------- | ----------------------------------------------------------------------------------------------- |
| `state.var_set` | Var Set | `value` | `value` | `key=signal` | Sets a strategy variable, usually scoped to the runtime instance. |
| `state.var_get` | Var Get | None | `value` | `key=signal` | Reads a strategy variable. |
| `state.counter` | Counter | `eventIn` | `value/eventOut` | `initialValue=0`, `step=1` | Counts each event trigger. Useful for trigger statistics. |
| `state.persistent_set` | Persistent KV Set | `eventIn/value` | `value/eventOut` | `key=last_signal` | Writes a cross-restart persistent variable. |
| `state.persistent_get` | Persistent KV Get | None | `value` | `key=last_signal`, `fallback` | Reads a persistent variable. Returns fallback when the key does not exist. |
| `state.rolling_window` | Rolling Window | `eventIn/value` | `values/latest/count/eventOut` | `size=20` | Maintains a rolling window of the latest N numeric values. |
| `state.last_signal` | Last Signal | `eventIn/signal` | `signal/changed/eventOut` | `key=signal` | Stores the previous signal and outputs whether it changed. Useful for avoiding repeated orders. |
| `state.overbought` | Overbought State | `value/threshold` | `result` | `threshold=70` | Indicator value is greater than or equal to the threshold. |
| `state.oversold` | Oversold State | `value/threshold` | `result` | `threshold=30` | Indicator value is less than or equal to the threshold. |
| `state.midline` | Midline State | `value/threshold` | `result` | `threshold=50` | Indicator value is greater than or equal to the midline threshold. |
| `strategy.trend_state` | Trend State | `changeUp/changeDown` | `state/stateCode/isLong/isShort` | `longCode=B`, `shortCode=S` | Also a state node; maintains trend state from switch signals. |
## 11. Tool Nodes
Tool nodes handle intermediate calculation and formatting. Prefer expression nodes for complex calculations and arithmetic nodes for simple operations.
| Node ID | Name | Main inputs | Main outputs | Parameters | Purpose and notes |
| --------------------- | --------------- | ----------------------- | ------------- | --------------------------------------------------- | ---------------------------------------------------------------------------- |
| `math.expression` | Math Expression | Dynamic variable inputs | `value` | `expression`, `variableCount`, variable aliases | Numeric expression supporting `+ - * / %` and parentheses. |
| `tool.number_expr` | Number Expr | Dynamic variable inputs | `value` | `expression`, `variableCount`, variable aliases | Legacy numeric expression node, useful for replacing Add/Sub/Mul/Div chains. |
| `tool.cast_number` | Cast -> Number | `value` | `value` | None | Explicitly casts to number. |
| `tool.cast_integer` | Cast -> Int | `value` | `value` | None | Explicitly casts to integer. |
| `tool.cast_bool` | Cast -> Bool | `value` | `value` | None | Explicitly casts to boolean. |
| `tool.clamp` | Clamp | `value` | `value` | `min=0`, `max=100` | Restricts a value to a range. |
| `tool.normalize` | Normalize | `value` | `value` | `min=0`, `max=100` | Normalizes a value to 0-1. |
| `tool.add` | Add | `a/b` | `value` | None | Addition. |
| `tool.sub` | Sub | `a/b` | `value` | None | Subtraction. |
| `tool.mul` | Mul | `a/b` | `value` | None | Multiplication. |
| `tool.div` | Div | `a/b` | `value` | None | Division. |
| `tool.map_symbol` | Map Symbol | `symbol` | `symbol` | `exchange=binance/okx/bybit` | Maps a symbol to the target exchange format. |
| `tool.tag` | JSON/Tag | `value` | `value/tag` | `tag` | Adds a text tag or JSON fragment to data. |
| `tool.round` | Round/Precision | `value` | `value` | `precision=2` | Handles numeric precision for prices, quantities, and chart display. |
## 12. Chart Nodes
Chart nodes visualize the strategy. Some nodes receive `eventIn` to control whether the current bar is drawn; others are purely data-driven. Chart nodes usually do not participate in order decisions and are best used as side outputs.
### Common Chart Parameters
| Parameter | Description |
| --------------- | ------------------------------------------------------------------------------------------------------------------- |
| `pane` | Display area:`main` main chart, `chart` chart layer, `volume` volume pane, `indicator:0/1` indicator panes. |
| `visible` | Whether to display. |
| `zIndex` | Layer order, from -200 to 200. Higher values render above lower values. |
| `layer` | Render layer:`background`, `underlay`, `overlay`, `annotation`. |
| `style` | Plot style:`line`, `linebr`, `stepline`, `area`, `histogram`, `columns`, `circles`, `cross`. |
| `strokeStyle` | Line style:`solid`, `dashed`, `dotted`. |
### Chart Node Index
| Node ID | Name | Main inputs | Main outputs | Key parameters | Purpose and notes |
| ---------------------------- | --------------- | ------------------------------------------------------- | ------------ | ------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------- |
| `chart.color` | Color | None | `color` | `color=#FF38BDF8` | Outputs color text for reuse by multiple chart nodes. |
| `chart.background` | Background | `eventIn/color/startValue/endValue/startTime/endTime` | None | `color`, `rangeMode=bars/time`, `startBarsAgo/endBarsAgo` | Draws a background region by candle range or time range. |
| `chart.bar_color` | Bar Color | `eventIn` | None | `colorMode=single/trend/theme`, body/wick/border/up/down colors | Changes candle colors, useful for visualizing trend state. |
| `chart.plots` | Plot | `color/value` | `plotRef` | `style`, `color`, `lineWidth`, `histBase`, `offset`, `showLast`, `trackPrice` | Draws indicator lines, columns, areas, and more. Outputs a Plot reference. |
| `strategy.plot_trend_line` | Plot Trend Line | `value/trend` | `plotRef` | `style`, `upColor`, `downColor`, `neutralColor`, `lineWidth` | Indicator line that changes color by trend state. |
| `chart.fill` | Fill | `color/plot1/plot2` | None | `color`, `showLast`, `fillGaps` | Fills the area between two Plot/HLine references. Both references must be in the same pane. |
| `chart.hline` | HLine | `price/color/startValue/endValue/startTime/endTime` | `hlineRef` | `price`, `title`, `color`, `linestyle`, `linewidth`, `rangeMode` | Draws a horizontal line and can be used as a Fill reference. |
| `chart.levels` | Levels | `value/color` | None | `value`, `color`, `lineWidth`, `strokeStyle`, `label`, range parameters | Draws price level lines for support, resistance, TP/SL references. |
| `chart.line` | Line | `startValue/endValue` | None | `lineColor`, `lineWidth`, `strokeStyle`, `leftBarsAgo/rightBarsAgo` | Draws a segment from a historical bar to current or future offset. |
| `chart.box` | Box | `top/bottom/text` | None | `fillColor`, `borderColor`, `textColor`, `borderWidth`, `leftBarsAgo/rightBarsAgo` | Draws a price range box for consolidation zones or supply/demand zones. |
| `chart.tables` | Tables | `eventIn` and dynamic `value1...valueN` | None | `title`, `placement`, `itemCount=1-12`, `labelPosition`, `columnCount`, colors and alignment | Displays a chart dashboard.`itemCount` dynamically expands value inputs and label parameters. |
| `chart.text` | Text | `value` | `text` | `color`, `textFallback`, `size`, `barsAgo` | Outputs text. When a value is connected, it concatenates “text + value”. |
| `chart.shapes` | Shapes | `value/series/text` | `shape` | `shape`, `location=abovebar/belowbar/absolute`, colors, size, offset | Draws shape markers. If `series` is false, it usually does not draw. |
| `chart.plotchar` | PlotChar | `series/value/text/shape` | None | `location`, `value`, `color`, `offset`, `yOffset` | Draws text or shape markers by condition.`shape` supports multiple connections. |
| `chart.entry_plot` | Entry Plot | None | `plotRef` | `shape=arrow_right_sharp`, `size`, `textSize` | Outputs an entry chart template. Actual drawing happens when an order fills. |
| `chart.exit_plot` | Exit Plot | None | `plotRef` | `shape=arrow_left_sharp`, `size`, `textSize` | Outputs an exit chart template. Actual drawing happens when an order fills. |
Common chart usage:EMA.value -> chart.plots.value
RSI.value -> chart.tables.value1
Entry Plot.plotRef -> strategy.entry.plot
Exit Plot.plotRef -> strategy.close.plot
## 13. Common Strategy Templates
### 15m Execution, 1h Trend Filterevent.on_bar_close(timeframe=15m)
-> market.symbol_selector.eventIn
market.symbol_selector.symbol
-> market.get_ohlcv.symbol
market.get_ohlcv(timeframe=1h).close
-> indicator.ema(period=50)
market.get_ohlcv(timeframe=1h).close
-> indicator.ema(period=200)
EMA50.value > EMA200.value
-> logic.compare.result
logic.compare.result
-> strategy.entry.when
event.on_bar_close.out
-> logic.edge_trigger.eventIn
logic.compare.result
-> logic.edge_trigger.condition
logic.edge_trigger.eventOut
-> strategy.entry.eventIn
### Breakout Entry with ATR RiskGet OHLCV.close -> indicator.donchian.series
Last Price.price -> signal.breakout.value
Donchian.upper -> signal.breakout.level
Get OHLCV -> indicator.atr
ATR.value -> strategy.atr_stop_block.atr
risk.max_order_rate.intent
risk.order_validation.intent
strategy.atr_stop_block.intent
-> strategy.entry.riskInputs
### Prevent Repeated Orders from the Same SignalCompare.result -> state.last_signal.signal
OnBar.out -> state.last_signal.eventIn
state.last_signal.changed -> strategy.entry.when
state.last_signal.eventOut -> strategy.entry.eventIn
## 14. Troubleshooting
| Problem | Check first |
| ------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Blueprint cannot compile | Whether there is an event source; whether port types match; whether data flow forms a loop; whether an input port has duplicate connections. |
| Strategy does not trigger | Whether event timeframe is correct; whether `when` is true; whether `Edge Trigger` has already fired; whether date filter has expired. |
| Order node does not execute | Whether `eventIn` is connected; whether `riskInputs` is connected; whether risk control rejected it; whether runtime mode allows trading. |
| High-frequency repeated orders | Add `logic.gate`, `logic.once_per_bar`, `state.last_signal`, and/or `risk.max_order_rate`. |
| 1h filter does not work | Check whether `market.get_ohlcv.timeframe` is explicitly set to `1h`; do not accidentally use `runtime`. |
| Indicator is empty or abnormal | Whether `limit` covers the indicator period; whether input connects to the correct series; whether the backtest range has enough historical candles. |
| Chart does not display | Whether required chart inputs exist; whether `visible` is enabled; whether `pane/layer/zIndex` is reasonable; whether Fill references are in the same pane. |
| Type mismatch | Insert `tool.cast_number`, `tool.cast_integer`, or `tool.cast_bool`. |
## 15. Full Node ID Index
Use this index to quickly check `schemaId` in blueprint files.
| Category | Node IDs |
| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Events | `event.on_start`, `event.on_stop`, `event.on_bar`, `event.on_bar_open`, `event.on_bar_close`, `event.on_tick`, `event.on_timer`, `event.on_order_update`, `event.on_trade_transaction`, `event.on_position_update` |
| Market | `market.symbol_selector`, `market.get_ohlcv`, `market.last_price`, `market.bid_ask`, `market.mark_price`, `market.account_snapshot`, `market.position_state` |
| Indicators | `indicator.sma`, `indicator.ema`, `indicator.kama`, `indicator.rsi`, `indicator.atr`, `indicator.atr_median`, `indicator.bb`, `indicator.macd`, `indicator.donchian`, `indicator.candle_streak`, `indicator.adx`, `indicator.chop`, `indicator.vwap`, `indicator.stoch`, `indicator.stoch_rsi`, `indicator.highest`, `indicator.lowest`, `indicator.ichimoku`, `indicator.supertrend`, `indicator.fibonacci`, `indicator.cci`, `indicator.williams_r`, `indicator.parabolic_sar`, `indicator.obv`, `indicator.mfi`, `indicator.volume`, `indicator.keltner`, `indicator.roc`, `indicator.momentum`, `indicator.smoothed_momentum`, `indicator.wavetrend`, `indicator.aroon`, `indicator.cmf`, `indicator.pivot_points` |
| Signals | `logic.cross_over`, `logic.cross_under`, `signal.enter_range`, `signal.leave_range`, `signal.breakout`, `signal.breakdown`, `strategy.date_range_filter`, `strategy.cross_signal` |
| Logic | `logic.compare`, `logic.boolean_and`, `logic.boolean_or`, `logic.boolean_not`, `logic.edge_trigger`, `logic.if_else`, `bool.expression`, `logic.bool_expr`, `logic.ternary`, `logic.select_value`, `logic.gate`, `logic.once_per_bar` |
| Risk | `risk.max_order_rate`, `risk.kill_switch`, `risk.order_validation`, `risk.max_position_size`, `risk.cooldown_after_loss`, `risk.daily_consecutive_loss_cooldown`, `risk.stop_take_rule`, `strategy.atr_stop_block` |
| Functions | `strategy.entry`, `strategy.cancel`, `strategy.close`, `strategy.cancel_all`, `strategy.close_all`, `strategy.exit` |
| Orders | `strategy.entry_block`, `strategy.exit_block`, `order.place_market`, `order.place_limit`, `order.cancel_order`, `order.close_position`, `order.set_tpsl` |
| State | `strategy.trend_state`, `state.var_set`, `state.var_get`, `state.counter`, `state.persistent_set`, `state.persistent_get`, `state.rolling_window`, `state.last_signal`, `state.overbought`, `state.oversold`, `state.midline` |
| Tools | `math.expression`, `tool.number_expr`, `tool.cast_number`, `tool.cast_integer`, `tool.cast_bool`, `tool.clamp`, `tool.normalize`, `tool.add`, `tool.sub`, `tool.mul`, `tool.div`, `tool.map_symbol`, `tool.tag`, `tool.round` |
| Chart | `chart.color`, `chart.background`, `chart.bar_color`, `chart.plots`, `strategy.plot_trend_line`, `chart.fill`, `chart.hline`, `chart.levels`, `chart.line`, `chart.box`, `chart.tables`, `chart.text`, `chart.shapes`, `chart.plotchar`, `chart.entry_plot`, `chart.exit_plot |
