Skip to main content

Script Troubleshooting

Use this page when Code Lab builds fail, scripts do not appear, indicators disable themselves, or strategies behave differently than expected.

Compile Errors

SymptomLikely causeFix
Script does not appearWrong namespace, wrong base class, duplicate class, or failed custom build.Match the script category namespace and rebuild.
Draw.TextFixed not foundScript uses another platform API.Use Draw.FixedText(...) or Ctx.Drawing.FixedText(...).
TextPosition not foundExternal enum.Use ChartHudAnchor.
IsOverlay not foundExternal overlay property.Use HyperionX panes and plots.
Buy, Sell, ShortSell, or Cover not foundExternal order helpers.Use EnterLong, EnterShort, ExitLong, ExitShort, SubmitOrder, or Ctx.Orders.
Generated helper missingThe referenced indicator failed to compile.Fix the indicator and rebuild custom scripts.
DateTime.Now issueDateTime resolves to bar series in script context.Use System.DateTime.Now.

Runtime Indicator Disabled

If an indicator disables itself, check:

  • early-bar guards
  • null child indicators
  • missing extra data series
  • invalid bars-ago reads
  • divide-by-zero
  • drawing tags using negative bar indexes
  • UI-thread access from background work

Start with:

if (CurrentBar < RequiredBars)
return;

Strategy Runs But Does Not Trade

Check:

  • strategy is enabled
  • account is selected
  • connection is connected
  • script is calculating on the intended series
  • BarsInProgress guard is not blocking all logic
  • position state check is correct
  • order quantity is greater than zero
  • signal names and OCO groups are valid
  • risk limits or account settings are not rejecting orders

Strategy Trades But Exits Are Missing

Check:

  • stop/target methods are called before or with the entry
  • fromEntrySignal matches the entry signal
  • OCO group is shared by paired exits
  • position quantity is available before submitting exits
  • exits are not being cancelled by later logic

Multi-Series Issues

Common fix:

if (CurrentBars[0] < 50 || CurrentBars[1] < 20)
return;

Then use BarsInProgress to route logic.

if (BarsInProgress == 1)
{
// Secondary series update.
return;
}

Drawing Problems

SymptomFix
Drawing duplicates every barReuse a stable tag if only one drawing should exist.
Drawing disappearsCheck tag reuse and Draw.Remove(...) calls.
Drawing throws bar index out of rangeGuard CurrentBar before using barsAgo.
HUD text uses wrong APIUse Draw.FixedText(...), not Draw.TextFixed(...).
Custom overlay lagsPrecompute values outside OnRender and limit loops to visible bars.

Build Hygiene

  • Keep one public class name per script.
  • Keep file names close to class names.
  • Remove copied generated regions from other platforms.
  • Do not store API keys in script parameters.
  • Treat warnings as cleanup items, but fix errors immediately.

Debugging Tools

Use:

Print("debug message");
Log("log message");
Ctx.Log.Info("context log");
Ctx.Log.Error("error message");

Keep debug output concise. High-frequency printing can make chart interaction feel laggy.