Search
Trading Tools
    Menu Close
    Back to all

    How to Edit an Existing TradingView Indicator with AI

    If you already have a TradingView indicator that works, creating a completely new version is usually unnecessary; most traders just want to add another signal, add alerts, change how something is displayed, or make a small improvement without disrupting the existing logic.
     
    TradingView Xen includes a Work on Existing Indicator task for this type of development, and you can provide your current Pine Script, describe the change you want, and let Xen update the existing code rather than starting again from an empty script.

    £5 Free Credit for New Users

    New users currently receive £5 of free Xen AI credit. Xen uses pay-as-you-go pricing, so you only purchase additional credit when required. Try Xen AI for TradingView

     

     

    Getting Started

    The first step is simply to provide Xen with the indicator you are already using. This gives it the complete script, including the inputs, calculations, plots and any existing signal logic. Then explain exactly what you want changed. This could be a small adjustment to one calculation or a larger feature that introduces new chart signals, settings and alert conditions.
     
    Because Xen is working with the original script, you can also tell it to leave existing behaviour unchanged. That is particularly useful when the indicator has already been tested, and you only want to extend one part of it.
     

    Adding a new feature to an existing indicator

    For the example in the video, we started with a simple Donchian Channel indicator, and the original script plotted the upper and lower channel levels, a centre line and coloured the bars according to their position inside the channel.
     
    We then asked Xen to add breakout signals: a green marker when price closed above the previous upper channel and a red marker when it closed below the previous lower channel. We also asked for separate settings to enable or disable the markers and to add TradingView alert conditions.
     
    This is a useful example because the new feature touches several parts of the script while leaving the original indicator intact. Xen needs to understand the existing calculation, add the new conditions, create the chart markers and include the alert logic without replacing the rest of the code.
     

    How to Review and Repair Existing Pine Script

    The Existing Indicator task is not limited to adding features. It can also be used when you have inherited an older script, made several manual changes, or simply want another review of the code before continuing development.
     
    You can ask Xen to explain part of the indicator, look for potential problems, clean up sections of code or help repair compiler errors. This is often more practical than moving small pieces of the script into a general-purpose coding tool because Xen already has the complete TradingView project in context.
     

    Use your own code as a reference

    You can also provide additional Pine Script alongside the indicator. If you already have a working calculation, function, or piece of signal logic from another project, you can supply it as an example and integrate it into the existing script.
     
    This is useful when you want to keep a particular implementation rather than asking Xen to create its own version. The reference code shows exactly how the feature should work, while the main indicator gives Xen the context needed to fit it into the existing structure.

     

    Test the updated indicator in TradingView

    Once the changes are complete, copy the updated code into the TradingView Pine Editor and add it to a chart. Check that the original indicator still behaves as expected and then test the new feature separately.
     
    For the Donchian example, that means checking the existing channel and bar colours first, then confirming that the new breakout markers appear on the correct bars and that the alert conditions can be selected in TradingView.
     
    This approach makes incremental Pine Script development much easier to manage. Instead of replacing a working indicator every time you want another feature, you can keep improving the same script as your requirements change.

    Work on an Existing Pine Script Indicator with Xen AI