Skip to Content
Platform FeaturesExporting Strategies

Exporting Strategies

Learn how to export your trading strategies to MetaTrader 5 (MT5) and TradingView for live trading or further analysis.

Overview

Once you’ve developed and backtested a strategy in Lona, you can export it to popular trading platforms:

  • MetaTrader 5 (MT5): Professional trading platform for forex, stocks, and futures
  • TradingView: Popular charting platform with Pine Script support

The export system converts your strategy from Lona’s internal format to platform-specific code, ready for deployment.

Starting an Export

Where to Find Export

  1. Open your strategy from the Strategies section
  2. Look for the Export button in the strategy details panel
  3. Click to open the export dialog

Export Dialog

The export dialog has two main sections:

  • Platform Selection: Choose between MT5 or TradingView
  • Export Options: Configure how the export is processed

Choosing Your Platform

MetaTrader 5 (MT5)

Best For:

  • Professional traders using MT5 terminals
  • Forex and CFD trading
  • Automated trading (Expert Advisors)
  • Brokers that support MT5

Output: MQL5 source code (.mq5) and optionally compiled binary (.ex5)

TradingView

Best For:

  • Chart-based trading
  • Visual strategy analysis
  • Alert-based trading
  • Sharing strategies with community

Output: Pine Script v5 code (.pine)

Export Options

Common Options (Both Platforms)

Include Strategy Parameters

  • What it does: Exports adjustable input parameters
  • When enabled: Traders can modify settings without editing code
  • Recommendation: Keep enabled for flexibility

Include Documentation

  • What it does: Generates README with installation instructions
  • When enabled: Includes step-by-step setup guide
  • Recommendation: Keep enabled

MT5-Specific Options

Compile to Executable

  • What it does: Compiles MQL5 source to binary .ex5 file
  • When enabled: Ready-to-use file, no compilation needed by end user
  • Trade-off: Takes extra processing time (30-60 seconds)
  • When to use: Final production version, sharing with others

TradingView-Specific Options

Include Alert Conditions

  • What it does: Adds alert() function calls for trading signals
  • When enabled: Enables TradingView alert notifications
  • Recommendation: Keep enabled if using alerts

The Export Process

After clicking Export, you’ll see real-time progress:

ProgressStageDescription
10-20%AnalysisAI analyzes your strategy structure
30-40%Event MappingConverts Lona events to platform equivalents
50-60%Code GenerationCreates platform-specific code
70-75%ValidationChecks code for errors
85-90%CompilationCompiles to binary (MT5 only, if enabled)
95-100%PackagingCreates downloadable archive

Processing Time:

  • Simple strategies: 30-60 seconds
  • Complex strategies: 1-3 minutes
  • MT5 compilation adds 30-60 seconds

Automatic Error Recovery

If the system detects validation errors:

  • Automatically retries up to 3 times
  • Each retry improves the generated code
  • You can cancel if taking too long

Download and Files

What You Receive

When export completes, you’ll receive a ZIP archive containing:

For MT5 Exports:

strategy_name_mt5.zip ├── strategy_name.mq5 # MQL5 source code ├── strategy_name.ex5 # Compiled binary (if enabled) ├── metadata.json # Strategy analysis data ├── validation_report.json # Quality check results └── README.txt # Installation instructions

For TradingView Exports:

strategy_name_tradingview.zip ├── strategy_name.pine # Pine Script v5 code ├── metadata.json # Strategy analysis data ├── validation_report.json # Quality check results └── README.txt # Installation instructions
  • Success dialog appears with download button
  • Download link valid for 24 hours
  • Save the file before the link expires

Installing Exported Strategies

MT5 Installation

Step 1: Locate MT5 Data Folder

Windows:

C:\Users\[Username]\AppData\Roaming\MetaQuotes\Terminal\[Instance]\MQL5\Experts

Mac (with Wine):

~/Library/Application Support/MetaTrader 5/drive_c/Program Files/MetaTrader 5/MQL5/Experts

Step 2: Copy Files

  • Extract the ZIP archive
  • Copy .mq5 file (and .ex5 if available) to the Experts folder

