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

The fastest way to convert. It's available to every signed-in user — the converter is metered by your tokens, just like the chat, so there's no separate plan to unlock.

Use the dedicated converter for a hands-off translation:

  1. Go to app.horizontrading.ai/convert
  2. Paste your MQL5 code, or click Upload File (.pine, .mq5, .mq4, .cs, .txt). The converter auto-detects the language — then click Continue.
  3. Under Convert to:, choose Pine Script (TradingView), then click Convert.
  4. When it finishes, the converted script opens in the chat. From there you can review it, click Copy Code, and paste it into TradingView.

The converter uses a real AI translation (not a lookup table), so the trade logic actually carries across. Pick Premium for the highest-quality result, or Basic to spend fewer tokens.

Open Converter →

The converter works in every direction across all three languages — Pine Script, MetaTrader 5 (MQL5), and NinjaScript (NinjaTrader 8). Paste any of them and pick any of the others as your target. New to NinjaScript? See Running NinjaScript on NinjaTrader 8.


Convert inside the chat (alternative)

Prefer to talk it through? You can also convert in a normal chat, which lets you ask questions and refine as you go.

Before you start

  • Sign in to HorizonAI (every account starts with a free trial).
  • Have your MQL5 source code ready to paste.

1) Start a new Pine Script

  • Click New Script to open the "What do you want to build?" page.
  • Set the language toggle to Pine Script — the target language you want to receive.

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

2) Paste your MQL5 code

  • Expand "Have existing code? Paste it here to edit" and paste your MQL5 code into the box.

3) Ask HorizonAI to convert

  • In the prompt box, type: "Convert this MetaTrader 5 (MQL5) code into Pine Script."
  • Click Start building →.

4) Review and run in TradingView

  • HorizonAI produces the Pine Script in the Code panel.
  • Click Copy Code, paste it 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: