Skip to content

Building Strategies

Select Build Strategy when you want Xen to create a new TradingView strategy and no existing source is being modified or converted. Describe the system as trading behaviour rather than code. Include entry and exit conditions, permitted trade directions, position sizing and any required stop, target, trailing or break-even rules.

Pine strategies also need clear execution assumptions. State whether signals should be confirmed at bar close, whether pyramiding is allowed, how session filters behave and whether higher-timeframe data may be used. Xen does not add unrequested protection automatically, so include every control that belongs in the design.

Use Prompt Builder to remove guesswork

Xen gives you the choice to use Prompt Builder or continue with your original request. If important details are missing and you continue without it, Xen must make assumptions about how the strategy should work, just as most other AI tools would. Use Prompt Builder and Build Plans to clarify entries, exits, trade direction, risk controls and execution rules before the strategy is created.

Build a TradingView strategy with AI

Generate a baseline

Begin with the smallest version that proves the signal and position-management logic. A baseline is easier to compile and backtest than a complete system containing every planned feature. Prompt Builder can create a staged Build Plan when several features interact.

When generation completes, Xen returns one complete Pine Script v6 file with an overview and implementation notes. The response actions copy or download the source, open requirements verification and prepare a Pine error repair. Save the complete file locally as well as in Xen.

Strategy conversion timing

A strategy converted from another platform can compile correctly without producing identical trades. Trading platforms do not always evaluate forming bars, incoming ticks and order events in the same sequence. An entry generated at the close of a bar on the source platform might be submitted on the next available update in TradingView, while an intrabar strategy can react to price movement that is not visible in completed bar data.

Historical bars also provide less information than a live sequence of ticks. If a bar reaches both a stop loss and profit target, its open, high, low and close values do not prove which price was reached first. Each platform's historical fill model may resolve that bar differently. Settings such as calculate-on-close, calculate-on-each-tick, order-fill resolution and secondary data series can therefore change entry, exit and fill timing.

Broker and data-feed differences add another source of variation. Price quotes, tick sequences, spread, session boundaries, timestamps, missing ticks and contract data can differ between providers. Even the same strategy running on the same timeframe can receive a different sequence of market events and produce different signals or fills.

For these reasons, you should not expect a converted TradingView strategy to reproduce the source platform's backtest trade for trade or return exactly the same performance results. Treat the converted strategy as a new implementation: compare entry and exit times with the original, verify position and protective-order behaviour, include realistic commission and slippage, and test with the intended TradingView data connection before live use.

Compile and test

Paste the complete script into Pine Editor and click Save. TradingView's compiler is the final authority. Resolve every error and review warnings before adding the strategy to a chart. Then use Strategy Tester to inspect trades and confirm that entries, exits, protective orders, commissions, slippage and date or session controls behave as intended.

Return to the same Xen project for focused refinements. Complete generated revisions are saved in History, and Verify requirements can compare the latest script with the project's explicit requests. Trade-performance analysis remains separate: use Analyse Strategy with a List of Trades CSV when you want Xen to review backtest evidence.

Simulation before live use

A strategy can compile and still contain unsuitable order logic, repainting assumptions or unrealistic historical behaviour. Test on representative symbols and timeframes before considering any live use.