RC2_IND_ON
תוכן זה אינו זמין עדיין בשפה שלך.
Indicator
<name>requires anon=keyword — no trade symbol is declared to default to.
What it means
on= names the series an indicator consumes. It is optional: when you leave it out, the indicator defaults to the close of the strategy’s trading symbol, which is why RSI(14) and RSI(14, on=self.trade) mean the same thing in a single-symbol strategy.
RC2_IND_ON is the guard on that default — it fires when an indicator omits on= and there is no trading symbol for the default to point at.
Why it happens
A strategy with no Symbol() at all is the shape this guard was written for. In practice you will never see this code for it, because the missing symbol is refused earlier, by RC2_NO_SYMBOL, before execute() is even parsed:
class Bad(Strategy): sizing = FixedCapital()
def execute(self): sma = SMA(20) # ❌ nothing to default on= to if sma.value > 0: returnSo RC2_IND_ON is best read as documentation of the rule rather than a message you should expect in the editor: an indicator always resolves to a concrete series, and the trade symbol is the only thing the language will supply for you. If you ever do see it, the fix is the same as for RC2_NO_SYMBOL.
How to fix it
Declare the trading symbol — then on= becomes optional again.
class Good(Strategy): trade = Symbol() sizing = FixedCapital()
def execute(self): sma_default = SMA(20) # the trade symbol's close sma_spelled = SMA(20, on=self.trade) # the same thing, said out loud if sma_default.value > 0 and sma_spelled.value > 0 and self.trade.is_flat: self.buy(self.trade)Writing on= explicitly is recommended even when it is optional — a reader (or a future you) should not have to know the defaulting rule to know what an indicator is measuring.
Related
- Indicators
- Symbols
RC2_NO_SYMBOL— the diagnostic you actually get for a strategy with noSymbol().RC2_IND_ON_UNKNOWN—on=is present but names something that was never declared.RC2_IND_ON_SOURCE—on=is present but is not a symbol, a field, or an indicator.