3.2 Let AI write the code
You no longer need to be a programmer to test a strategy. Language models can write code for most platforms.
| Platform | Language | Suited to |
|---|---|---|
| TradingView | Pine Script | Indicators, alerts and simple backtests |
| MetaTrader 4 and 5 | MQL4 and MQL5 | Robots (Expert Advisors) |
| cTrader | C# (cBots) | Robots |
| Your own computer | Python | Flexible tests and data analysis |
How to get better code
- State the rules precisely – ideally as numbered points.
- Give the platform and version, for example “Pine Script version 6”.
- Ask for comments that explain each part.
- Paste in the error messages you get, and ask the AI to fix them.
- Ask the AI to look for mistakes: “Go through the code and look for errors that give unrealistically good results.”
Common mistakes in AI-written code
- Look-ahead bias: The code uses information from the future, for example today’s closing price before the day is over.
- No costs: spread, commission and financing are left out.
- Wrong position size: the risk ends up different from what you think.
- Functions that do not exist: the AI makes up commands that are not part of the language.
Without coding
Want to build a robot without writing code? Try the algo builder, which creates finished code for MetaTrader and cTrader from the rules you choose. See also the course Algorithmic trading.
Key takeaways
- AI can write code for TradingView, MetaTrader, cTrader and Python.
- Give precise rules, state the platform and version, and ask for comments.
- Look out for look-ahead bias, missing costs and functions that do not exist.
Practise what you have learned – without riskTry it on a free demo account with Skilling, with real prices and virtual money.
Open a free demo account
65% of retail investor accounts lose money when trading CFDs with this provider.