RC2_IND_NO_COMPUTE
תוכן זה אינו זמין עדיין בשפה שלך.
Indicator class must define a
compute(self, ...)method.
What it means
compute() is the indicator. Everything else in the class — Param(), Series(), position, state defaults — only describes the machinery; compute() is the one thing that turns a bar into a number.
The platform calls it once per bar and stores what it returns, so a class without it has nothing to store and nothing to plot. There is no default implementation to fall back on.
Why it happens
The usual cause is a class that was written top-down and stopped at the declarations:
class MySMA(Indicator): position = ON_CHART period = Param(20, min=2, max=200) buffer = Series(period)The other cause is a misspelling. The name is matched exactly — Compute, calculate, compute_value and __call__ are all “not compute”, and a class carrying only those gets this error (plus RC2_IND_METHOD for the stray method).
How to fix it
Add compute(self, ...), taking the bar fields it needs and returning the value.
class MySMA(Indicator): position = ON_CHART period = Param(20, min=2, max=200) buffer = Series(period)
def compute(self, close): self.buffer.add(close) return sum(self.buffer) / len(self.buffer)The parameters after self are the bar fields you want — any non-empty subset of close, open, high, low, volume, in any order. The platform feeds only what you ask for.
Related
- Custom Indicators
RC2_IND_COMPUTE_SIG—compute()exists, but its parameters are not bar fields.RC2_IND_METHOD— the class declares a method that is notcompute().RC2_IND_COMPUTE—compute()exists, but its body uses something unsupported.