Skip to content

Working with Existing Code

Use Existing Strategy or Existing Indicator when a complete NinjaScript file already exists. These tasks are intended for controlled changes, code review and problems that appear only after the script is compiled or run in NinjaTrader.

Upload a .cs or plain-text file, or paste the complete source into the composer. Add the change request before sending. Xen formats uploaded source as code in the conversation so it remains readable and distinct from ordinary instructions.

Describe a focused change

Explain what currently happens and what should happen instead. If NinjaTrader produced an error, include its exact text and state when it occurred. Compiler errors, Log messages and Strategy state information are more useful than a general statement that the script failed.

Xen is instructed to preserve the class name, public inputs and unrelated working behaviour. This is important when the script is already saved in NinjaTrader templates or used in Strategy Analyzer. If a rename is required, request it explicitly.

When source is supplied without a requested change, Xen identifies the apparent script and asks what should be changed rather than rewriting it automatically.

Runtime problems

Build Check can find compilation and selected lifecycle problems, but it does not execute the Strategy or Indicator. Runtime messages from NinjaTrader must be supplied to Xen with the source.

For example, an error raised from OnStateChange should include the full NinjaTrader Log message and the state reached when the failure occurred. Behavioural problems should include the instrument, data series, calculation mode and the action that exposed the issue.

After a repair, compile the complete file in NinjaTrader and repeat the test that originally failed. Avoid adding another feature until the repair is confirmed.

Review without changing code

You can ask Xen to explain or review existing source without modifying it. State that you want analysis only. Xen will describe the relevant behaviour and risks without returning a rewritten file.

If you later request a change, confirm that the latest complete source in the conversation is still the version being used in NinjaTrader.