Our partnerSkilling
  • Spreads from 0.1 pips
  • 1,000+ instruments
  • Free demo account

65% of retail investor accounts lose money when trading CFDs with this provider.

SkillingOpen account
Module 3 · Build and test strategies with AI

3.2 Let AI write the code

Lesson 11 of 26Reading time: 2 minFact-checked

You no longer need to be a programmer to test a strategy. Language models can write code for most platforms.

PlatformLanguageSuited to
TradingViewPine ScriptIndicators, alerts and simple backtests
MetaTrader 4 and 5MQL4 and MQL5Robots (Expert Advisors)
cTraderC# (cBots)Robots
Your own computerPythonFlexible tests and data analysis
Use AI as an assistant – not an oracleAskPrecise promptAI answersSuggestions and codeVerifyCheck numbers and sourcesTestBacktest and demoYou decideYour own risk managementLanguage models can be wrong with great confidence (“hallucinate”). You are the one responsible –and it's your money – when you trade.
AI writes – you check, test and decide.

How to get better code

  1. State the rules precisely – ideally as numbered points.
  2. Give the platform and version, for example “Pine Script version 6”.
  3. Ask for comments that explain each part.
  4. Paste in the error messages you get, and ask the AI to fix them.
  5. 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.