Portfolio & Trading Indicators
Indicators for portfolio value, positions, orders, and trading state.
Portfolio & Trading Indicators
Indicators that reference your portfolio state, positions, orders, and time. These let you build strategies that adapt based on what you own and what you've done.
Portfolio-Level Indicators
Portfolio Value
The total current value of your portfolio (cash + all positions).
- Parameters: None
- Range: >= 0
- Example condition:
Portfolio Value > 50000 (Portfolio has grown past $50K)
Buying Power
The amount of cash available to make new purchases.
- Parameters: None
- Range: >= 0
- Example condition:
Buying Power > 1000 (Ensure at least $1K available before buying)
Initial Value
The starting value of the portfolio when it was created or when the backtest began.
- Parameters: None
- Range: > 0
- Example condition:
Portfolio Value > Initial Value * 1.1 (Portfolio is up 10% from start)
Prospective Rebalance Decision Metric
Exposes the allocation plan that a DynamicRebalance or RebalanceOption action is about to execute, so the strategy condition can decide whether that plan is worthwhile.
- Parameters: Metric: Allocation Drift, Planned Turnover, Estimated Cost, Expected Benefit, or Net Benefit
- Range: Drift and turnover are portfolio fractions; cost and benefit metrics are dollar amounts
- Example condition:
Rebalance Expected Benefit > Rebalance Estimated Cost (execute only when the prospective allocation improvement exceeds estimated trading cost)
Tip: This indicator is evaluated against the prospective plan inside DynamicRebalance and RebalanceOption. It returns zero in other action contexts.
Position Indicators
Position Value
The current dollar value of your position in one or more assets.
- Parameters: Asset(s)
- Range: >= 0
- Example condition:
Position Value(AAPL) > 10000 (Apple position is worth more than $10K)
Position Percent Change
How much your position has gained or lost as a percentage since you opened it.
- Parameters: Asset(s)
- Range: Unbounded (percentage)
- Example condition:
Position Percent Change(TSLA) > 20 (Take profits when position is up 20%)
Position Max Drawdown
The maximum percentage decline in the position's unrealized P&L from its peak. Aggregates the stock or crypto holding plus all option spreads on that underlying. Returns 0 at a new high water mark; rises as P&L falls below the peak, so it is never negative.
- Parameters: Asset
- Range: >= 0 (percentage points of P&L)
- Example condition:
Position Max Drawdown(NVDA) > 25 (the aggregate position P&L is more than 25 percentage points below its observed peak)
Underlying Max Drawdown
The current percentage decline of the asset's market price from the highest price observed by this indicator. Tracks the underlying price independently of position state.
- Parameters: Asset
- Range: 0 to 100 (percentage)
- Example condition:
Underlying Max Drawdown(NVDA) >= 20 (true when the price is at least 20% below its observed peak)
Position Max Drawup
The percentage increase of the asset's current market price from the lowest price observed by this indicator. Share purchases and sales do not change the calculation; it does not use position cost basis.
- Parameters: Asset
- Range: >= 0 (percentage)
- Example condition:
Position Max Drawup(AAPL) > 25 (the market price is more than 25% above the lowest price observed by this indicator)
Order Indicators
Days Since Order
The number of days since the most recent order matching the specified filters.
- Parameters: Asset(s), Side (Buy/Sell), Order Status (Filled/Canceled/Pending/Accepted)
- Range: >= 0 (days), or a large number if no matching order exists
- Example condition:
Days Since Order(AAPL, Buy, Filled) > 14 (Haven't bought Apple in the last 2 weeks — prevents over-trading)
Days Since Option Order
The number of days since the most recent option order matching the specified filters. Supports filtering by underlying, option type (call/put), spread type, direction (debit/credit), position effect (open/close), and days to expiration at order time.
- Parameters: Underlying, Option Type (Call/Put), Direction (Long/Short), Spread Type, Position Effect (Open/Close), Min DTE, Max DTE, Order Status
- Range: >= 0 (days), or a large number if no matching order exists
- Example condition:
Days Since Option Order(SPY, Call, Open, Vertical, Long, 10-30 DTE, Filled) > 7 (Haven't opened a SPY call debit spread in the last week)
Days Since Strategy Fired
The number of days since the current strategy last produced an execution artifact. Counts same-strategy order rows, rebalance orders, and launched agents.
- Parameters: None
- Range: >= 0 (days), or a large number if the strategy has never fired
- Example condition:
Days Since Strategy Fired > 7 (cool down this strategy after any action it triggers)
Days Since Last RebalanceOption Order
Elapsed days since the latest Filled-matching portfolio order stamped RebalanceOption, RebalanceOptionRenewal or RebalanceOptionFunding. It uses fill time and ignores strategy ID, so these strategies share a cooldown. Unfilled or canceled orders do not reset it.
- Parameters: None
- Range: >= 0 (days), or a large number if no RebalanceOption-generated order exists
- Example condition:
Days Since Last RebalanceOption Order > 10 (cool down the whole option book after any rebalance-option order)
Minutes Since Option Order
The number of minutes since the most recent option order matching the specified filters. Same filters as Days Since Option Order but measured in minutes for intraday strategies.
- Parameters: Underlying, Option Type (Call/Put), Direction (Long/Short), Spread Type, Position Effect (Open/Close), Min DTE, Max DTE, Order Status
- Range: >= 0 (minutes), or a large number if no matching order exists
- Example condition:
Minutes Since Option Order(SPY, Put, Open, Vertical, Short, 30-60 DTE, Filled) < 30 (Opened a SPY put credit spread in the last 30 minutes)
Minutes Since Order
Same as Days Since Order but measured in minutes. Useful for intraday strategies.
- Parameters: Asset(s), Side, Order Status
- Range: >= 0 (minutes)
- Example condition:
Minutes Since Order(SPY, Buy, Filled) > 60 (Wait at least 1 hour between buys)
Last Order Price
The execution price of the most recent order matching the specified filters.
- Parameters: Asset, Side, Order Status
- Range: > 0
- Example condition:
Price(AAPL) < Last Order Price(AAPL, Buy, Filled) * 0.95 (Price has dropped 5% below last buy — consider averaging down)
Sum Order Quantity
The total number of shares across all matching orders within a window.
- Parameters: Asset(s), Window (lookback period), Side, Order Status
- Range: >= 0
- Example condition:
Sum Order Quantity(AAPL, 30 days, Buy, Filled) < 100 (Limit total shares bought per month)
Sum Order Amount
The total dollar amount across all matching orders within a window.
- Parameters: Asset(s), Window (lookback period), Side, Order Status
- Range: >= 0
- Example condition:
Sum Order Amount(*, 7 days, Buy, Filled) < 5000 (Cap weekly spending at $5K)
Transaction & Alert Indicators
Days Since Alert
The number of days since an alert was triggered. Useful for rate-limiting alerts.
- Parameters: Message (optional — match a specific alert message)
- Range: >= 0
- Example condition:
Days Since Alert > 1 (Don't fire the same alert more than once per day)
Days Since Agent
The number of days since an AI agent was launched by this strategy. Useful for rate-limiting agent launches.
- Parameters: None
- Range: >= 0
- Example condition:
Days Since Agent > 7 (Don't launch a new agent more than once per week)
Minutes Since Agent
The number of minutes since an AI agent was launched by this strategy. Useful for fine-grained rate-limiting of agent launches within a single day.
- Parameters: None
- Range: >= 0
- Example condition:
Minutes Since Agent > 60 (Don't launch a new agent more than once per hour)
Minutes Since Alert
The number of minutes since an alert was triggered. Useful for fine-grained rate-limiting of alerts within a single day.
- Parameters: Message (optional — match a specific alert message)
- Range: >= 0
- Example condition:
Minutes Since Alert > 60 (Don't fire the same alert more than once per hour)
Time & Date Indicators
Day
The weekday in America/New_York: Monday = 1 through Sunday = 7. Use Date for the day of the month.
- Parameters: None
- Example condition:
Day = 1 (Monday). Use Date = 1 for the first calendar day of a month, and add a cooldown to prevent repeated orders.
Month
The current month (1–12).
- Parameters: None
- Example condition:
Month = 1 (January effect — rebalance at the start of the year)
Year
The current year.
- Parameters: None
- Example condition:
Year >= 2025
Date
The day of the month in America/New_York, from 1 through 31. Combine with Month and Year for a specific calendar date.
Current Time (Hours)
Hours since midnight in America/New_York time, including fractional hours. For example, 9:30 AM returns 9.5. Daylight saving time is handled automatically.
- Parameters: None
- Example condition:
Current Time Hours >= 10 (Don't trade before 10 AM ET)
Current Time (Minutes)
Minutes since midnight in America/New_York time, including fractional minutes. For example, 9:30 AM returns 570. Daylight saving time is handled automatically.
Current Time (Seconds)
Seconds since midnight in America/New_York time, including fractions of a second. For example, 9:30 AM returns 34200. Daylight saving time is handled automatically.
Current Timestamp
The current market observation time in Unix seconds, including fractions. Unlike CurrentTimeSeconds (seconds since Eastern midnight), this absolute clock continues across dates. In a backtest it is simulation time; in paper and live trading it is the market evaluation time.
- Parameters: None
- Example condition: CurrentTimestamp() - ChartBar(..., endTime) measures a completed candle's age in seconds.
Tip: For intraday time-based conditions, consider using Minutes After Open and Minutes Until Close instead — they're relative to market hours and more intuitive.