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

HyperionX 1.1.10 public scripts use the generated Indicator and Strategy classes in the HyperionX.Custom namespaces rather than deriving directly from lower-level runtime classes. A newer HyperionX.SDK runtime adapter exists in the active development tree, but it is Preview and not an established 1.1.10 compatibility contract.

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.
BarBrushProtected setter for the current candle body color.
CandleOutlineBrushProtected setter for the current candle outline and wick color.
BackBrushAllProtected setter for the current bar background color.

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

For normal order workflows, prefer managed helpers:

EnterLong(quantity, signalName);
EnterShort(quantity, signalName);
ExitLong(quantity, signalName, fromEntrySignal);
ExitShort(quantity, signalName, fromEntrySignal);
SetStopLossTicks(fromEntrySignal, ticks);
SetProfitTargetTicks(fromEntrySignal, ticks);

Limit and stop-market variants are also available. See Strategy and Order Reference for the complete managed surface.

Advanced direct submission

Use SubmitOrder(...) when the managed API cannot express the required lifecycle:

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

Compatibility overload:

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

For stop orders, a non-zero stopPrice wins. If stopPrice is 0, HyperionX uses auxiliaryPrice as the stop price.

The allowMoneyManagement argument is currently retained for signature compatibility and does not opt an order in or out. In the active release-candidate source, a selected module runs automatically for Buy and SellShort entries, while exits are not resized. Treat that behavior as Preview until the signed target package is frozen; see Optimization Module Reference.

Directly submitted orders can be cancelled with:

CancelOrder(order);

Direct submission makes the strategy responsible for working-order tracking, OCO coordination, partial fills, and cancel/replace behavior. 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, invalid parameter shapes, or compile errors can stop helper generation. Keep custom class names unique and use Parameters And Generated Helpers for the current generation and runtime-activation rules.

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.