# Whale-E AI strategy guide This file is for AI agents that need to create a Whale-E TOML strategy, run it, and export one selected result to TradingView Pine Script. Use it as a compact bootstrap and block/key reference. Do not invent block names or keys. If a block is needed, use the exact TOML block name and key names listed here, then open the linked page for full behavior. Base documentation: https://whale-e.com/documentation/introduction/ Strategy structure: https://whale-e.com/documentation/strategy-structure/ Expressions and functions: https://whale-e.com/documentation/expressions-and-functions/ Built-in variables: https://whale-e.com/documentation/built-in-variables/ Symbols and timeframes: https://whale-e.com/documentation/exchanges-symbols-sources-and-timeframes/ Sizing, margin, leverage: https://whale-e.com/documentation/position-sizing-margin-and-leverage/ Objectives: https://whale-e.com/documentation/objectives/ Block reference: https://whale-e.com/documentation/blocks/ CLI overview: https://whale-e.com/documentation/cli/cli-overview/ JSON export: https://whale-e.com/documentation/cli/json-export/ Pine Script export: https://whale-e.com/documentation/cli/pine-script-export/ TradingView alignment: https://whale-e.com/documentation/tradingview-alignment/ Whale-E follows TradingView conventions wherever possible; parity requires the same exchange, symbol, timeframe, date range, sizing, commission, slippage, order timing, margin, and documented limits. Pine Script export and TradingView alignment are separate topics: use the Pine Script export page for `--export-pinescript`; if the user asks about TradingView parity, alignment, or a mismatch, read the TradingView alignment document before answering. ## Core model A Whale-E strategy is a TOML file. An executable strategy requires exactly one `[backtest]` table and exactly one `[start]` table. It contains: - configuration tables, especially the required `[backtest]` table - indicator blocks that create named time series - optional constraints, filters, constants, and objectives for grid search and ranking - a state machine made of `[start]`, conditional blocks, and action blocks The state machine runs candle by candle. One block is current at a time. A conditional block waits until its condition is true, then moves to the next block. An action block submits or updates a trading action, then moves to the next block. Most standalone blocks use `next_block_id`. `[[if]]` uses `then_block_id` and `else_block_id`. `[[and]]` and `[[or]]` own the transition and their logical children omit `next_block_id`; `[[route]]` has no own `next_block_id` and each direct child must define one. TOML syntax: - `[block]` is a unique table, used once. - `[[block]]` is an array-of-tables, so it can be repeated. - A fixed numeric value uses `length = 20`. - A numeric range uses `length.start`, `length.stop`, and optional `length.step`; bounds are inclusive and omitted `step` defaults to `1` unless the block says otherwise. - An array tests listed values, for example `type = ["sma", "ema", "wma"]`. - A string may name a standard price source, indicator id, order id, block id, symbol, timeframe, or expression depending on the key. Expressions and variables: - Use the expressions page for exact syntax, operators, functions, and context-specific availability. - Expression fields include `[constraints].condition`, `[[objective]].formula`, `[[condition]].condition`, `[[if]].condition`, `[[custom_series]].formula`, `[[variable]].initialization`, `[[variable]].formula`, order fields such as `qty`, `qty_percent`, `limit`, and `stop`, and comparison fields such as `reference` and `comparison`. - Depending on the key, an expression field accepts either an unquoted number or a TOML string. Use a TOML string for formulas and compound expressions. - Expressions use double-precision real numbers and strings. Comparisons and logical operators return `0` or `1`. In `[[condition]]` and `[[if]]`, `0` and `NaN` are false; any other defined non-zero value is true. - Common operators are arithmetic `+ - * / % ^`, comparisons `< <= > >= == !=` (with `=` and `<>` aliases), logical `and`, `or`, `not`, and ternary `cond ? a : b`. - String literals inside expressions use single quotes, for example `condition = "tickerid == 'BINANCE:BTCUSDT'"`. - Common functions include `na(x)`, `nz(x)`, `bool(x)`, `abs(x)`, `sqrt(x)`, `pow(a,b)`, `min(...)`, `max(...)`, `avg(...)`, `clamp(min,x,max)`, and `inrange(min,x,max)`. Open the expressions page for the full list. - Built-in variables are read-only. Use the built-in variables page for exact update timing. - Runtime backtest-summary variables: `initial_capital` starting capital; `equity` current portfolio value; `netprofit` realized net profit; `grossprofit` realized winning PnL; `grossloss` realized losing PnL as a positive value; `grossprofit_percent` and `grossloss_percent` as percent of initial capital; `avg_winning_trade`, `avg_losing_trade`, `avg_trade` average trade PnL; `avg_winning_trade_percent`, `avg_losing_trade_percent`, `avg_trade_percent` average trade PnL percent; `closedtrades` closed trade count; `max_drawdown`, `max_drawdown_percent`, `max_runup`, `max_runup_percent`. - Runtime open-position variables: `openprofit`, `openprofit_percent`, `opentrades`, `position_avg_price`, `margin_liquidation_price`. - Runtime market variables: `ticker` TradingView symbol without exchange, `tickerid` full `EXCHANGE:SYMBOL`. - Runtime candle series: `open`, `high`, `low`, `close`, `volume`, `hl2`, `hlc3`, `ohlc4`, `hlcc4`. - Objective-only variables: `sharpe_ratio`, `sortino_ratio`, `calmar_ratio`, `profit_factor`, `percent_profitable`, `profit_multiplier`, `exposure_pct`, `commission_paid`. They are valid in `[[objective]].formula`, not in trading conditions. - `fast` and `fast[0]` mean the current value of the series created by `id = "fast"`. `fast[1]` means the previous candle value. If history is unavailable, the value is `NaN`. - Indicator parameters can be referenced in expressions, for example `fast.length`, `fast.type`, `fast.symbol`, or `fast.timeframe`. - `[[custom_series]]` can use price series, indicator outputs, and indicator-level variables; it cannot use runtime backtest, portfolio, order, or trade variables. - Output variables documented on block pages are not TOML keys. TOML keys are only the keys listed under each block below. ## Minimal workflow Create `strategy.toml`, then run: ```text whale-e strategy.toml ``` For machine-readable output: ```text whale-e strategy.toml --json --json-pretty --json-include-strategy ``` `--json` writes JSON to stdout and disables console/file logs, SQLite result export, and Pine Script export for that run. To export a TradingView Pine Script, first retrieve the combination code: - in logs: `Backtest Context` > `Combination code` - in SQLite result tables: `combination_code` - in JSON: `backtests[].context.combination_code` Then run: ```text whale-e strategy.toml --export-pinescript G2C45 ``` A combination code is `GxCy`: `G` is the 1-based grid number and `C` is the combination id. Invalid or constraint-rejected combinations fail export. `--export-pinescript` prints Pine Script to stdout and cannot be combined with `--json` or `--analyze`. ## Complete strategy example ```toml # BTC/USDT 4h Trend Following - Whale-E [backtest] symbol = "BINANCE:BTCUSDT" timeframe = "240" start_date = 2018-01-01 end_date = 2026-06-26 initial_capital = 10000 # Spot / no leverage: use 95% of equity to leave room for fees and slippage. default_qty_type = "percent_of_equity" default_qty_value = 95 pyramiding = 1 commission_type = "percent" commission_value = 0.1 slippage = 2 # Signals execute from the next candle, matching TradingView's default order timing. process_orders_on_close = false close_open_position_at_end = true [[objective]] id = "calmar" formula = "calmar_ratio" ascending = false [logging] include_trades = true timestamp_enabled = false [filters] min_required_positions = 35 max_allowed_drawdown = 40 # Anti-overfitting constraints: # - the exit channel must be shorter than the entry channel # - EMA fast < EMA slow < EMA trend [constraints] condition = "exit_low.length < breakout_high.length and ema_fast.length < ema_slow.length and ema_slow.length < ema_trend.length" [[highest]] id = "breakout_high" source = "high" length.start = 48 length.stop = 168 length.step = 6 [[lowest]] id = "exit_low" source = "low" length.start = 24 length.stop = 96 length.step = 6 [[ma]] id = "ema_fast" source = "close" type = "ema" length.start = 24 length.stop = 72 length.step = 6 [[ma]] id = "ema_slow" source = "close" type = "ema" length.start = 96 length.stop = 216 length.step = 12 [[ma]] id = "ema_trend" source = "close" type = "ema" length.start = 168 length.stop = 360 length.step = 12 [[adx]] id = "adx" di_length = 14 adx_length = 14 [[constant]] id = "adx_min" start = 18 stop = 32 step = 2 [start] id = "start" next_block_id = "wait_long_breakout" [[condition]] id = "wait_long_breakout" condition = "close > breakout_high[1] and close > ema_trend and ema_fast > ema_slow and adx > adx_min" next_block_id = "open_long" [[entry]] id = "open_long" order_id = "btc_trend_long" direction = "long" # Default wait_candles = 1, so the state machine reaches monitor_exit on the next candle. next_block_id = "monitor_exit" [[or]] id = "monitor_exit" condition_ids = ["channel_breakdown", "ema_trend_loss", "ema_bearish_flip"] next_block_id = "close_long" [[condition]] id = "channel_breakdown" condition = "close < exit_low[1]" [[condition]] id = "ema_trend_loss" condition = "close < ema_fast" [[condition]] id = "ema_bearish_flip" condition = "ema_fast < ema_slow" [[close]] id = "close_long" order_id = "btc_trend_long" # Default wait_candles = 0, so the state machine can return immediately after submitting the close. next_block_id = "wait_long_breakout" ``` This example creates a grid-searched BTC/USDT 4h long strategy: wait for a Donchian breakout confirmed by EMA regime and ADX strength, open a long position, monitor three alternative exit conditions, close the position, then return to the entry condition. ## Example result excerpt This illustrative excerpt depends on market data, cache state, Whale-E version, settings, and CPU. The `723.2M candles/s` throughput was measured on an Intel Core i9-13900K, which is a very fast desktop CPU. ```text [info] Grid 1/1 has 2 823 552 valid combinations out of 3 675 672 total combinations. [info] [Run 1/1] Grid 1 BINANCE:BTCUSDT (240): Exploring 2 823 552 valid combinations. [info] [Run 1/1] Grid 1 BINANCE:BTCUSDT (240): Completed in 01m 11s 322ms with 2 823 552 backtests, 190 377 564 positions, and 723.2M candles/s. [info] [Run 1/1] 379 320 backtests exceeded the maximum allowed drawdown. ``` Best ranked result: ```text [info] Result 1 | score 2.44159153 | G1C84002 | BINANCE:BTCUSDT | 240 [info] Hyperparameters [info] ---------------------------------------- [info] adx_min | 22.000000000000 [info] breakout_high.length | 48 [info] ema_fast.length | 54 [info] ema_slow.length | 96 [info] ema_trend.length | 228 [info] exit_low.length | 24 [info] ---------------------------------------- [info] Overview [info] ---------------------------------------------------------------------------------- [info] Total P&L | Max equity drawdown | Trades | Profitable trades | Profit factor [info] ---------------------------------------------------------------------------------- [info] 230104.28 USDT | 34057.65 USDT | 74 | 47.30 % | 2.877 [info] 2301.04 % | 18.60 % | | 35/74 | [info] ---------------------------------------------------------------------------------- ``` ## Configuration blocks ### `[backtest]` Purpose: Defines the backtest window, market grid, execution model, sizing, fees, margin, and end-of-test handling. Doc: https://whale-e.com/documentation/blocks/configuration/backtest/ Keys: - `start_date` (required): backtest start date/time. Dates are interpreted with the fixed offset inferred from `start_date` and `end_date`, then run internally in UTC. - `end_date` (required): backtest end date/time, using the same date formats and offset rules as `start_date`. - `price_history_start_date` (optional): earlier data-loading start using the same date/offset rules as `start_date`; explicit conflicting offsets are rejected and Whale-E may move it earlier to satisfy lookback needs. - `symbol` (required): symbol or array of symbols in `EXCHANGE:SYMBOL` format; normalized duplicates are rejected. - `timeframe` (required): timeframe or array; minutes `1`..`1440`, days `D`/`1D`..`365D`, weeks `W`/`1W`..`52W`; monthly `M` is not supported; duplicates are rejected. - `auto_slippage_enabled` (optional): enables slippage based on one-minute candle range. Default `false`. - `auto_slippage_ratio` (optional): fraction of the one-minute high-low range used for automatic slippage. Effective default is `0` when disabled, `0.25` when enabled. - `slippage` (optional): manual slippage in ticks, used when automatic slippage is disabled. Default `0`. - `backtest_fill_limits_assumption` (optional): tick overrun required to fill limit orders. `0` means touch is enough. Default `0`. - `use_bar_magnifier` (optional): uses lower-timeframe inspection to resolve intrabar event order. Default `false`. - `process_orders_on_close` (optional): allows orders created on bar close to execute on that close tick. Default `false`. - `max_blocks_on_same_candle` (optional): loop guard for block transitions on the same candle. `0` disables it. Default `1024`. - `commission_value` (optional): commission amount interpreted by `commission_type`. Default `0.1` in percent mode, `0` in cash modes; percent must be `< 100`. - `commission_type` (optional): `percent`, `cash_per_contract`, or `cash_per_order`. Default `"percent"`. - `initial_capital` (optional): initial quote-currency capital. Default `1000000`. - `default_qty_type` (optional): global sizing mode for entries and raw orders: `fixed`, `cash`, or `percent_of_equity`. Default `"percent_of_equity"`. - `default_qty_value` (optional): global sizing value; fixed quantity, cash budget, or equity percentage depending on `default_qty_type`. Default `100` in percentage mode; ranges are allowed only in percentage mode. - `margin_long` (optional): long margin percentage, `>= 0`; `0` disables margin for longs, values above `100` are allowed. Default `100`. - `margin_short` (optional): short margin percentage, `>= 0`; `0` disables margin for shorts, values above `100` are allowed. Default `100`. - `long_size_multiplier` (optional): multiplier applied only to percentage-based long sizing. Can be ranged. Default `1`. - `short_size_multiplier` (optional): multiplier applied only to percentage-based short sizing. Can be ranged. Default `1`. - `pyramiding` (optional): maximum number of same-direction entries, `1..10000`. `1` disables pyramiding. Default `1`. - `close_entries_rule` (optional): entry-closing rule used by `[[close]]`, usually `"fifo"` or `"any"`. Default `"fifo"`. - `close_open_position_at_end` (optional): closes any open position at `end_date` when true; otherwise values it open. Default `true`. ### `[general]` Purpose: Configures engine-level runtime options and the in-memory indicator cache. Doc: https://whale-e.com/documentation/blocks/configuration/general/ Keys: - `threads` (optional): worker threads. `0` or omitted means automatic selection: logical cores minus one, minimum `1`. - `results_directory` (optional): output directory; provided path must be absolute. Default is `results` under the strategy directory, resolved to absolute. - `cache_enabled` (optional): enables the in-memory indicator series cache. Default `true`. - `cache_budget_mode` (optional): cache budget mode: `off`, `percent`, or `mb`. Default `"percent"`. - `cache_budget_value` (optional): budget value; `percent` requires `1..100`, `mb` requires `> 0`, `off` ignores the value. Default `80`. ### `[logging]` Purpose: Controls console/file logging and which backtest details appear in logs. Doc: https://whale-e.com/documentation/blocks/configuration/logging/ Keys: - `file_logging_enabled` (optional): writes logs to file. Default `false`. - `console_logging_enabled` (optional): writes logs to console. Default `true`. - `timestamp_enabled` (optional): prefixes log lines with timestamps. Default `true`. - `estimated_time_display_minutes` (optional): interval for remaining-time updates in grid logs, `0..1440`; `0` disables. Default `5`. - `logs_directory` (optional): absolute directory for log files. - `log_file_name` (optional): explicit log file name; otherwise generated from strategy and date. - `objective_limit` (optional): number of ranked results to print per objective. Default `1`. - `include_trades` (optional): prints the trade list. Default `false`. - `include_all_grid_parameters` (optional): logs non-varying grid parameters too. Default `false`. - `include_all_hyperparameters` (optional): logs non-varying hyperparameters too. Default `false`. - `include_block_usage` (optional): logs block execution counters. Default `false`. - `trades_oldest_first` (optional): orders the trade list from oldest to newest when `include_trades = true`. When `false`, newest trades are shown first. Default `false`. - `include_strategy_toml` (optional): appends the loaded TOML to logs. Default `false`. ### `[database]` Purpose: Configures SQLite result export and the local market-data cache. Doc: https://whale-e.com/documentation/blocks/configuration/database/ Keys: - `backtest_export_enabled` (optional): exports backtest results to SQLite. Default `false`. - `objective_limit` (optional): maximum exported backtests per objective. Default `50`. - `database_directory` (optional): result database directory; provided path must be absolute. Created/used only when result export is enabled. - `database_file_name` (optional): result database file name; otherwise generated from strategy and timestamp. - `market_data_cache_enabled` (optional): enables the persistent market-data cache. Default `true`. - `market_data_cache_directory` (optional): directory containing `cache.db`; provided path must be absolute. Created/used only when market-data cache is enabled. - `include_all_grid_parameters` (optional): stores non-varying grid parameters too. Default `false`. - `include_all_hyperparameters` (optional): stores non-varying hyperparameters too. Default `false`. - `include_trades` (optional): stores detailed trades. Default `false`. - `include_block_usage` (optional): stores block execution counters. Default `false`. - `include_strategy_toml` (optional): stores the source TOML in metadata. Default `false`. ### `[network]` Purpose: Configures strategy-level TLS behavior for HTTP(S) requests after strategy loading. Doc: https://whale-e.com/documentation/blocks/configuration/network/ Keys: - `verify_tls` (optional): enables server certificate verification. Default `true`. - `allow_insecure_tls` (optional): required explicit acknowledgement when `verify_tls = false`. Default `false`. - `ca_bundle_path` (optional): absolute existing custom CA bundle path; validated if present, used only with TLS verification, and overridden by `WHALEE_CA_BUNDLE`. ### `[filters]` Purpose: Defines final or runtime rejection thresholds for performance and risk. Doc: https://whale-e.com/documentation/blocks/configuration/filters/ Keys: - `min_required_positions` (optional): minimum completed positions required, `>= 1`. Default `1`. - `min_roi_pct` (optional): minimum return on initial capital in percent, `0..100`. Default `0` disabled. - `min_win_rate` (optional): minimum winning-position percentage. Default `0`. - `min_sharpe_ratio` (optional): minimum annualized Sharpe ratio. Default `0` disabled. - `min_sortino_ratio` (optional): minimum annualized Sortino ratio. Default `0` disabled. - `min_calmar_ratio` (optional): minimum Calmar ratio. Default `0` disabled. - `max_allowed_drawdown` (optional): maximum drawdown percentage, `>= 0`; can stop a backtest early. Omitted means no limit. - `max_initial_capital_loss` (optional): maximum loss from initial capital in percent, `0..100`; default protection is `80`. - `max_margin_calls` (optional): maximum total margin calls allowed; omitted or `< 0` disables the filter, `0` forbids the first one. ### `[constraints]` Purpose: Filters invalid hyperparameter combinations before each backtest. Doc: https://whale-e.com/documentation/blocks/configuration/constraints/ Keys: - `condition` (required): boolean expression filtering combinations before each backtest; use indicator range fields, constants, and percentage-sizing ranges, not objective/result variables. False combinations are skipped. ### `[[objective]]` Purpose: Defines a ranking score and sort direction for tested combinations. Doc: https://whale-e.com/documentation/blocks/configuration/objective/ Keys: - `id` (required): unique objective identifier. - `formula` (required): expression evaluated from backtest result variables. If no `[[objective]]` is declared, Whale-E uses `id = "netprofit"`, `formula = "netprofit"`, `ascending = false`. - `ascending` (optional): `true` minimizes the score; `false` maximizes it. Default `false`. ### `[[constant]]` Purpose: Declares a reusable numeric constant that can be optimized across a range. Doc: https://whale-e.com/documentation/blocks/configuration/constant/ Keys: - `id` (required): unique constant name used in expressions. - `start` (required): first value. - `stop` (required): last value. - `step` (optional): increment between values. Default `1`. ### `[[symbol_override]]` Purpose: Overrides market constraints for a specific symbol. Doc: https://whale-e.com/documentation/blocks/configuration/symbol-override/ Keys: - `symbol` (required): full symbol with exchange prefix, for example `"OKX:BTCUSDT"`. - `mincontract` (optional): minimum tradable quantity step. - `mintick` (optional): minimum price tick. - `pointvalue` (optional): monetary value of one price point; not every exchange alias applies this override. ## State-machine and action blocks Graph ids, order ids, `from_entry`, and transition targets must be valid Whale-E identifiers; required ids must be non-empty after graph validation. ### `[start]` Purpose: Required entry point of the strategy graph. Doc: https://whale-e.com/documentation/blocks/actions/start/ Keys: - `id` (required): unique identifier of the start block. - `next_block_id` (required): first block to evaluate; must be non-empty in executable strategies. ### `[[entry]]` Purpose: Creates or updates an entry order; fills open, add to, or reverse a managed position according to pyramiding and reversal rules. Doc: https://whale-e.com/documentation/blocks/actions/entry/ Keys: - `id` (required): unique graph block id. - `order_id` (required): engine-level entry id used by `[[close]]`, `[[cancel]]`, and `[[exit]].from_entry`. - `next_block_id` (required): block to execute after the entry transition delay. - `direction` (optional): `"long"` or `"short"`. Default `"long"`. - `qty` (optional): absolute quantity; overrides global sizing. Mutually exclusive with `qty_percent`. - `qty_percent` (optional): percent of equity for this order; overrides global sizing. Mutually exclusive with `qty`. - `limit` (optional): limit price or expression. - `stop` (optional): stop trigger price or expression. - `oca_name` (optional): OCA group name. - `oca_type` (optional): canonical OCA behavior: `"cancel"`, `"reduce"`, or `"none"`. Default `"cancel"`. - `comment` (optional): trade-list/Pine comment; no calculation effect. - `alert_message` (optional): Pine Script alert message only. - `wait_candles` (optional): candles to wait before moving on; affects transition only. Default `1`. ### `[[order]]` Purpose: Submits a raw buy/sell order not tied to entry-position management. Doc: https://whale-e.com/documentation/blocks/actions/order/ Keys: - `id` (required): unique graph block id. - `order_id` (required): order identifier used by `[[cancel]]`; not targeted by `[[close]]` or `[[exit]].from_entry`, though an unfiltered `[[exit]]` can apply to the resulting position. - `next_block_id` (required): block to execute after the order transition delay. - `direction` (optional): `"long"` means buy, `"short"` means sell. Default `"long"`. - `qty` (optional): absolute quantity; overrides global sizing. Mutually exclusive with `qty_percent`. - `qty_percent` (optional): percent of equity; overrides global sizing. Mutually exclusive with `qty`. - `limit` (optional): limit price or expression. - `stop` (optional): stop trigger price or expression. - `oca_name` (optional): OCA group name. - `oca_type` (optional): canonical OCA behavior: `"cancel"`, `"reduce"`, or `"none"`. Default `"cancel"`. - `comment` (optional): trade-list/Pine comment; no calculation effect. - `alert_message` (optional): Pine Script alert message only. - `disable_alert` (optional): Pine Script alert disabling flag. Default `false`. - `wait_candles` (optional): candles to wait before moving on; affects transition only. Default `1`. ### `[[exit]]` Purpose: Places, updates, or cancels take-profit, stop-loss, and trailing exit orders. Doc: https://whale-e.com/documentation/blocks/actions/exit/ Keys: - `id` (required): unique graph block id. - `next_block_id` (required): block to execute next. - `order_id` (required): exit set identifier; repeated evaluation replaces matching exits, and providing no exit level cancels that set. - `from_entry` (optional): restricts exit to entries whose `order_id` matches; can arm exits before a pending entry fills; cannot target `[[order]]`. - `qty` (optional): fixed quantity to exit. Mutually exclusive with `qty_percent`. - `qty_percent` (optional): percent of current position to exit. Default `100`. Mutually exclusive with `qty`. - `profit` (optional): take-profit distance in ticks from entry price. - `limit` (optional): take-profit absolute limit price. - `loss` (optional): stop-loss distance in ticks from entry price. - `stop` (optional): stop-loss absolute stop price. - `trail_price` (optional): trailing stop activation price. - `trail_points` (optional): trailing stop activation distance in ticks from entry. - `trail_offset` (optional): trailing distance in ticks; requires activation by `trail_price` or `trail_points`. - `oca_name` (optional): OCA group name for generated exit orders; empty creates an internal isolated OCA reduce group for that exit set. - `comment` (optional): general Pine comment/trade signal fallback. - `comment_profit` (optional): Pine `comment_profit` only. - `comment_loss` (optional): Pine `comment_loss` only. - `comment_trailing` (optional): Pine `comment_trailing` only. - `alert_message` (optional): Pine `alert_message` only. - `alert_profit` (optional): Pine `alert_profit` only. - `alert_loss` (optional): Pine `alert_loss` only. - `alert_trailing` (optional): Pine `alert_trailing` only. - `disable_alert` (optional): Pine `disable_alert` only. Default `false`. - `wait_candles` (optional): candles to wait before moving on; affects transition only. Default `0`. Exit level rules: if both `profit` and `limit` are set, Whale-E uses the level closest to entry; same for `loss` and `stop`. Trailing requires `trail_offset` plus `trail_price` or `trail_points`; if both activation levels are set, the closest activation is used. Without `from_entry`, an exit applies persistently to current and later same-side legs while the position remains open. ### `[[close]]` Purpose: Closes all or part of an open entry position. Doc: https://whale-e.com/documentation/blocks/actions/close/ Keys: - `id` (required): unique graph block id. - `next_block_id` (required): block to execute next. - `order_id` (required): targets the `order_id` of an existing `[[entry]]`, not the entry block `id`. - `qty` (optional): absolute quantity to close. Mutually exclusive with `qty_percent`. - `qty_percent` (optional): percent of open position to close. Mutually exclusive with `qty`. If both `qty` and `qty_percent` are omitted, closes 100% of the targeted entry. - `comment` (optional): trade-list/Pine comment; no calculation effect. - `alert_message` (optional): Pine Script alert message only. - `wait_candles` (optional): candles to wait before moving on; affects transition only. Default `0`. ### `[[close_all]]` Purpose: Closes the full long and short exposure. Doc: https://whale-e.com/documentation/blocks/actions/close-all/ Keys: - `id` (required): unique graph block id. - `next_block_id` (required): block to execute next. - `immediately` (optional): forces current-candle close behavior regardless of `process_orders_on_close`. Default `false`; when false and `process_orders_on_close` is false, the close happens on the next eligible candle. - `wait_candles` (optional): candles to wait before moving on; affects transition only. Default `0`. - `comment` (optional): trade-list/Pine comment. Defaults to `Close All`. - `alert_message` (optional): Pine Script alert message only. ### `[[cancel]]` Purpose: Cancels pending orders and exit intents matching an `order_id`. Doc: https://whale-e.com/documentation/blocks/actions/cancel/ Keys: - `id` (required): unique graph block id. - `order_id` (required): target id for pending `[[entry]]`, `[[order]]`, `[[exit]]` orders and matching deferred or persistent exit intents; cancelling an unfilled entry with no open leg also clears exits tied to that entry. - `next_block_id` (required): block to execute next. - `wait_candles` (optional): candles to wait before moving on; affects transition only. Default `0`. ### `[[cancel_all]]` Purpose: Cancels pending entry/order orders, price-based exits, and deferred/persistent exit intents while leaving already scheduled market close exits active. Doc: https://whale-e.com/documentation/blocks/actions/cancel-all/ Keys: - `id` (required): unique graph block id. - `wait_candles` (optional): candles to wait before moving on; affects transition only. Default `0`. - `next_block_id` (required): block to execute next. ## Conditional and flow blocks Predicate children allowed in `condition_ids`: `condition`, `trend`, `position`, `threshold`, `cross`, `crossover`, `crossunder`, `trailing`, `wait`, `and`, `or`. Do not use `if`, `variable`, `route`, or action blocks in `condition_ids`. For predicate blocks, `next_block_id` is required when standalone or a direct `[[route]]` child, forbidden when child of `[[and]]` or `[[or]]`; `[[route]]` itself never has `next_block_id`. ### `[[condition]]` Purpose: Evaluates a free boolean expression on each candle. Doc: https://whale-e.com/documentation/blocks/conditional/condition/ Keys: - `id` (required): unique graph block id. - `condition` (required): expression; `0` and `NaN` are false, non-zero defined values are true. - `next_block_id` (conditional): next block after validation. Required when standalone or direct child of `[[route]]`; forbidden as child of `[[and]]` or `[[or]]`. ### `[[cross]]` Purpose: Detects either bullish or bearish crossing: `(reference > comparison and reference[1] <= comparison[1]) or (reference < comparison and reference[1] >= comparison[1])`. Doc: https://whale-e.com/documentation/blocks/conditional/cross/ Keys: - `id` (required): unique graph block id. - `reference` (required): numeric expression that crosses. - `comparison` (required): numeric expression or level crossed by `reference`. - `next_block_id` (conditional): next block after validation, with the same child/direct rules as `[[condition]]`. ### `[[crossover]]` Purpose: Detects `reference` crossing above `comparison`: `reference > comparison and reference[1] <= comparison[1]`. Doc: https://whale-e.com/documentation/blocks/conditional/crossover/ Keys: - `id` (required): unique graph block id. - `reference` (required): numeric expression that must move above `comparison`. - `comparison` (required): numeric expression or level. - `next_block_id` (conditional): next block after validation, with the same child/direct rules as `[[condition]]`. ### `[[crossunder]]` Purpose: Detects `reference` crossing below `comparison`: `reference < comparison and reference[1] >= comparison[1]`. Doc: https://whale-e.com/documentation/blocks/conditional/crossunder/ Keys: - `id` (required): unique graph block id. - `reference` (required): numeric expression that must move below `comparison`. - `comparison` (required): numeric expression or level. - `next_block_id` (conditional): next block after validation, with the same child/direct rules as `[[condition]]`. ### `[[if]]` Purpose: Immediately chooses one of two graph branches from a boolean expression. Doc: https://whale-e.com/documentation/blocks/conditional/if/ Keys: - `id` (required): unique graph block id. - `condition` (required): boolean expression; `0` and `NaN` are false. - `then_block_id` (required): block executed when true. - `else_block_id` (required): block executed when false or `NaN`. `[[if]]` is not a predicate and cannot be used in `condition_ids`. ### `[[and]]` Purpose: Evaluates children in order and validates only when all reached child conditions are true on the same candle; stops at first false. Doc: https://whale-e.com/documentation/blocks/conditional/and/ Keys: - `id` (required): unique graph block id. - `condition_ids` (required): predicate child id or array of ids to evaluate. - `next_block_id` (conditional): next block after group validation. Omit when this block is a child of `[[and]]` or `[[or]]`. ### `[[or]]` Purpose: Evaluates children in order and validates when the first reached child condition is true; stops at first true. Doc: https://whale-e.com/documentation/blocks/conditional/or/ Keys: - `id` (required): unique graph block id. - `condition_ids` (required): predicate child id or array of ids evaluated sequentially. - `next_block_id` (conditional): next block after group validation. Omit when this block is a child of `[[and]]` or `[[or]]`. ### `[[route]]` Purpose: Tests child conditions in order and follows the `next_block_id` of the first validated child. Doc: https://whale-e.com/documentation/blocks/conditional/route/ Keys: - `id` (required): unique graph block id. - `condition_ids` (required): private route child predicate id or array of ids; each child must define its own `next_block_id`, and other blocks must not target route children. ### `[[position]]` Purpose: Compares `reference` and `comparison` with a strict instantaneous relationship, not a crossing event. Doc: https://whale-e.com/documentation/blocks/conditional/position/ Keys: - `id` (required): unique graph block id. - `position` (required): `"above"` means `reference > comparison`; `"below"` means `reference < comparison`. - `reference` (required): expression being compared. - `comparison` (required): expression used as comparison point. - `next_block_id` (conditional): next block after validation, with the same child/direct rules as `[[condition]]`. ### `[[threshold]]` Purpose: Tests whether a relative percentage gap between two expressions reaches a threshold. Doc: https://whale-e.com/documentation/blocks/conditional/threshold/ Keys: - `id` (required): unique graph block id. - `position` (required): `"above"` means `reference >= comparison * (1 + threshold / 100)`; `"below"` means `reference <= comparison * (1 - threshold / 100)`. - `reference` (required): expression being compared. - `comparison` (required): baseline expression. - `threshold` (required): percentage gap, as number or expression string. - `next_block_id` (conditional): next block after validation, with the same child/direct rules as `[[condition]]`. ### `[[trailing]]` Purpose: Tracks a running extreme and validates after a relative pullback/rebound; first visit arms the tracker and each trigger resets it. Doc: https://whale-e.com/documentation/blocks/conditional/trailing/ Keys: - `id` (required): unique graph block id. - `position` (required): `"above"` tracks a running high and validates when current value falls by `abs(threshold)%`; `"below"` tracks a running low and validates when current value rebounds by `abs(threshold)%`. - `expression` (required): expression monitored on each candle. - `threshold` (required): pullback/rebound percentage, as number or expression string; runtime uses `abs(threshold)`. - `next_block_id` (conditional): next block after validation, with the same child/direct rules as `[[condition]]`. ### `[[trend]]` Purpose: Compares an expression with its previous candle value. Doc: https://whale-e.com/documentation/blocks/conditional/trend/ Keys: - `id` (required): unique graph block id. - `direction` (required): `"bullish"` for current > previous, `"bearish"` for current < previous. - `reference` (required): numeric expression to compare over time. - `next_block_id` (conditional): next block after validation, with the same child/direct rules as `[[condition]]`. ### `[[variable]]` Purpose: Immediately initializes or updates a persistent numeric runtime variable, then jumps to `next_block_id`. Doc: https://whale-e.com/documentation/blocks/conditional/variable/ Keys: - `id` (required): unique graph block id. - `variable` (required): variable name; must be a valid identifier and not collide with another runtime symbol. - `initialization` (required): startup expression; string, integer, or float, single expression only. - `formula` (required): expression evaluated when the block is reached; result replaces the variable value. `[[variable]]` is not a predicate and cannot be used in `condition_ids`. - `next_block_id` (required): block to execute next. ### `[[wait]]` Purpose: Standalone, pauses graph execution for a fixed number of candles. In `[[and]]`, `[[or]]`, or `[[route]]`, acts as a stateful predicate that becomes true when complete. Doc: https://whale-e.com/documentation/blocks/conditional/wait/ Keys: - `id` (required): unique graph block id. - `wait_candles` (optional): number of candles to wait, at least `1`. Default `1`. - `next_block_id` (conditional): next block after waiting, with the same child/direct rules as `[[condition]]`. ## Indicator blocks Indicator blocks create named series used later in expressions and state-machine blocks. The output key names differ by block: some use `id`, others use keys such as `upper_id`, `macd_id`, `k_id`, or `plus_id`. Always follow the exact key list of the selected block; do not infer keys from another indicator. Shared indicator TOML rules: - Standard price sources are `open`, `high`, `low`, `close`, `hl2`, `hlc3`, `ohlc4`, `hlcc4`, and `volume`. - Unless a block says otherwise, `source` accepts a string or array; each value is a standard price source or another indicator id. Duplicate sources are rejected. - `symbol` and `timeframe` accept a string or array. `symbol` uses `EXCHANGE:SYMBOL`, applies only to standard price sources, and is ignored when all sources are indicator ids. Omitted values inherit `[backtest]`. - Indicator `timeframe` uses the same supported formats as `[backtest].timeframe`; monthly `M` is not supported. - Indicator integer lengths generally use `1..10000` fixed or range values unless the block states a stricter minimum. Decimal multipliers/factors documented as positive must be `> 0`. - Do not add `source` to blocks whose key list omits it; those blocks use fixed inputs such as high/low or high/low/close. ### `[[adx]]` Purpose: Computes ADX trend strength. Doc: https://whale-e.com/documentation/blocks/indicator/average-directional-index-adx/ Keys: - `id` (required): ADX output series name. - `di_length` (optional): averaging window for +DI/-DI, fixed or range, `1..10000`. Default `14`. - `adx_length` (optional): smoothing window for ADX, fixed or range, `1..10000`. Default `14`. - `symbol` (optional): market for high/low/close input. - `timeframe` (optional): computation timeframe. ### `[[ao]]` Purpose: Computes Awesome Oscillator as the gap between fast and slow SMAs. Doc: https://whale-e.com/documentation/blocks/indicator/awesome-oscillator-ao/ Keys: - `id` (required): AO output series name. - `source` (optional): input series. Default `hl2`. - `fast` (optional): fast SMA length, fixed or range, `1..10000`. Default `5`. - `slow` (optional): slow SMA length, fixed or range, `1..10000`; at least one generated pair must satisfy `fast < slow`. Default `34`. - `symbol` (optional): market for price input. - `timeframe` (optional): computation timeframe. ### `[[aroon]]` Purpose: Computes Aroon Up and Aroon Down. Doc: https://whale-e.com/documentation/blocks/indicator/aroon-aroon/ Keys: - `up_id` (required): Aroon Up output series name. - `down_id` (required): Aroon Down output series name. - `length` (optional): lookback length, fixed or range. Default `14`. - `symbol` (optional): market for high/low input. - `timeframe` (optional): computation timeframe. ### `[[atr]]` Purpose: Computes Average True Range volatility. Doc: https://whale-e.com/documentation/blocks/indicator/average-true-range-atr/ Keys: - `id` (required): ATR output series name. - `length` (optional): ATR window, fixed or range, `1..10000`. Default `14`. - `symbol` (optional): market for high/low/close input. - `timeframe` (optional): computation timeframe. ### `[[barssince]]` Purpose: Counts candles since a condition was last true; output is `NaN` until the first true value, then `0`, `1`, `2`, etc. Doc: https://whale-e.com/documentation/blocks/indicator/bars-since-barssince/ Keys: - `id` (required): output counter series name. - `condition` (required): indicator-stage expression; defined non-zero is true, `0` and `NaN` are false. - `timeframe` (optional): timeframe used to evaluate the condition. - `symbol` (forbidden): use symbol-specific upstream series inside `condition` instead. ### `[[bbw]]` Purpose: Computes BBW = `100 * (upper - lower) / basis`, equivalent to `100 * 2 * multiplier * stdev(source,length) / SMA(source,length)`. Doc: https://whale-e.com/documentation/blocks/indicator/bollinger-band-width-bbw/ Keys: - `id` (required): BBW output series name. - `source` (optional): input series. Default `close`. - `length` (optional): SMA/stdev window, fixed or range, `1..10000`. Default `20`. - `multiplier` (optional): standard deviation multiplier, fixed or range. Default `2.0`. - `symbol` (optional): market for price input. - `timeframe` (optional): computation timeframe. ### `[[bb]]` Purpose: Computes Bollinger Bands. Doc: https://whale-e.com/documentation/blocks/indicator/bollinger-bands-bb/ Keys: - `upper_id` (required): upper band output series name. - `middle_id` (required): middle band output series name. - `lower_id` (required): lower band output series name. - `source` (optional): input series. Default `close`. - `length` (optional): moving average and stdev window, fixed or range, `2..10000`. Default `20`. - `multiplier_upper` (optional): positive upper band stdev multiplier, fixed or range. Default `2.0`. - `multiplier_lower` (optional): positive lower band stdev multiplier, fixed or range. Default `2.0`. - `type` (optional): moving average type: `sma`, `ema`, `wma`, `hma`, `dema`, `tema`, `trima`, `smma`, `zlema`, or `rma`; string or unique array. Default `sma`. - `symbol` (optional): market for price input. - `timeframe` (optional): computation timeframe. ### `[[cci]]` Purpose: Computes Commodity Channel Index. Doc: https://whale-e.com/documentation/blocks/indicator/commodity-channel-index-cci/ Keys: - `id` (required): CCI output series name. - `source` (optional): input series. Default `hlc3`. - `length` (required): observation window, fixed or range, `2..10000`. - `symbol` (optional): market for price input. - `timeframe` (optional): computation timeframe. ### `[[change]]` Purpose: Computes the fixed-lag difference of a series. Doc: https://whale-e.com/documentation/blocks/indicator/change/ Keys: - `id` (required): output series name. - `source` (optional): input series. Default `close`. - `length` (required): lag in candles, fixed or range, `1..10000`. - `symbol` (optional): market for price input. - `timeframe` (optional): computation timeframe. ### `[[cmo]]` Purpose: Computes Chande Momentum Oscillator. Doc: https://whale-e.com/documentation/blocks/indicator/chande-momentum-oscillator-cmo/ Keys: - `id` (required): CMO output series name. - `source` (optional): input series. Default `close`. - `length` (optional): observation window, fixed or range, `2..10000`. Default `20`. - `symbol` (optional): market for price input. - `timeframe` (optional): computation timeframe. ### `[[chandelier]]` Purpose: Computes rolling long and short Chandelier Exit levels from recent high/low extremes offset by ATR; it exposes thresholds but does not close positions or enforce a ratchet. Doc: https://whale-e.com/documentation/blocks/indicator/chandelier-exit-chandelier/ Keys: - `long_id` (required): long exit-level output series name. - `short_id` (required): short exit-level output series name. - `length` (optional): recent-extreme window, fixed or range, `1..10000`. Default `22`. - `atr_length` (optional): ATR window, fixed or range, `1..10000`. Default `22`. - `multiplier` (optional): strictly positive ATR multiplier, fixed or range. Default `3.0`. - `symbol` (optional): market for high/low/close input. - `timeframe` (optional): computation timeframe. The `source` key is not accepted; `[[chandelier]]` always uses high, low, and close. ### `[[cog]]` Purpose: Computes COG = `-sum(age * source) / sum(source)`, with current candle age `1` and oldest age `length`. Doc: https://whale-e.com/documentation/blocks/indicator/center-of-gravity-cog/ Keys: - `id` (required): COG output series name. - `source` (optional): input series. Default `close`. - `length` (required): lookback window, fixed or range, `1..10000`. - `symbol` (optional): market for price input. - `timeframe` (optional): computation timeframe. ### `[[correlation]]` Purpose: Computes Pearson correlation between two series. Doc: https://whale-e.com/documentation/blocks/indicator/correlation/ Keys: - `id` (required): correlation output series name. - `source1` (required): first input series, string or array. - `source2` (required): second input series, string or array. - `length` (required): correlation window, fixed or range, `1..10000`. - `symbol` (optional): allowed only if every generated `source1`/`source2` pair uses standard price sources; rejected for indicator-based or mixed pairs. - `timeframe` (optional): computation timeframe. ### `[[custom_series]]` Purpose: Creates a formula-based indicator series. Doc: https://whale-e.com/documentation/blocks/indicator/custom-series/ Keys: - `id` (required): output series name. - `formula` (required): expression defining the computed series. - `timeframe` (optional): computation timeframe. - `symbol` (forbidden): not allowed on `[[custom_series]]`; use upstream symbol-specific series instead. ### `[[dev]]` Purpose: Computes mean absolute deviation around an SMA. Doc: https://whale-e.com/documentation/blocks/indicator/deviation-dev/ Keys: - `id` (required): deviation output series name. - `source` (optional): input series. Default `close`. - `length` (required): SMA/deviation window, fixed or range, `1..10000`. - `symbol` (optional): market for price input. - `timeframe` (optional): computation timeframe. ### `[[dmi]]` Purpose: Computes +DI, -DI, and optionally ADX. Doc: https://whale-e.com/documentation/blocks/indicator/directional-movement-index-dmi/ Keys: - `plus_id` (conditional): +DI output series name. - `minus_id` (conditional): -DI output series name. - `adx_id` (conditional): ADX output series name; requires `plus_id`, `minus_id`, and `adx_length`. - `di_length` (optional): +DI/-DI smoothing window, fixed or range, `1..10000`. Default `14`. - `adx_length` (conditional): ADX smoothing window, fixed or range, `1..10000`; required with `adx_id`, forbidden without it. - `symbol` (optional): market for high/low/close input. - `timeframe` (optional): computation timeframe. At least one of `plus_id`, `minus_id`, or `adx_id` is required. ### `[[dm]]` Purpose: Computes the Demarker ratio from rising highs and falling lows; the output normally ranges from `0` to `1` and is `NaN` when both averaged components are zero. Doc: https://whale-e.com/documentation/blocks/indicator/demarker-indicator-dm/ Keys: - `id` (required): Demarker output series name. - `length` (optional): averaging window, fixed or range, `1..10000`. Default `14`. - `symbol` (optional): market for high/low input. - `timeframe` (optional): computation timeframe. The `source` key is not accepted; `[[dm]]` always uses high and low. ### `[[donchian]]` Purpose: Computes Donchian upper and lower channels. Doc: https://whale-e.com/documentation/blocks/indicator/donchian-channels/ Keys: - `upper_id` (required): upper channel output series name. - `lower_id` (required): lower channel output series name. - `symbol` (optional): market for high/low input. - `timeframe` (optional): computation timeframe. - `length` (optional): lookback window, fixed or range, `1..10000`. Default `20`. ### `[[donchian_mid]]` Purpose: Computes the midpoint of Donchian high/low bounds. Doc: https://whale-e.com/documentation/blocks/indicator/donchian-mid-line/ Keys: - `id` (required): midpoint output series name. - `length` (optional): lookback window, fixed or range, `1..10000`. Default `20`. - `offset` (optional): non-negative forward projection offset, fixed or range. Default `0`. - `symbol` (optional): market for high/low input. - `timeframe` (optional): computation timeframe. ### `[[eom]]` Purpose: Computes SMA-smoothed Ease of Movement from candle midpoint displacement, high-low range, and volume. Doc: https://whale-e.com/documentation/blocks/indicator/ease-of-movement-eom/ Keys: - `id` (required): EOM output series name. - `length` (optional): number of defined readings in the smoothing window, fixed or range, `1..10000`; zero-volume candles are ignored. Default `14`. - `div` (optional): signed integer scale factor, fixed or range; `0` makes defined readings zero and a negative value reverses their sign. Default `10000`. - `symbol` (optional): market for high/low/volume input. - `timeframe` (optional): computation timeframe. The `source` key is not accepted; `[[eom]]` always uses high, low, and volume. ### `[[er]]` Purpose: Computes Kaufman's Efficiency Ratio as net displacement divided by total traveled distance; it measures path efficiency, not direction, and normally ranges from `0` to `1` on continuous defined windows. Doc: https://whale-e.com/documentation/blocks/indicator/kaufmans-efficiency-ratio-er/ Keys: - `id` (required): ER output series name. - `source` (optional): input series. Default `close`. - `length` (optional): observation window, fixed or range, `1..10000`. Default `10`. - `symbol` (optional): market for price input. - `timeframe` (optional): computation timeframe. If the source contains `NaN`, retained valid changes can make the output exceed `1` after the current and lagged values become defined again. ### `[[falling]]` Purpose: Outputs `1.0` when the source has strictly fallen across the last `length` valid comparisons, otherwise `0.0`. Doc: https://whale-e.com/documentation/blocks/indicator/falling/ Keys: - `id` (required): boolean/numeric output series name. - `source` (optional): input series. Default `close`. - `length` (required): number of falling comparisons, fixed or range, `1..10000`. - `symbol` (optional): market for price input. - `timeframe` (optional): computation timeframe. ### `[[highest]]` Purpose: Computes the highest value of a series over a window. Doc: https://whale-e.com/documentation/blocks/indicator/highest/ Keys: - `id` (required): output series name. - `source` (optional): input series. Default `high`. - `length` (required): lookback window, fixed or range, `1..10000`. - `symbol` (optional): market for price input. - `timeframe` (optional): computation timeframe. ### `[[highestbars]]` Purpose: Returns the negative bar offset to the oldest highest value in a window; `0` means current candle. Doc: https://whale-e.com/documentation/blocks/indicator/highest-bars-highestbars/ Keys: - `id` (required): output series name. - `source` (optional): input series. Default `high`. - `length` (required): lookback window, fixed or range, `1..10000`. - `symbol` (optional): market for price input. - `timeframe` (optional): computation timeframe. ### `[[iii]]` Purpose: Computes Intraday Intensity Index: `(2*close - high - low) / ((high - low) * volume)`, returning `NaN` when the denominator is zero or inputs are unavailable. Doc: https://whale-e.com/documentation/blocks/indicator/intraday-intensity-index-iii/ Keys: - `id` (required): III output series name. - `symbol` (optional): market for OHLCV input. - `timeframe` (optional): computation timeframe. ### `[[kc]]` Purpose: Computes Keltner Channels: middle = `EMA(source,length)`, upper/lower = `middle +/- multiplier * EMA(range,length)`. Doc: https://whale-e.com/documentation/blocks/indicator/keltner-channels-kc/ Keys: - `upper_id` (required): upper channel output series name. - `middle_id` (required): middle EMA output series name. - `lower_id` (required): lower channel output series name. - `source` (optional): input series for the middle line. Default `close`. - `length` (optional): EMA/range window, fixed or range, `1..10000`. Default `20`. - `multiplier` (optional): positive range multiplier, fixed or range. Default `2.0`. - `use_true_range` (optional): true uses True Range, false uses high-low. Default `true`. - `symbol` (optional): market for range prices and standard-source input. - `timeframe` (optional): computation timeframe. ### `[[kcw]]` Purpose: Computes Keltner Channel Width: `(2 * multiplier * EMA(range,length)) / EMA(source,length)`, returning `NaN` when the middle line is zero. Doc: https://whale-e.com/documentation/blocks/indicator/keltner-channels-width-kcw/ Keys: - `id` (required): KCW output series name. - `source` (optional): input series for the middle line. Default `close`. - `length` (optional): EMA/range window, fixed or range, `1..10000`. Default `20`. - `multiplier` (optional): positive range multiplier, fixed or range. Default `2.0`. - `use_true_range` (optional): true uses True Range, false uses high-low. Default `true`. - `symbol` (optional): market for range prices and standard-source input. - `timeframe` (optional): computation timeframe. ### `[[kijun_sen]]` Purpose: Fixed Donchian midpoint alias: `(highest(high, 26) + lowest(low, 26)) / 2`, offset `0`; no `source`, `length`, or `offset` key. Doc: https://whale-e.com/documentation/blocks/indicator/ichimoku-kijun-sen/ Keys: - `id` (required): Kijun-sen output series name. - `symbol` (optional): market for high/low input. - `timeframe` (optional): computation timeframe. ### `[[linreg]]` Purpose: Computes linear regression over a series. Doc: https://whale-e.com/documentation/blocks/indicator/linear-regression-linreg/ Keys: - `id` (required): linear regression output series name. - `source` (optional): input series. Default `close`. - `length` (required): regression window, fixed or range, `1..10000`. - `offset` (optional): integer/range evaluation offset. Default `0`; positive reads earlier on the fitted line, negative projects forward. - `symbol` (optional): market for price input. - `timeframe` (optional): computation timeframe. ### `[[lowest]]` Purpose: Computes the lowest value of a series over a window. Doc: https://whale-e.com/documentation/blocks/indicator/lowest/ Keys: - `id` (required): output series name. - `source` (optional): input series. Default `low`. - `length` (required): lookback window, fixed or range, `1..10000`. - `symbol` (optional): market for price input. - `timeframe` (optional): computation timeframe. ### `[[lowestbars]]` Purpose: Returns the negative bar offset to the oldest lowest value in a window; `0` means current candle. Doc: https://whale-e.com/documentation/blocks/indicator/lowest-bars-lowestbars/ Keys: - `id` (required): output series name. - `source` (optional): input series. Default `low`. - `length` (required): lookback window, fixed or range, `1..10000`. - `symbol` (optional): market for price input. - `timeframe` (optional): computation timeframe. ### `[[ma]]` Purpose: Computes a moving average. Doc: https://whale-e.com/documentation/blocks/indicator/moving-averages-ma/ Keys: - `id` (required): moving-average output series name. - `source` (optional): input series. Default `close`. - `type` (required): moving-average type: `sma`, `ema`, `wma`, `hma`, `dema`, `tema`, `trima`, `smma`, `zlema`, or `rma`; can be an array. - `length` (required): lookback window, fixed or range, `1..10000`. - `offset` (optional): non-negative output shift, fixed or range. Default `0`. - `symbol` (optional): market for price input. - `timeframe` (optional): computation timeframe. ### `[[macd]]` Purpose: Computes MACD, and optionally Signal and Histogram series. Doc: https://whale-e.com/documentation/blocks/indicator/moving-average-convergence-divergence-macd/ Keys: - `macd_id` (required): MACD line output series name. - `signal_id` (optional): Signal line output series name. - `hist_id` (optional): Histogram output series name; valid only with `signal_id`. - `source` (optional): input series. Default `close`. - `fast` (optional): fast MA length, fixed or range, `2..10000`. Default `12`. - `slow` (optional): slow MA length, fixed or range, `2..10000`; must be greater than `fast` for generated pairs. Default `26`. - `signal` (conditional): Signal MA length, fixed or range, `1..10000`; only allowed when `signal_id` exists. Default `9`. - `macd_type` (optional): MA type for fast/slow MACD line, same allowed values as `[[ma]]`, string or unique array. Default `ema`. - `signal_type` (conditional): MA type for Signal line, same allowed values as `[[ma]]`, string or unique array; only allowed when `signal_id` exists. Default `ema`. - `symbol` (optional): market for price input. - `timeframe` (optional): computation timeframe. ### `[[median]]` Purpose: Computes rolling median; even windows average the two middle values, and `NaN` inputs are skipped until enough valid values exist. Doc: https://whale-e.com/documentation/blocks/indicator/median-median/ Keys: - `id` (required): median output series name. - `source` (optional): input series. Default `close`. - `length` (required): rolling window, fixed or range, `1..10000`. - `symbol` (optional): market for price input. - `timeframe` (optional): computation timeframe. ### `[[mfi]]` Purpose: Computes Money Flow Index. Doc: https://whale-e.com/documentation/blocks/indicator/money-flow-index-mfi/ Keys: - `id` (required): MFI output series name. - `source` (optional): input series used with implicit volume. Default `hlc3`. - `length` (required): observation window, fixed or range, `1..10000`. - `symbol` (optional): market for price/volume input. - `timeframe` (optional): computation timeframe. ### `[[mode]]` Purpose: Computes rolling statistical mode; ties return the smallest value, and `NaN` inputs are skipped until enough valid values exist. Doc: https://whale-e.com/documentation/blocks/indicator/mode-mode/ Keys: - `id` (required): mode output series name. - `source` (optional): input series. Default `close`. - `length` (required): rolling window, fixed or range, `1..10000`. - `symbol` (optional): market for price input. - `timeframe` (optional): computation timeframe. ### `[[mom]]` Purpose: Computes momentum as a lagged difference. Doc: https://whale-e.com/documentation/blocks/indicator/momentum-mom/ Keys: - `id` (required): momentum output series name. - `source` (optional): input series. Default `close`. - `length` (required): lag in candles, fixed or range, `1..10000`. - `symbol` (optional): market for price input. - `timeframe` (optional): computation timeframe. ### `[[pli]]` Purpose: Computes a percentile by linear interpolation over a rolling window. Doc: https://whale-e.com/documentation/blocks/indicator/percentile-linear-interpolation-pli/ Keys: - `id` (required): percentile output series name. - `source` (optional): input series. Default `close`. - `length` (required): rolling window, fixed or range, `1..10000`. - `percentage` (required): percentile from `0` to `100`, fixed or range. - `symbol` (optional): market for price input. - `timeframe` (optional): computation timeframe. ### `[[price]]` Purpose: Exposes a selected price source as a named series. Doc: https://whale-e.com/documentation/blocks/indicator/price/ Keys: - `id` (required): output price series name. - `source` (optional): standard price source string or array: `open`, `high`, `low`, `close`, `hl2`, `hlc3`, `ohlc4`, `hlcc4`, or `volume`. Default `close`. - `symbol` (optional): market for the price source. - `timeframe` (optional): candle timeframe for the price source. ### `[[rising]]` Purpose: Outputs `1.0` when the source has strictly risen across the last `length` valid comparisons, otherwise `0.0`. Doc: https://whale-e.com/documentation/blocks/indicator/rising/ Keys: - `id` (required): boolean/numeric output series name. - `source` (optional): input series. Default `close`. - `length` (required): number of rising comparisons, fixed or range, `1..10000`. - `symbol` (optional): market for price input. - `timeframe` (optional): computation timeframe. ### `[[roc]]` Purpose: Computes Rate of Change: `((source - source[length]) / source[length]) * 100`. Doc: https://whale-e.com/documentation/blocks/indicator/rate-of-change-roc/ Keys: - `id` (required): ROC output series name. - `source` (optional): input series. Default `close`. - `length` (optional): lag in candles, fixed or range, `1..10000`. Default `9`. - `symbol` (optional): market for price input. - `timeframe` (optional): computation timeframe. ### `[[rsi]]` Purpose: Computes Relative Strength Index on a 0-100 scale. Doc: https://whale-e.com/documentation/blocks/indicator/relative-strength-index-rsi/ Keys: - `id` (required): RSI output series name. - `source` (optional): input series. Default `close`. - `length` (optional): RSI window, fixed or range, `2..10000`. Default `14`. - `symbol` (optional): market for price input. - `timeframe` (optional): computation timeframe. ### `[[sar]]` Purpose: Computes Parabolic SAR. No `source` key is accepted; this block always uses high, low, and close. Doc: https://whale-e.com/documentation/blocks/indicator/parabolic-sar-sar/ Keys: - `id` (required): SAR output series name. - `start` (optional): positive initial acceleration factor, fixed or range. Default `0.02`. - `increment` (optional): positive acceleration increment, fixed or range. Default `0.02`. - `max_value` (optional): positive maximum acceleration factor, fixed or range. Default `0.2`. - `symbol` (optional): market for high/low/close input. - `timeframe` (optional): computation timeframe. ### `[[senkou_span_a]]` Purpose: Computes Ichimoku Senkou Span A from high/low only: `((Tenkan + Kijun) / 2)` shifted by `offset`. No `source` key is accepted. Doc: https://whale-e.com/documentation/blocks/indicator/ichimoku-senkou-span-a/ Keys: - `id` (required): Senkou Span A output series name. - `tenkan_length` (optional): Tenkan window, fixed or range, `1..10000`. Default `9`. - `kijun_length` (optional): Kijun window, fixed or range, `1..10000`. Default `26`. - `offset` (optional): non-negative forward projection offset, fixed or range. Default `26`. - `symbol` (optional): market for high/low input. - `timeframe` (optional): computation timeframe. ### `[[senkou_span_b]]` Purpose: Fixed Donchian midpoint alias: `(highest(high, 52) + lowest(low, 52)) / 2`, offset `26`; no `source`, `length`, or `offset` key. Doc: https://whale-e.com/documentation/blocks/indicator/ichimoku-senkou-span-b/ Keys: - `id` (required): Senkou Span B output series name. - `symbol` (optional): market for high/low input. - `timeframe` (optional): computation timeframe. ### `[[stdev]]` Purpose: Computes rolling standard deviation. Doc: https://whale-e.com/documentation/blocks/indicator/standard-deviation-stdev/ Keys: - `id` (required): standard deviation output series name. - `source` (optional): input series. Default `close`. - `length` (required): rolling window, fixed or range; `>= 1` when `biased = true`, `>= 2` when `biased = false`. - `biased` (optional): `true` for population stdev, `false` for sample stdev. Default `true`. `NaN` source values are skipped until enough valid samples exist. - `symbol` (optional): market for price input. - `timeframe` (optional): computation timeframe. ### `[[stoch]]` Purpose: Computes %K = `100 * (close - lowest(low,k_length)) / (highest(high,k_length) - lowest(low,k_length))`; %D = `SMA(%K,d_length)`. No `source` key is accepted. Doc: https://whale-e.com/documentation/blocks/indicator/stochastic-oscillator-stoch/ Keys: - `k_id` (required): %K output series name. - `d_id` (required): %D output series name. - `k_length` (optional): stochastic window, fixed or range, `1..10000`. Default `14`. - `d_length` (optional): %K smoothing window for %D, fixed or range, `1..10000`. Default `3`. - `symbol` (optional): market for high/low/close input. - `timeframe` (optional): computation timeframe. ### `[[stoch_rsi]]` Purpose: Computes `RSI(source,rsi_length)`, applies stochastic over `stoch_length`, then SMA `smooth_k` for %K and SMA `smooth_d` for %D. Doc: https://whale-e.com/documentation/blocks/indicator/stochastic-rsi-stoch_rsi/ Keys: - `k_id` (required): %K output series name. - `d_id` (required): %D output series name. - `source` (optional): input series for RSI. Default `close`. - `rsi_length` (optional): internal RSI window, fixed or range, `2..10000`. Default `14`. - `stoch_length` (optional): stochastic window applied to RSI, fixed or range, `1..10000`. Default `14`. - `smooth_k` (optional): smoothing length for %K, fixed or range, `1..10000`. Default `3`. - `smooth_d` (optional): smoothing length for %D, fixed or range, `1..10000`. Default `3`. - `symbol` (optional): market for price input. - `timeframe` (optional): computation timeframe. ### `[[supertrend]]` Purpose: Computes an ATR-based SuperTrend line and optional direction series. No `source` key is accepted; this block always uses high, low, and close. Doc: https://whale-e.com/documentation/blocks/indicator/supertrend/ Keys: - `id` (required): SuperTrend line output series name. - `direction_id` (optional): direction output series name; `1` = downtrend, `-1` = uptrend. - `length` (optional): ATR window, fixed or range, `1..10000`. Default `10`. - `factor` (optional): positive ATR multiplier, fixed or range. Default `3.0`. - `symbol` (optional): market for high/low/close input. - `timeframe` (optional): computation timeframe. ### `[[tenkan_sen]]` Purpose: Fixed Donchian midpoint alias: `(highest(high, 9) + lowest(low, 9)) / 2`, offset `0`; no `source`, `length`, or `offset` key. Doc: https://whale-e.com/documentation/blocks/indicator/ichimoku-tenkan-sen/ Keys: - `id` (required): Tenkan-sen output series name. - `symbol` (optional): market for high/low input. - `timeframe` (optional): computation timeframe. ### `[[variance]]` Purpose: Computes rolling variance. Doc: https://whale-e.com/documentation/blocks/indicator/variance/ Keys: - `id` (required): variance output series name. - `source` (optional): input series. Default `close`. - `length` (required): rolling window, fixed or range; `>= 1` when `biased = true`, `>= 2` when `biased = false`. - `biased` (optional): `true` for population variance, `false` for sample variance. Default `true`. `NaN` source values are skipped until enough valid samples exist. - `symbol` (optional): market for price input. - `timeframe` (optional): computation timeframe. ### `[[vwap]]` Purpose: Computes a cumulative volume-weighted average from a daily UTC anchor or a custom reset series. Doc: https://whale-e.com/documentation/blocks/indicator/volume-weighted-average-price-vwap/ Keys: - `id` (required): VWAP output series name. - `source` (optional): numeric series to weight by volume, string or array. Default `hlc3`. - `anchor` (optional): reset-series id, string or array; `0` and `NaN` are false, any other value starts a new cumulative period on that candle. Omitted or empty uses a daily UTC anchor. - `symbol` (optional): market providing standard price sources and implicit volume. - `timeframe` (optional): timeframe used to align the source, implicit volume, and anchor. The `volume` key is not accepted; volume is read implicitly from the selected market. With a custom anchor, output is `NaN` until the first trigger. A later `NaN` source or volume keeps the cumulative state at `NaN` until the next anchor.