Language Overview¶
PalmScript scripts are top-level source files made of declarations and statements.
Common building blocks:
interval <...>for the base execution clocksourcedeclarations for market-backed series- separate
executiondeclarations for order-routing targets - optional supplemental
use <alias> <interval>declarations - top-level functions
let,const,input, tuple destructuring,export,regime,trigger,entry/exit, andorder- compile-time portfolio declarations such as
max_positions = 2andportfolio_group "majors" = [left, right] - optional
input ... optimize(...)metadata for optimizer search-space inference - declarative backtest controls such as
cooldown long = 12andmax_bars_in_trade short = 48 if / else if / else- expressions built from operators, calls, and indexing
- helper builtins such as
crossover,state,activated,barssince, andvaluewhen - typed
ma_type.<variant>,tif.<variant>,trigger_ref.<variant>,position_side.<variant>, andexit_kind.<variant>enum literals
Script Shape¶
Executable PalmScript scripts name data sources explicitly:
interval 1m
source bn = binance.spot("BTCUSDT")
source bb = bybit.usdt_perps("BTCUSDT")
execution exec = bybit.usdt_perps("BTCUSDT")
plot(bn.close - bb.close)
Mental Model¶
- every script has one base interval
- executable scripts declare one or more
sourcebindings - scripts may also declare one or more
executionbindings for order routing without exposing new market series - market series are always source-qualified
- series values evolve over time
- higher intervals update only when those candles fully close
- missing history or missing aligned source data appears as
na plot,export,regime,trigger, and strategy declarations emit results after each execution step- optimizer-aware
inputdeclarations can carry bounded integer, float, or choice search metadata without changing runtime semantics cooldownandmax_bars_in_tradeare compile-time bar-count declarations that make re-entry and time-based exits explicit in the script- portfolio declarations are compile-time only and become active when backtest-oriented CLI commands receive multiple
--execution-sourcealiases - order declarations can target a declared execution binding with named arguments such as
venue = execorvenue = current_execution() - portfolio mode shares one equity ledger across the selected execution aliases by default and blocks only the new entries that would exceed the configured position-count or exposure caps
--spot-virtual-rebalanceswitches multi-venue spot portfolio runs to long/flat per-alias quote-wallet accounting with automatic quote transfers before long entries
Where To Go For Exact Rules¶
- syntax and tokens: Lexical Structure and Grammar
- declarations and visibility: Declarations and Scope
- expressions and semantics: Evaluation Semantics
- market series rules: Intervals and Sources
- indicators and helper builtins: Indicators and Builtins
- outputs: Outputs