Muchun Collection

Writing Script Code with AI: How I Use AI to Assist My TradingView Trading

2025-12-31 · Muchun

English translation of the Chinese original (AI-assisted). Read the original in Chinese.

I want to record how I use AI to write script code for me.

The original reason was actually very simple.

I have been trading with TradingView for a long time, and I have always been a free user. I have never bought any of its paid plans, and the reason is straightforward: I use TradingView very simply.

I only look at charts, and I use very few indicators. I don't use alerts, I don't need more historical data, and opinion sharing and social features mean nothing to me.

For me, TradingView is a chart-viewing tool with a few very basic indicators. That's all.

But over long-term use, there was one practical problem.

As a free user, there is a limit on how many indicators can be used at the same time. Most of the time this doesn't affect me, but occasionally I really need to use more than two indicators at once.

Once the limit is exceeded, one of them has to be removed. This means several conditions cannot be observed on the same chart at the same time.

I didn't want to pay for this, so I started wondering: is there another way?

Later, I noticed the "Pine Editor" at the bottom of TradingView.

This gave me an initial idea: could I combine several of the indicators I commonly use into a single indicator?

This was the starting point of all my experiments.

I did try to study scripts myself, but I soon realized a practical problem: I don't know programming, and I don't know how to write code.

Learning programming systematically from scratch just for this would not only be a question of ability; more importantly, the cost in time and energy would be too high.

So I naturally thought of AI.

My requirements were not complicated. For example:

I needed a moving-average indicator, possibly several moving averages, such as four with different periods;

I also wanted one of the lines from Ichimoku, but without the cloud;

and I wanted to see the ATR value, but without plotting the ATR indicator on the chart—only the value for the current bar.

These are actually functions from three different indicators.

I told AI all of this in full, clearly describing what I needed, what I didn't need, and how I wanted it displayed.

AI then wrote a piece of script code for me.

All I had to do was copy and paste the code into TradingView's script editor and save it as my own indicator.

It worked.

This way, I load only one indicator on the chart, but inside it, the several functions I actually need are already combined.

It not only solved the indicator limit for free users, but also made the chart cleaner and closer to how I like to work.

On this basis, the next idea came naturally.

Since I could already combine my usual indicators, could I go a step further and backtest some of the market patterns I had observed over the years?

And further still, could I turn these experiences and judgments into backtesting tools, or even strategy scripts?

Looking back, this was a very clear path: first solve the limits at the tool level, then verify judgments formed over the long term, and only at the end move on to strategy and the system itself.

In fact, all of this can be done in TradingView.

Whether it is a backtesting script, a strategy script, or a more complex analytical tool, the method and the order are the same: first clarify the requirements, then describe the logic, and finally let AI turn the logic into code.

For me, backtesting and scripts only help verify whether the logic holds together. They do not make judgments for me, and they certainly do not take on risk for me.

Of course, the process has not always gone smoothly.

Sometimes the code AI writes throws errors. Sometimes it works, but the result is not what I expected.

When this happens, I don't keep going round in circles with a single AI. My approach is to cross-check with several AIs:

One AI writes the basic functional code;

another checks the syntax and possible errors;

and a third verifies whether the logic actually does what I originally intended.

For me, cross-checking with several AIs is not a trick, but a way of actively reducing the risk of errors in understanding and in implementation.

By correcting things this way, I gradually realized that I was not actually "learning to code," but learning how to describe requirements precisely and have AI implement them for me.

From a trader's point of view, AI can do a lot. It can write indicator code, backtesting scripts, and strategy scripts; it can help with modeling, parameter validation, and historical data analysis; and, in the future, it may track and scan many instruments, or the entire market, in real time according to your own strategy logic.

I haven't gone that far in these directions yet.

There are many tutorials about these things online, but I have hardly studied them systematically.

I prefer to bring AI in step by step, after I have clearly identified a problem I am facing, and solve only the part that really needs solving at that moment, rather than bringing in every possibility at once.

For me, the principle of using AI is not "the more complicated, the better," but whether it fits my own abilities, my way of understanding, and how efficiently I can use it.

I have always followed my own pace of acceptance, understanding, and thinking, letting AI become part of my trading process step by step.

Not to chase a sense of technology, nor to show off tools, but to serve my own system of judgment.

For me, the value of AI lies not in making decisions for me, but in helping me see more clearly how I make decisions.

I believe AI-assisted trading will become a long-term trend. But it will not happen overnight, and there will not be only one standard answer.

Everyone will take a different path.

For me, this is still a process of learning, practicing, and continuously thinking. What it develops into is not important right now.

Time will provide the answer. We can take our time and see.

Images in the original are not included in the web version.

← All articles