דלגו לתוכן
פתיחת RaamTrade

RC2_IND_PARAM

תוכן זה אינו זמין עדיין בשפה שלך.

Param <name> requires a default value, and that default must be a literal.

What it means

A Param() in an indicator is declared with its default first and positionally: Param(20, min=2, max=200). The default is not optional and not a keyword.

Two reasons it has to be there, and has to be a constant. First, the default is the value the indicator computes with when nobody overrides it — a chart pane that drops MySMA on a symbol has no form to fill in. Second, the default is read at compile time to size buffers and the warmup floor, so it must be knowable without running anything.

Why it happens

Bounds without a default — min= looks like it supplies one, but it does not:

class MySMA(Indicator):
position = ON_CHART
period = Param(min=2, max=200) # ❌ no default
buffer = Series(period)
def compute(self, close):
self.buffer.add(close)
return sum(self.buffer) / len(self.buffer)

A default that is not a constant — a name, an expression, or a call:

class MySMA(Indicator):
position = ON_CHART
default_period = 20
period = Param(default_period) # ❌ default must be a literal
buffer = Series(period)
def compute(self, close):
self.buffer.add(close)
return sum(self.buffer) / len(self.buffer)

How to fix it

Put a literal in the first position. Negative and decimal literals are fine (Param(-1.5), Param(0.02)). A number — an indicator’s parameter values ride the chart’s numeric wire, so a True/False or a text default is refused separately by RC2_IND_PARAM_KIND.

class MySMA(Indicator):
position = ON_CHART
period = Param(20, min=2, max=200)
threshold = Param(0.5, min=0.0, max=1.0)
buffer = Series(period)
def compute(self, close):
self.buffer.add(close)
average = sum(self.buffer) / len(self.buffer)
return average * self.threshold

min= and max= stay optional — they bound the slider the user sees and the range the optimizer sweeps, but they never stand in for the default.

  • Param()
  • Custom Indicators
  • RC2_IND_BODY — the assignment is not a Param() (or Series(), child indicator, or literal) at all.
  • RC2_IND_PARAM_KIND — the default IS a literal, but not a number.
  • RC2_PARAM_DEFAULT — the same rule for a Param() in a strategy class body.