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.
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:
| Folder | Script Type |
|---|---|
Indicators | Custom indicators. |
Strategies | Custom strategies. |
BarTypes | Custom bar/data series types. |
Optimizers | Optimizer implementations. |
OptimizationFitnesses | Fitness score modules. |
MoneyManagements | Money management modules. |
Commissions | Commission models. |
Addons | Platform extensions. |
Script Categories
| Category | Namespace | Base class |
|---|---|---|
| Indicator | HyperionX.Custom.Indicators | Indicator |
| Strategy | HyperionX.Custom.Strategies | Strategy |
| Bar Type | HyperionX.Custom.BarTypes | Bar type base |
| Optimizer | HyperionX.Custom.Optimizers | Optimizer base |
| Optimization Fitness | HyperionX.Custom.OptimizationFitnesses | Fitness base |
| Money Management | HyperionX.Custom.MoneyManagements | Money management base |
| Commission | HyperionX.Custom.Commissions | Commission base |
| Addon | HyperionX.Custom.Addons | AddonBase |
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.
| State | Purpose |
|---|---|
State.SetDefaults | Set name, version, defaults, parameters, and declare plots. |
State.Configured | Allocate custom series, call AddSeries(...), connect plots, and initialize indicators. |
State.Historical | Historical calculation state. |
State.Playback | Playback/replay state. |
State.RealTime | Real-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:
OpenHighLowCloseVolumeDateTimeInput
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:
Parametersfor calculation settings.Appearancesfor colors, widths, line styles, and display settings.Riskfor strategy risk inputs.Executionfor 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:
- Identify whether it is an indicator, strategy, bar type, optimizer, or addon.
- Put it in the matching HyperionX namespace.
- Replace other-platform lifecycle methods with HyperionX
OnStateChanged()andOnBarUpdate(). - Replace other-platform drawing APIs with HyperionX
DrawAPIs. - Convert orders to HyperionX managed helpers; use
SubmitOrder(...)only for advanced unmanaged handling. - Replace unsupported properties with HyperionX-supported properties.
- Compile.
- Fix all diagnostics.
- Load in simulation or on a test chart.
- Watch logs for runtime errors.
Common Compile Problems
| Problem | Typical Cause |
|---|---|
| Script does not appear | Wrong namespace, wrong base class, duplicate class name, or custom assembly failed to build. |
| Generated helper missing | The indicator class failed to compile or is in the wrong namespace. |
Draw.TextFixed not found | Script used another platform's API. Use Draw.FixedText(...) or Draw.HudText(...). |
IsOverlay not found | Script used another platform property. Use HyperionX plot/panel behavior instead. |
| Strategy helper not found | Use documented managed helpers such as EnterLong(...), or the advanced SubmitOrder(...) API when needed. |
| Runtime indicator disabled | Script 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:
- Create or edit the script in Code Lab.
- Disable affected running strategies before the build.
- Build the complete custom project and fix every diagnostic.
- 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.
- Check logs for runtime errors and verify output visually.
- Run strategy validation/backtesting where available.
- Test with an explicitly selected
LocalPaperaccount. Playback does not select it automatically; the current release-candidate build rejects external-account order mutations while Playback is active. - After another build, remove and add the extension again—or reload its owning host—to create an instance from the new assembly.
- Use controlled size only after the documented provider and release checks pass.
Continue with Build, Test, And Debug and Parameters And Generated Helpers.