Skip to main content

Code Lab

Code Lab is the HyperionX C# scripting environment. It is where users build custom indicators, strategies, bar types, optimizers, optimization fitness modules, money management modules, commissions, and addons.

The established HyperionX 1.1.10 customer contract uses the generated classes and namespaces under HyperionX.Custom. Lower-level desktop implementation types are not a public extension API. The newer HyperionX.SDK runtime adapter present in the active development tree is Preview and is not an established 1.1.10 release contract.

Custom code runs inside the desktop process

A custom extension can block the UI, consume memory, read local data available to the process, or submit orders when its host and account allow it. Review imported source and test with LocalPaper before loading it in an account-connected session.

What Code Lab Is For

Use Code Lab when you need to:

  • Build a custom indicator.
  • Build an automated strategy.
  • Port an indicator or strategy from another platform into HyperionX.
  • Build an optimizer or fitness module.
  • Add a custom commission model.
  • Add money management logic.
  • Build reusable trading components.
  • Validate script behavior before running it live.

Custom Script Location

Custom scripts are normally stored under:

%USERPROFILE%\Documents\HyperionX\Bin\Custom

Typical subfolders:

FolderScript Type
IndicatorsCustom indicators.
StrategiesCustom strategies.
BarTypesCustom bar/data series types.
OptimizersOptimizer implementations.
OptimizationFitnessesFitness score modules.
MoneyManagementsMoney management modules.
CommissionsCommission models.
AddonsPlatform extensions.

Script Categories

CategoryNamespaceBase class
IndicatorHyperionX.Custom.IndicatorsIndicator
StrategyHyperionX.Custom.StrategiesStrategy
Bar TypeHyperionX.Custom.BarTypesBar type base
OptimizerHyperionX.Custom.OptimizersOptimizer base
Optimization FitnessHyperionX.Custom.OptimizationFitnessesFitness base
Money ManagementHyperionX.Custom.MoneyManagementsMoney management base
CommissionHyperionX.Custom.CommissionsCommission base
AddonHyperionX.Custom.AddonsAddonBase

The namespace must match the selected script category. If the namespace is wrong, the script may compile but not appear in the expected platform window.

Core Namespaces

Most indicator scripts use:

using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Windows.Media;
using System.Xml.Serialization;
using HyperionX.Chart.Classes;
using HyperionX.Chart.Enums;
using HyperionX.Core.Attributes;
using HyperionX.Core.DataCalc;
using HyperionX.Core.Enums;

Strategies usually also use:

using HyperionX.Core.Market;
using HyperionX.Custom.Indicators;

Lifecycle

HyperionX scripts use the OnStateChanged() and OnBarUpdate() lifecycle.

StatePurpose
State.SetDefaultsSet name, version, defaults, parameters, and declare plots.
State.ConfiguredAllocate custom series, call AddSeries(...), connect plots, and initialize indicators.
State.HistoricalHistorical calculation state.
State.PlaybackPlayback/replay state.
State.RealTimeReal-time calculation state.

Use OnBarUpdate() for per-bar logic. Always guard early bars before reading prior values.

public override void OnBarUpdate()
{
if (CurrentBar < 20)
return;

double momentum = Close[0] - Close[10];
}

Market Data Series

Scripts inherit primary series from ScriptBase:

  • Open
  • High
  • Low
  • Close
  • Volume
  • DateTime
  • Input

Use [0] for the current bar and [1] for one bar ago.

double currentClose = Close[0];
double priorClose = Close[1];
double currentVolume = Volume[0];
System.DateTime barTime = DateTime[0];

Volume is a double series. Do not assume it is an integer-only value.

Parameters

Use [HyperionXProperty] for user-editable script settings.

[HyperionXProperty]
[Display(Name = "Period", GroupName = "Parameters", Order = 1)]
public int Period { get; set; }

Use [Display(...)] to control the property grid label, group, and sort order.

Recommended groups:

  • Parameters for calculation settings.
  • Appearances for colors, widths, line styles, and display settings.
  • Risk for strategy risk inputs.
  • Execution for strategy order behavior.

Plots And Series

Indicators usually create a Plot in State.SetDefaults, allocate a Series<double> in State.Configured, register it with AddSeries(...), then assign the plot data source.

private Plot _plot;

[Browsable(false)]
[XmlIgnore]
public Series<double> Average { get; set; }

