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 holding plus all option spreads on that underlying. Returns 0 at a new high water mark; rises as P&L falls below the peak.
- Parameters: Asset
- Range: >= 0 (percentage points of P&L)
- Example condition:
Position Max Drawdown(NVDA) > 25 (Stop-loss: exit when the NVDA position has given back 25% of its peak P&L)
Underlying Max Drawdown
The maximum percentage decline of the asset's market PRICE from its peak since the indicator started observing. Tracks the underlying stock — does NOT consult position state. Useful as an emergency exit when the asset itself crashes, regardless of how the position is performing.
- Parameters: Asset
- Range: 0 to 100 (percentage)
- Example condition:
Underlying Max Drawdown(NVDA) > 20 (Close NVDA exposure when the stock is 20% off its peak)
Position Max Drawup
The maximum percentage increase from trough price since you entered the position.
- Parameters: Asset
- Range: >= 0 (percentage)
- Example condition:
Position Max Drawup(AAPL) > 25 (Position has rallied 25% from its lowest point since entry)
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
The number of days since the portfolio last emitted an order from any RebalanceOption strategy. Ignores strategy ID so multiple RebalanceOption strategies can share one cooldown.
- 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 current day of the month (1–31).
- Parameters: None
- Example condition:
Day = 1 (Execute on the first of each month — useful for DCA strategies)
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 current date as a numeric value. Useful for scheduling strategies around specific dates.
Current Time (Hours)
The current hour in Eastern Standard Time (0–23).
- Parameters: None
- Example condition:
Current Time Hours >= 10 (Don't trade before 10 AM ET)
Current Time (Minutes)
The current minutes since midnight in Eastern Standard Time.
Current Time (Seconds)
The current seconds since midnight in Eastern Standard Time.
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.