Convert a Pine Script strategy to trade on MT5
Already have your own TradingView strategy or indicator? The Pine Converter in your MT5 Bridge dashboard adds the MetaTrader 5 alert messages to it, so every signal it gives becomes an MT5 order, and the alert needs nothing typed in its Message box.
What the converter does
- Strategies: every entry, exit and close sends the matching MT5 order.
- Indicators: each
alertcondition()oralert()that says buy, sell, long, short, exit or close does. - Reversals: on MT5 a sell never closes a buy, so the converted code closes the other side itself before it reverses.
- Your logic is not changed. The converter adds an MT5 Bridge group of inputs and the alert messages; it does not touch how your script decides to trade.
Step by step
- Convert. In the dashboard open Pine Converter, pick Indicator or Strategy, paste your whole Pine script and press Convert. Copy the converted code. Every conversion is kept in your Converted history.
- Put it in TradingView. Open the Pine Editor, replace the code with the converted code, then Save and Add to chart.
- Fill in the inputs. Double-click the script's name on the chart (or its gear) and open Inputs. In the MT5 Bridge group paste your MT5 API key (from MT5 Accounts), set the Strategy tag and the Lot size, then press Ok. Until a key is in, the chart shows a red reminder.
- Create one alert. Click Alert (the clock icon) and pick your script as the condition. For a strategy choose Order fills only if offered; for an indicator choose Any alert() function call.
- Message. For a strategy, replace the Message with exactly:
For an indicator, leave the Message as it is: the script writes it.{{strategy.order.alert_message}} - Webhook. Open Notifications, tick Webhook URL, paste
https://mt5bridge.net/webhookand press Create.
The Lot size tick box
- Ticked: every trade uses the lot size you type next to it.
- Unticked: the size your script works out itself is used (a strategy's quantity, or an indicator's lot or qty variable). If your script has none, your MT5 account's own sizing is used.
Test on a demo account first. Every alert shows on Webhook Alerts in
the dashboard with what happened to it, so you can see each signal reach MT5 before trading live.
Common questions
Does the converter need my TradingView password?
No. You paste the script yourself and copy the result back; the bridge never signs in to TradingView.
Which Pine versions work?
Pine Script version 5 and version 6, both strategies and indicators.
Can I still change my strategy later?
Yes. Edit your original script, convert it again and replace the code in TradingView. Then delete the old alert and create it again: a TradingView alert keeps running the version of the script it was created with.
Risk warning. A strategy that did well on past data can lose money live.
Trading forex, metals, indices, CFDs and crypto is high risk; only trade money you can afford to lose.
Convert your first script. The Pine Converter is in every MT5 Bridge account, and
your first MT5 account trades free for 7 days.
Create your account
Create your account