Build, Test, and Debug
Code Lab is a project compiler, not a one-file runner. Every source below the custom root participates in one HyperionX.Custom.dll, and successful editor compilation is only the first gate.
Paths
The default source root is:
%USERPROFILE%\Documents\HyperionX\Bin\Custom
Code Lab writes:
%USERPROFILE%\Documents\HyperionX\Bin\Custom\bin\Debug\HyperionX.Custom.dll
%USERPROFILE%\Documents\HyperionX\Bin\Custom\bin\Debug\HyperionX.Custom.pdb
The default installed configuration also loads from the Debug folder. A customized project/output setting can change the runtime path; check Options > Project and the HyperionX log before copying artifacts manually.
Two builds are involved
Code Lab and the desktop runtime compile the same source tree for different purposes.
1. Code Lab build
Selecting Build in Code Lab:
- Saves the active editor buffer into its category folder.
- Reads every
.csfile below the custom root except files underbinandobj. - Normalizes the legacy spelling
State.ConfiguretoState.Configured. - Adds narrow global imports, editor compatibility support, and in-memory indicator helper sources.
- Emits a Debug
HyperionX.Custom.dlland PDB. - Shows Roslyn errors and warnings in the Code Lab diagnostics view.
This pass does not by itself replace every object already running in the desktop process.
2. Desktop runtime build and load
At startup, from the chart Compile Project action, or when an indicator/strategy selector detects stale source, HyperionX:
- Unloads successfully loaded add-ons and clears custom bar registrations.
- Unloads the previous collectible custom assembly.
- Reads the entire custom source tree again.
- Generates indicator convenience helpers in memory.
- Emits and loads a new
HyperionX.Custom.dll. - Discovers scripts, research modules, bar builders, and add-ons.
- Recreates eligible chart objects when reload-on-compile is enabled.
Runtime activation is authoritative. A green Code Lab build followed by a runtime-build error is not a deployable extension.
Code Lab currently supplies imports and compatibility members that the runtime pass does not reproduce. Put every required using directive in the source, use State.Configured, and depend only on documented members. Always complete the runtime activation check.
The normal edit loop
- Start from the closest Code Lab template.
- Give every public class a unique name and align the file name with it.
- Save the source in its category folder.
- Disable running strategies and remove affected instances before the runtime build.
- Select Build in Code Lab and resolve all errors.
- Trigger runtime activation by opening the relevant selector or using Compile Project.
- Create a fresh instance in its actual host.
- Inspect the HyperionX log and verify a written expected result.
- Build a second time to test reload and cleanup.
An enabled strategy remains on the old assembly during a runtime recompile and is marked as out of date. Disable it before compiling. If it remained enabled, toggling Enabled off and on later reuses the same object; remove and add the strategy again, or reload its owning host.
Indicators can be recreated automatically when reload-on-compile is enabled, but a fresh instance remains the safest verification target. Bar builders and successfully loaded add-ons are re-registered from the new assembly.
Atomic-build consequences
- One unrelated syntax error can block every custom extension.
- Duplicate class names can break generated helpers or make discovery ambiguous.
- Moving a file to another folder below
Customdoes not exclude it. - To quarantine a file, move it completely outside the custom root or change its extension.
- Never edit
binorobj; those are output and intermediate folders. - A failed runtime compile can leave no current custom assembly loaded. Resolve the error and activate again.
One syntax or type error can create many follow-on messages. Fix the earliest source location, rebuild, and reassess.
Assembly and dependency boundary
Code Lab compiles against a fixed set of HyperionX, .NET, WPF, and already loaded process assemblies. It does not restore an independent NuGet graph for each extension.
- Prefer APIs already referenced by the installed Code Lab runtime.
- Do not assume adding
PackageReferenceto an unrelated project changes the Code Lab build. - Do not distribute copied HyperionX binaries with source extensions.
- Treat manually copied third-party DLLs as unsupported unless a HyperionX release documents that deployment path.
- Use an external process and the local desktop API when an integration needs dependency isolation.
Indicator helper generation
Code Lab and the runtime use the same in-memory indicator helper generator. It supports file-scoped and block-scoped namespaces and does not append generated code to customer source.
For a helper such as MyAverage(14):
- Put the class in
HyperionX.Custom.Indicators. - Derive the class directly from
Indicator. - Mark helper parameters with
[HyperionXProperty]. - Keep the class name unique.
- Do not copy another platform's generated cache region.
An indirect subclass can still be discovered by base type, but the current generator only emits helpers for a class whose declared base has the simple name Indicator.
See Parameters and generated helpers for the generated signature and cache behavior.
SDK adapter status
The active release-candidate source also generates native hosts for direct HyperionX.SDK.IndicatorBase and StrategyBase subclasses. That adapter is Preview and unreleased; it is not the release-safe authoring path for an existing 1.1.10 installation. Use HyperionX.Custom for public samples and verify API status before testing SDK-shaped source.
Diagnose compile and activation failures
For each error, check:
- The file and line belong to the source you intended to compile.
- The namespace and base type match the extension family.
- The member exists in the current HyperionX reference.
- Required
usingdirectives are explicit and unambiguous. DateTime[0]means bar time andSystem.DateTime.Nowmeans machine clock time.- No copied generated region declares duplicate support types.
- The source passes desktop activation, not only the Code Lab pass.
| Symptom | Most likely check |
|---|---|
| Code Lab fails | Fix the first diagnostic anywhere in the custom tree. |
| Code Lab succeeds; runtime fails | Remove editor-only aliases/import assumptions and read the main HyperionX log. |
| Type does not appear | Confirm a concrete class, correct base type, successful runtime load, and the intended selector. |
| Helper method is missing | Use the exact indicator namespace, a direct Indicator base, and [HyperionXProperty] parameters. |
| Old behavior remains | Stop and recreate the instance; an enabled strategy can keep its old assembly. |
| Add-on did not start | Complete a desktop runtime load or restart HyperionX; Code Lab emission alone is not activation. |
More symptom-specific fixes are in Script Troubleshooting.
Runtime verification by extension type
| Type | Minimum verification |
|---|---|
| Indicator | Add to a chart; change parameters; scroll, zoom, resize, change interval, reload, and inspect outputs/logs. |
| Strategy | Backtest, then playback or simulation on an explicitly selected LocalPaper account; inspect orders, fills, positions, stops, targets, errors, and stop behavior. Playback does not select LocalPaper; the current release-candidate build rejects external-account mutations while Playback is active. |
| Bar type | Compare deterministic candles across historical construction, incremental updates, reset, and flush. |
| Optimizer | Run a tiny known grid and confirm combination count, cancellation, retained results, and ranking. |
| Fitness | Verify profitable, losing, empty, and non-finite result cases. |
| Money management | Verify valid, minimum, maximum, zero, and preserve-requested-quantity cases in every intended environment. |
| Commission | Verify full exits, partial exits, quantity, asset class, and a zero-cost baseline. |
| Add-on | Test first load, second load, failed load, unload, event cleanup, and UI responsiveness. |
Logs and output
Indicators and strategies can use:
Print("calculation checkpoint");
Log("platform log message");
Ctx.Log.Info("structured information");
Ctx.Log.Error("structured error");
Add-ons use their protected Print(...) method. Avoid per-tick logging except during a short diagnostic run; high-frequency output can hide the useful event and reduce responsiveness.
Runtime failure policy
Use early-bar guards, null checks, bounded loops, and explicit no-data handling. The host adds a final isolation layer:
- A live indicator is disabled after ten consecutive callback failures.
- A live strategy skips a failing update and stays enabled.
- After ten consecutive live strategy calculation errors, HyperionX suspends new entries while leaving exits and protection active.
- Historical and validation failures can abort the current run instead of using the live policy.
The strategy exposes AreEntriesSuspended, LastRuntimeError, ConsecutiveRuntimeErrors, and RuntimeStatusText. Do not call ResumeEntriesAfterFault() until the cause is corrected and account state is reconciled.
Recover from a bad build
If the project does not compile:
- Read the first diagnostic.
- Move only the suspect source completely outside the custom root.
- Activate a clean build and verify the remaining project.
- Restore the file and fix it before reactivation.
If runtime code misbehaves:
- Disable the strategy or remove the chart object where possible.
- Move the extension's owned source outside the custom root.
- Build and activate an assembly without it.
- Restart HyperionX if faulty in-process code left resources active.
- Inspect logs before reintroducing the extension.
Source-checkout validation
Repository contributors can validate the live Code Lab folder with:
.\Scripts\compile-code-lab.bat
Bundled source also requires:
dotnet build .\HyperionX.Custom\HyperionX.Custom.csproj -c Release -p:Platform=x64
These commands are not required for installed users. Code Lab diagnostics are the first gate; successful desktop activation is the final gate.
Definition of done
- The full custom tree builds in Code Lab and activates in the desktop runtime.
- New warnings are understood.
- The type appears in its intended host.
- A fresh instance produces the written expected result.
- A second build proves reload and cleanup behavior.
- Historical, playback, simulation, and live differences are documented.
- Strategy code passes a simulation-first safety review.
- Logs contain no unexpected exceptions, credentials, account identifiers, or private data.