本文へ移動

仕組み

ADR-0016: `switch` and `off` on `@param`: a flag and a filter that can be seen to be on or off

これらのページは英語です。仕様は一つの言語で保つことで、一つのことだけを語ります。

Status: accepted (2026-10-24)

Context#

ADR-0015 let a strategy parameter say how far an optimizer may move it. Strategies also have parameters that are not quantities to tune but switches: whether to close when the target turns against the position (1 or 0), which kind of stop to use, or a filter that a value of 0 removes (an ATR ceiling, a minimum target distance). The terminal showed all of them as a text box holding a number, so a person could not tell at a glance what was on, and an optimizer that was asked to search a filter's range had no way to say "or off".

Decision#

  • switch: true on an Int parameter: it is 1 (on) or 0 (off). It stands for min: 0, max: 1, step: 1 and takes no min, max, step, log or off; on any other kind it is E-DECO-VALUE. A host shows it as a checkbox. The contract needs nothing new for it: a parameter whose range is the whole numbers 0 to 1 is a switch, which a host can tell.
  • off: N on a parameter that has a range (a whole number for an Int): the value that means "this filter is off". It lies outside the range the optimizer moves the parameter in (a ceiling searched between 100 and 2000 is off at 0). A host shows a checkbox beside the value and sends N when it is unticked. The signal graph carries it as ParamTune.off, written only when present; IR 0.1.5 → 0.1.6 because an older reader would drop the field.
  • Both are advice to a host, like every other key: the compiler does nothing else with them, and a program with them and the same program without them are the same strategy. They need language 0.2 like the rest of @param.

Alternatives#

  • A Bool parameter type. The honest way to say a flag, but it adds a type to the strategy parameters, to the host API's argument kinds, and to every place that translates a strategy; for a flag the optimizer never needs more than 0 and 1.
  • An enabled key on every decorated parameter. Would have meant two values per parameter in the contract; off keeps one value and says which one stands for "not used".
  • Reading 0 as "off" by convention. Works for ceilings and minimums, not for a parameter where 0 is a real setting; the author says it.

Consequences#

  • The Backtests window can draw a checkbox for a switch and a checkbox beside a filter's value, and say in one line what is active.
  • An optimizer can search a switch (try it on and off) or a filter's range with the filter on; whether the filter is on at all is the person's choice.
  • An older reader of an artifact that uses off ignores the field and treats the value as a plain number: the strategy still runs as written.