Strategy And Order Reference
Strategies inherit from Strategy in the HyperionX.Custom.Strategies namespace. The generated Strategy base derives from StrategyBase.
Strategies can calculate indicators, submit orders, manage stops and targets, inspect account state, and report performance.
Strategy State
| Member | Purpose |
|---|---|
Enabled | Starts or stops the strategy. |
Account | Selected account. |
Accounts | Available accounts for the active connection. |
Positions | Strategy position collection. |
LastPosition | Most recent strategy position. |
Realized | Strategy realized PnL. |
Unrealized | Strategy unrealized PnL. |
SystemPerformance | Backtest and live performance object. |
IsManagedOrderMode | Enables managed-order behavior. |
EntriesPerDirection | Entry limit per direction. |
Managed Entry Helpers
Use these for common strategy entries:
EnterLong();
EnterLong(1, "Long");
EnterShort();
EnterShort(1, "Short");
EnterLongLimit(1, limitPrice, "Long limit");
EnterShortLimit(1, limitPrice, "Short limit");
EnterLongStopMarket(1, stopPrice, "Long stop");
EnterShortStopMarket(1, stopPrice, "Short stop");
Exit Helpers
ExitLong();
ExitLong(1, "Exit long", "Long");
ExitShort();
ExitShort(1, "Exit short", "Short");
ExitLongLimit(1, limitPrice, "Exit long limit", "Long");
ExitShortLimit(1, limitPrice, "Exit short limit", "Short");
ExitLongStopMarket(1, stopPrice, "Exit long stop", "Long");
ExitShortStopMarket(1, stopPrice, "Exit short stop", "Short");
When quantity is 0 in some context helpers, HyperionX resolves the current position quantity.
Managed Stops And Targets
SetStopLoss(stopPrice);
SetStopLoss("Long", stopPrice);
SetStopLossTicks(20);
SetStopLossTicks("Long", 20);
ClearStopLoss();
SetProfitTarget(targetPrice);
SetProfitTarget("Long", targetPrice);
SetProfitTargetTicks(40);
SetProfitTargetTicks("Long", 40);
ClearProfitTarget();
Managed protection should be set before or near the entry logic so the strategy can attach protection consistently.
Direct SubmitOrder
For lower-level control:
SubmitOrder(
selectedBarsInProgress: 0,
orderAction: OrderAction.Buy,
orderType: OrderType.Market,
quantity: 1,
limitPrice: 0,
stopPrice: 0,
oco: "",
signalName: "Enter Long");
Supported OrderAction values:
BuyBuyToCoverSellSellShort
Supported OrderType values:
MarketLimitMITStopLimitStopMarket
Ctx.Orders
Ctx.Orders gives strategy-only order helpers:
Ctx.Orders.BuyMarket(1, "Buy");
Ctx.Orders.SellMarket(1, "Sell");
Ctx.Orders.SellShortMarket(1, "Short");
Ctx.Orders.BuyToCoverMarket(1, "Cover");
string oco = Ctx.Orders.CreateOcoGroup("HX");
Ctx.Orders.BuyLimit(1, limitPrice, "BuyLimit", oco);
Ctx.Orders.SellStop(1, stopPrice, "Stop", oco);
Ctx.Orders.Cancel(orderId);
Ctx.Orders.Change(orderId, quantity: 2, limitPrice: newPrice);
Ctx.Orders.Flatten();
Ctx.Orders.CancelAllWorking();
Ctx.Orders throws if called from an indicator.
Account And Position Context
double balance = Ctx.Account.Balance;
double equity = Ctx.Account.Equity;
double unrealized = Ctx.Account.Unrealized;
bool flat = Ctx.Position.IsFlat;
double size = Ctx.Position.Quantity;
MarketPosition side = Ctx.Position.MarketPosition;
Performance Metrics
Strategies expose summary properties backed by SystemPerformance, including:
NetProfitCommissionValueProfitFactorSharpeEquityHighsMaxDrawDownMaxDrawDownDaysStartDateEndDateMaxConsLossMaxConsWinsTradesWinPercentAverageTradesInYearAverageTradeProfitAverageWinningTradeLargestWinningTradeAverageLoosingTradeLargestLoosingTrade
These are used by validation, optimization, and reporting workflows.
Safety Rules
- Test on simulation/playback first.
- Guard early bars and null account state.
- Make signal names meaningful.
- Use OCO groups for paired exits.
- Never assume browser-style webhooks equal broker execution.
- Keep strategy parameters free of credentials.