구조
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: trueon anIntparameter: it is1(on) or0(off). It stands formin: 0, max: 1, step: 1and takes nomin,max,step,logoroff; on any other kind it isE-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: Non a parameter that has a range (a whole number for anInt): 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 sendsNwhen it is unticked. The signal graph carries it asParamTune.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
Boolparameter 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
enabledkey on every decorated parameter. Would have meant two values per parameter in the contract;offkeeps 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
offignores the field and treats the value as a plain number: the strategy still runs as written.