Work on an Existing Strategy
Use Existing Strategy when you already have a complete Pine Script strategy and want Xen to review it, fix a problem or make a focused change. This workflow keeps source files separate from the conversation, so clarification answers and later requests continue to use the same authoritative strategy.
Working on an existing strategy with AI
Start with the current strategy
Select Existing Strategy, then Add source code. Paste the complete Pine Script or select Load a .pine file, enter a file name and select Add source. The first file is always saved as the Current codebase and must contain a strategy() declaration.
Do not paste the strategy into the ordinary message box. If you do, Xen redirects the complete script to the source window so it can be stored correctly. Use the message box for your request after the source has been added.
Choose how each source file is used
An Existing Strategy project can retain up to four source files. Each file has one of three roles:
- Current codebase is the complete strategy Xen must review or modify. There can be only one current codebase.
- Merge functionality into the current codebase supplies another script whose relevant features should be integrated into the current strategy.
- Use only as example code gives Xen a pattern or implementation to study without treating every feature as a merge requirement.
After a current strategy has been saved, reopen Add source code to add merge or example files. Choose Replace current codebase when a newer complete strategy should become authoritative. Attached files and their roles appear above the message box and can be removed if they are no longer relevant.
When sharing merge or example code, explain exactly which behaviour Xen should reuse. A source role provides context, but it does not replace a clear request.
Request one focused change
Describe what happens now, what should happen instead and what must remain unchanged. For strategy changes, identify the entry and exit rules, order timing, position handling, stop-loss and take-profit behaviour, pyramiding settings, alert names and any date or session filters that must be preserved.
When reporting a problem, include the symbol, timeframe, relevant inputs, order or bar where it occurred, and the exact Pine Editor or Strategy Tester evidence. If you add source without a request, Xen identifies the strategy and asks what you want to do instead of rewriting it automatically.
Review without modifying the strategy
Select Review strategy beside the attached files to request a static review of all shared source. Xen reports priority findings, current behaviour, questions and recommended next steps without generating replacement code. Pine Editor and Strategy Tester remain authoritative for compilation and runtime behaviour.
For a narrower analysis, ask a direct question in the message box and state that you do not want code changed.
Test every revised version
When Xen returns a complete revised strategy, that version becomes the latest working source for the project. Paste it into Pine Editor, resolve every compiler message, and repeat the original Strategy Tester checks using the same symbol, timeframe, settings and test period. Confirm that unrelated entry, exit and risk behaviour still works before requesting the next change.