Overview

Convert MT5 (MQL5) to Pine Script

Use HorizonAI to transform MQL5 into Pine Script for TradingView

Convert your MetaTrader 5 (MQL5) indicators and Expert Advisors to TradingView Pine Script using HorizonAI's AI-powered conversion tools.

One-Click Converter (Pro & Elite)

New! Pro and Elite users can now use our dedicated converter for instant script conversion.

If you're on the Pro or Elite plan, you can use our streamlined one-click converter:

  1. Go to app.horizontrading.ai/convert
  2. Upload or paste your MQL5 code
  3. Click Convert to Pine Script
  4. Copy your converted Pine Script code to TradingView

That's it — no prompting required. The converter handles the translation automatically, mapping MQL5 logic to Pine Script equivalents.

Open Converter →

Chat-Based Conversion (All Plans)

All users (including Free and Starter) can convert scripts using the AI chat. This method gives you more control over the conversion process and lets you ask questions along the way.

Before you start

  • Create a free HorizonAI account and sign in.
  • Have your MQL5 source code ready to paste.

1) Create a new script in HorizonAI

  • Click New Script.
  • When asked for a language, choose Pine Script — this is the target language you want to receive.

You always select the language you want to end up with. For MT5 → Pine, pick Pine Script.

2) Choose "I have existing code"

  • Select Existing code.
  • Paste your existing MQL5 code into the input.

3) Ask HorizonAI to convert

  • In the prompt, say: "Please convert this MetaTrader 5 (MQL5) code into Pine Script."
  • Click Go.

4) Review and run in TradingView

  • HorizonAI will produce Pine Script based on your MQL5 code.
  • Copy the result into TradingView's Pine Editor, then click Add to chart.

If it's a strategy, you can open Strategy Tester for a performance report. For indicators, adjust inputs and verify visuals on the chart.


Tips for better conversions

  • Mention whether the MQL5 code is an indicator or an Expert Advisor (strategy) so logic maps correctly.
  • Provide context like timeframe, symbol, or broker assumptions.
  • List configurable inputs you want exposed in Pine via input.*.

FAQs

  • Does it work for EAs and indicators? Yes. Clarify which one you're converting.
  • What if TradingView errors on add-to-chart? Paste errors back into HorizonAI and ask for a fix.
  • Can I iterate? Yes. Update your prompt or paste revised MQL5 code and regenerate.

Next Steps

Once you've converted your MT5 code to Pine Script:

Deploy on TradingView:

Learn More:

Related Conversions: