RC2_IND_ON_UNKNOWN
Indicator
<name>on=references a Symbol slot — or an indicator — that was never declared.
What it means
on= is resolved at compile time against two lists: the Symbol() slots in the class body, and the indicators already declared above it in execute(). A name in neither list is an error, not an empty series.
The “above it” part matters. Indicators are hoisted in source order, so a chain can only ever point backwards — on= is resolved against what has been declared so far, which is what makes the dependency order unambiguous and cycle-free.
Why it happens
A Symbol slot that isn’t there — usually a slot renamed in the class body but not in execute():
class Bad(Strategy): trade = Symbol() sizing = FixedCapital()
def execute(self): spy_sma = SMA(20, on=self.spy) # ❌ no Symbol named spy if spy_sma.value > 0 and self.trade.is_flat: self.buy(self.trade)A chain declared in the wrong order — the source indicator exists, but below the one that reads it:
class Bad(Strategy): trade = Symbol() sizing = FixedCapital()
def execute(self): smooth = EMA(5, on=rsi) # ❌ rsi is declared on the NEXT line rsi = RSI(14, on=self.trade) if smooth.value > 50 and self.trade.is_flat: self.buy(self.trade)How to fix it
Declare the thing you are pointing at — a Symbol() in the class body for a feed, or the source indicator earlier in execute() for a chain.
class Good(Strategy): trade = Symbol(trade=True) spy = Symbol(ticker="SPY") sizing = FixedCapital()
def execute(self): spy_sma = SMA(20, on=self.spy) # ✅ spy is a declared slot rsi = RSI(14, on=self.trade) smooth = EMA(5, on=rsi) # ✅ rsi is declared above
if self.spy.close > spy_sma and smooth.value > 50 and self.trade.is_flat: self.buy(self.trade, percent=0.5)A second Symbol() is a data feed: the strategy reads it but never trades it. With more than one slot, exactly one must be marked trade=True.
Related
- Indicators
- Symbols
RC2_IND_CYCLE— the name resolves, but to the indicator being declared.RC2_IND_ON_FIELD— the slot resolves, the OHLCV field after it does not.RC2_NO_TRADE— several slots declared and none markedtrade=True.