public override void OnStateChanged()
{
if (State == State.SetDefaults)
{
_plot = new Plot(Colors.DeepSkyBlue, "Average", 2, PlotLineType.Solid, PlotChartType.Linear);
AddPanePlot(_plot);
}
else if (State == State.Configured)
{
Average = new Series<double>();
AddSeries(Average);
_plot.DataSource = Average;
}
}

Drawing API

Use HyperionX drawing APIs, not drawing APIs from another trading platform.

Correct examples:

Draw.LineHorizontal(this, "last-close", Close[0], Brushes.DeepSkyBlue, 1, DashStyles.Dash);

Draw.FixedText(
this,
"status",
$"Close: {Close[0]:0.####}",
ChartHudAnchor.TopRight,
textBrush: Brushes.White,
backgroundBrush: Brushes.Black,
borderBrush: Brushes.DeepSkyBlue,
fontSize: 12);

Do not use Draw.TextFixed(...), TextPosition, or IsOverlay unless HyperionX explicitly implements them.

Strategy Orders

Strategies should use HyperionX managed order helpers for normal entry, exit, stop, and target workflows.

For a complete create-to-simulation walkthrough, use Build Your First Strategy. For exact overloads and argument meanings, use the Strategy And Order Reference.

SetStopLossTicks("Long Entry", 20);
SetProfitTargetTicks("Long Entry", 40);
EnterLong(1, "Long Entry");

Use EnterLong, EnterShort, ExitLong, and ExitShort, including their limit and stop-market variants. Use the lower-level SubmitOrder(...) API only when managed helpers cannot express the required lifecycle.

Do not assume external-platform helpers such as Buy(...), Sell(...), ShortSell(...), or Cover(...) exist.

Porting Scripts From Other Platforms

When porting a script:

  1. Identify whether it is an indicator, strategy, bar type, optimizer, or addon.
  2. Put it in the matching HyperionX namespace.
  3. Replace other-platform lifecycle methods with HyperionX OnStateChanged() and OnBarUpdate().
  4. Replace other-platform drawing APIs with HyperionX Draw APIs.
  5. Convert orders to HyperionX managed helpers; use SubmitOrder(...) only for advanced unmanaged handling.
  6. Replace unsupported properties with HyperionX-supported properties.
  7. Compile.
  8. Fix all diagnostics.
  9. Load in simulation or on a test chart.
  10. Watch logs for runtime errors.

Common Compile Problems

ProblemTypical Cause
Script does not appearWrong namespace, wrong base class, duplicate class name, or custom assembly failed to build.
Generated helper missingThe indicator class failed to compile or is in the wrong namespace.
Draw.TextFixed not foundScript used another platform's API. Use Draw.FixedText(...) or Draw.HudText(...).
IsOverlay not foundScript used another platform property. Use HyperionX plot/panel behavior instead.
Strategy helper not foundUse documented managed helpers such as EnterLong(...), or the advanced SubmitOrder(...) API when needed.
Runtime indicator disabledScript threw during calculation. Check early-bar guards and null assumptions.

AI Script Rules

When AI writes Code Lab scripts, it must:

  • Write HyperionX scripts, not scripts for another platform.
  • Use local HyperionX APIs.
  • Use the correct namespace and base class.
  • Use [HyperionXProperty] for editable settings.
  • Guard early bars.
  • Register custom series with AddSeries(...).
  • Use supported plot and draw APIs.
  • Compile after editing.
  • Fix all errors before loading the script.

Build And Test Flow

Recommended development flow:

  1. Create or edit the script in Code Lab.
  2. Disable affected running strategies before the build.
  3. Build the complete custom project and fix every diagnostic.
  4. Load a new indicator/strategy instance on a test chart. Runtime activation performs an additional authoritative compile/load pass that a green editor build alone does not replace.
  5. Check logs for runtime errors and verify output visually.
  6. Run strategy validation/backtesting where available.
  7. Test with an explicitly selected LocalPaper account. Playback does not select it automatically; the current release-candidate build rejects external-account order mutations while Playback is active.
  8. After another build, remove and add the extension again—or reload its owning host—to create an instance from the new assembly.
  9. Use controlled size only after the documented provider and release checks pass.

Continue with Build, Test, And Debug and Parameters And Generated Helpers.