Skip to main content

Code Lab API Reference

This is the public Code Lab API surface that script authors and AI coding agents should target.

Runtime Assemblies

Code Lab references the HyperionX runtime assemblies needed for custom scripts:

  • HyperionX.Core.dll
  • HyperionX.Chart.dll
  • HyperionX.Model.dll
  • HyperionX.DB.dll
  • HyperionX.SDK.dll

Most public custom scripts should use the generated Indicator and Strategy classes in the HyperionX.Custom namespaces rather than deriving directly from lower-level runtime classes.

Base Script Members

Indicators and strategies inherit common market data from ScriptBase.

MemberPurpose
OpenCurrent input open series.
HighCurrent input high series.
LowCurrent input low series.
CloseCurrent input close series.
VolumeCurrent input volume series.
DateTimeCurrent input bar time series.
InputPrimary input series.
CurrentBarCurrent processing bar index.
TickSizeInstrument tick size.
MultiplierInstrument multiplier.
InstrumentCurrent instrument context.
ConnectionNameCurrent connection context label.
DataSeriesCurrent data series information.
PlotsScript plot collection.
DrawChart drawing helper.
CtxScript context object.

Multi-series scripts can use the collection forms:

  • Opens
  • Highs
  • Lows
  • Closes
  • Volumes
  • DateTimes
  • CurrentBars

Lifecycle Methods

Override these methods when needed:

public override void OnStateChanged() { }
public override void OnBarUpdate() { }
public override void OnTickUpdate(ICandle candle, ICandle tick) { }
public override void OnAfterBarUpdate() { }
public override void OnConnectionStatusChanged(ConnectionStatus oldStatus, ConnectionStatus newStatus, string connectionName) { }

Most scripts only need OnStateChanged() and OnBarUpdate().

State Values

The current state enum contains:

Undefined
SetDefaults
Configured
Historical
Finalized
Calculated
Playback
RealTime
DataLoaded
Transition
Terminated

Recommended usage:

  • SetDefaults: defaults, name, version, plot objects.
  • Configured: allocate series, add series, wire plot data sources, create child indicators.
  • Historical, Playback, RealTime: calculation/runtime behavior.

Series And Plots

Use Series<double> for custom output values.

MySeries = new Series<double>();
AddSeries(MySeries);

Use Plot for chart visualization.

var plot = new Plot(Colors.DeepSkyBlue, "Main", 2, PlotLineType.Solid, PlotChartType.Linear);
AddPanePlot(plot);
plot.DataSource = MySeries;

Current public plot enums:

PlotLineType.Solid
PlotLineType.Dashed
PlotChartType.Linear
PlotChartType.Bars

Data Series Helpers

Scripts can request additional data series through:

AddDataSeries(DataSeriesType dataSeriesType, int dataSeriesValue, string symbol = "");

Use multi-series collection members to access additional series after they are configured.

Debug Output

Use script-level debug methods for diagnostics:

Print("message");
Log("message");
ClearDebug();

Output intended for strategy authors should stay separate from application debug logs where possible.

Draw API

Use the HyperionX Draw helper for chart drawings.

Common calls:

Draw.Line(this, "line", 10, Low[10], 0, High[0], Brushes.DeepSkyBlue, 2, DashStyles.Solid);
Draw.LineHorizontal(this, "hline", Close[0], Brushes.DeepSkyBlue, 1, DashStyles.Dash);
Draw.LineVertical(this, "vline", 0, Brushes.Gray, 1, DashStyles.Solid);
Draw.Text(this, "label", "Breakout", 0, High[0], Brushes.White);
Draw.FixedText(this, "hud", "Live", ChartHudAnchor.TopRight, textBrush: Brushes.White);
Draw.HudText(this, "hud2", "Status", ChartHudAnchor.BottomRight);

Helper methods also exist to check or remove drawings:

bool exists = Draw.Exists("tag");
Draw.Remove("tag");
Draw.Reset();

Chart Render Hooks

Advanced scripts can render overlays through IChartOverlayRenderer and IChartRenderContext.

IChartRenderContext provides:

  • Render backend and pass.
  • Visible bar range.
  • Candle width and gap.
  • Tick size.
  • Price range.
  • Pane width and height.
  • GetXByBarIndex(...).
  • GetYByPrice(...).
  • GetPriceByY(...).
  • GetNearestBarIndex(...).
  • DrawLine(...), DrawRectangle(...), DrawCircle(...), and DrawText(...).

Use this path for advanced text, timers, order-flow, profile, and custom drawing tools.

Strategy Order API

Strategies submit orders with:

SubmitOrder(int selectedBarsInProgress, OrderAction orderAction, OrderType orderType, double quantity, double limitPrice, double stopPrice, string oco, string signalName, string comment = null, bool allowMoneyManagement = false)

Orders can be cancelled with:

CancelOrder(order);

Use SubmitOrderPlaybackSim(...) only for playback/simulation-specific paths.

Generated Indicator Helpers

When an indicator compiles, HyperionX generates helper methods for indicators and strategies. For example, a class named SMA with a Period property generates helper calls similar to:

SMA(14);
SMA(Input, 14);

Duplicate class names or compile errors can stop helper generation. Keep custom class names unique.

AI Agent Rules For Code Lab

AI agents should follow these public rules:

  • Write HyperionX scripts only.
  • Use correct namespaces and base classes.
  • Check available local APIs before calling methods.
  • Do not use unsupported APIs from other platforms.
  • Do not invent draw helpers or order helpers.
  • Compile after edits and fix every error.
  • Keep credentials out of script parameters and logs.