Overview

Convert MT5 (MQL5) to Pine Script

Use HorizonAI to transform MQL5 into Pine Script for TradingView

Follow these steps to convert an existing MQL5 indicator or Expert Advisor into TradingView Pine Script using HorizonAI.

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.