Parameters and Generated Indicator Helpers
[HyperionXProperty] marks a public property as part of a script's configurable identity. HyperionX uses that metadata for property editing, cloning, optimization, and generated indicator helper caching.
Define a parameter
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using HyperionX.Core.Attributes;
[HyperionXProperty]
[Category("Parameters")]
[Display(Name = "Period", GroupName = "Parameters", Order = 1)]
[Range(1, 500)]
public int Period { get; set; }
Set the default in State.SetDefaults:
if (State == State.SetDefaults)
{
Name = "My Average";
Period = 14;
}
| Metadata | Purpose |
|---|---|
HyperionXProperty | Includes the property in HyperionX configuration and generated-helper identity. |
Display | Supplies the label, group, description, and order shown to users. |
Category | Groups the value in property editors that honor categories. |
Range | Communicates an intended UI validation range. |
Browsable(false) and XmlIgnore | Keep output series and runtime-only objects out of the editable property model. |
Do not rely on Range alone to make a value safe. Validate divisors, lookback lengths, quantity, prices, and indexes before using them. Imported source, older saved workspaces, and programmatic assignment can bypass a property editor.
Use stable primitive or enum values for public parameters. Current optimizer handling is designed around int, double, bool, and enums. Treat complex objects, services, credentials, and live account objects as runtime dependencies, not parameters.
How indicator helpers are generated
During both Code Lab compilation and desktop runtime compilation, HyperionX scans source and generates convenience methods in the custom Indicator and Strategy aliases. For:
namespace HyperionX.Custom.Indicators;
public class MyAverage : Indicator
{
[HyperionXProperty]
public int Period { get; set; }
}
the generated surface is equivalent to:
MyAverage MyAverage(
int period,
ScriptOptions options = null);
MyAverage MyAverage(
ISeries<double> input,
int period,
ScriptOptions options = null);
That enables:
private MyAverage _average = null!;
public override void OnStateChanged()
{
if (State == State.Configured)
_average = MyAverage(Close, 14);
}
Generator requirements
- Put the indicator in
HyperionX.Custom.Indicators. - Derive it directly from a base whose declared simple name is
Indicator. - Give the class a unique C# identifier.
- Mark each helper argument with
[HyperionXProperty]. - Make property types available to generated source through explicit namespaces or fully qualified names.
- Use either a file-scoped or block-scoped namespace; both are supported.
The generator does not edit customer files. Do not paste generated cache regions from NinjaTrader or another platform.
An indirect subclass can be discovered as an indicator, but the current helper generator only recognizes the directly declared Indicator base. If no helper is generated, construct or refactor using a documented pattern rather than creating a duplicate helper class in the source tree.
Caching behavior
Generated calls reuse a child indicator when all of these match:
- Indicator class.
- Input-series object.
ScriptOptionsvalue.- Every
[HyperionXProperty]value, compared with the property's==operator.
Changing a parameter produces a different cached child. Reference-valued parameters compare according to their type's equality behavior, which is another reason to keep helper parameters small and stable.
DateTime parameters are emitted as System.DateTime to avoid collision with the inherited bar-time DateTime series.
Output properties
Output series are runtime state, not parameters:
[Browsable(false)]
[XmlIgnore]
public Series<double> Average { get; private set; } = null!;
Create the series once in State.Configured, pass it to AddSeries(...), and connect it to a plot if it should render. Give output series stable, descriptive names so research exports and downstream scripts remain understandable.
Parameter review checklist
- Default is safe for a first run.
- Runtime code validates the actual value.
- Display name, group, order, and units are clear.
- A renamed or removed parameter has an upgrade note.
- Output and service properties are hidden from parameter editing.
- Generated helper builds in both Code Lab and desktop activation.
- A parent script can create two instances with different parameter values without cross-talk.
Continue with Indicator Patterns, Build, Test, and Debug, and the Indicator reference.