Step 3: Enable in MT5

  1. Open MetaTrader 5
  2. View → Navigator (Ctrl+N)
  3. Expand “Expert Advisors”
  4. Find your strategy
  5. Double-click to attach to a chart
  6. Enable AutoTrading in toolbar

Note: If you only have .mq5, MT5 will compile it automatically on first use.

TradingView Installation

Step 1: Open Pine Editor

  1. Go to TradingView.com
  2. Open any chart
  3. Click “Pine Editor” at bottom of screen

Step 2: Add Your Strategy

  1. Extract the ZIP archive
  2. Open the .pine file in a text editor
  3. Copy all the code
  4. Paste into Pine Editor
  5. Click “Add to Chart”

Step 3: Configure Alerts (Optional)

  1. Click the three dots on your strategy
  2. Select “Add Alert”
  3. Choose alert conditions
  4. Set notification preferences

Understanding Export Files

metadata.json

Contains information about your strategy:

  • Export ID and timestamp
  • Detected indicators and parameters
  • Strategy complexity assessment
  • Event mappings used

validation_report.json

Quality assurance results:

  • Pass/fail status
  • Any errors or warnings found
  • Suggestions for improvement
  • Compilation results (MT5)

README.txt

Installation guide including:

  • Platform-specific setup steps
  • Parameter configuration help
  • Troubleshooting tips

Supported Features

Technical Indicators

The export system supports common indicators:

  • Moving Averages (SMA, EMA)
  • RSI (Relative Strength Index)
  • MACD
  • Bollinger Bands
  • Stochastic Oscillator
  • ATR (Average True Range)
  • And many more

Trading Events

Lona events are converted to platform equivalents:

Lona EventMT5 HandlerTradingView
on_bar_closeOnTick()On each bar
on_position_openedOnTradeTransaction()strategy.entry()
on_position_closedOnTradeTransaction()strategy.close()

Troubleshooting

”Export Failed” Error

Possible Causes:

  • Strategy code has unresolved issues
  • Network connection interrupted
  • Server temporarily unavailable

Solutions:

  1. Verify your strategy runs successfully in backtest
  2. Check your internet connection
  3. Try again in a few minutes

”Validation Failed After Retries”

Possible Causes:

  • Complex strategy logic difficult to convert
  • Unsupported indicator or feature

Solutions:

  1. Simplify strategy if possible
  2. Download the partial export and modify manually
  3. Contact support for assistance

”Compilation Errors” (MT5)

Possible Causes:

  • MQL5 syntax issues in generated code
  • Missing dependencies

Solutions:

  1. Open .mq5 file in MetaEditor
  2. Review error messages
  3. Make manual corrections if needed
  • Export links are valid for 24 hours
  • Re-run the export to get a new download link
  • Save exports locally as backup

Best Practices

Before Exporting

  • Ensure backtest results are satisfactory
  • Verify all parameters have reasonable defaults
  • Test with different market conditions
  • Document any special requirements

After Exporting

  • Test in demo/paper trading first
  • Verify indicator calculations match
  • Check entry/exit signals fire correctly
  • Monitor for any behavioral differences

Platform-Specific Tips

For MT5:

  • Use compiled .ex5 for production
  • Test on demo account before live
  • Check spread and slippage settings

For TradingView:

  • Test alert conditions manually first
  • Verify bar timing matches expectations
  • Check strategy tester results

Limitations

What Cannot Be Exported

  • Strategies using unsupported data types
  • Complex portfolio-level operations
  • Real-time external data feeds
  • Custom visualization components

Platform Differences

Exported strategies may behave slightly differently due to:

  • Bar timing differences
  • Order execution models
  • Available indicator implementations
  • Platform-specific limitations

Important: Always validate exported strategies with thorough testing before live trading.

Quick Reference

TaskWhere to Find It
Start ExportStrategy details → Export button
Choose PlatformExport dialog → Platform tab
Configure OptionsExport dialog → Options section
Monitor ProgressProgress dialog during export
Download ResultSuccess dialog → Download button
View Installation GuideREADME.txt in ZIP archive

What’s Next?

After exporting your strategy:

  • Test thoroughly in demo/paper trading mode
  • Monitor performance and compare with backtests
  • Iterate on parameters in the target platform
  • Consider creating variations for different markets

Related Pages:

Last updated on