Setup Guide
Follow these steps to set up TV2Broker EA with TradingView and MetaTrader 5
1. TradingView Requirements
TradingView Essential Plan or Higher Required
Note: You can start with TradingView's Free Trial of Essential plan or higher
2. MetaTrader 5 Setup
Download TV2Broker Expert
3. Expert Advisor Installation
Step 1: Open Data Folder
Step 2: Navigate to MQL5
Step 3: Open Experts Folder
Step 4: Add TV2Broker EA
4. Configure DLL Settings
You must allow DLL imports in your MetaTrader settings to allow our Expert Advisor to communicate securely with our servers.
Add the following URL to your allowed WebRequest URLs:
5. Final Configuration
Step 1: Enable Auto Trading
Step 2: Add TV2Broker to Chart
6. TradingView Alert Setup
Visit TradingView's charting platform at: https://www.tradingview.com/chart/
Step 1: Access Alert Settings
From the top of the chart, locate and click on the Alert option.
Step 2: Configure Alert Message
In the alert window, write your signal message inside the highlighted yellow box.
Step 3: Set Up Webhook
In the final step, add and configure your webhook settings.
7. Signal Parameters & Examples
Below are all supported parameters you can send in your TradingView alert message. Write each parameter on a separate line. Parameters are case-insensitive.
7.1 Market Orders (Buy / Sell)
Open a market buy or sell order. Required fields: key, symbol, action.
7.2 Stop Loss & Take Profit
Add sl and tp1 in points (not pips). The EA converts points to price automatically.
SL = 2000 points below entry. TP1 = 2000 points above entry.
7.3 Multiple Take Profits (TP1 - TP4)
Send up to 4 take-profit levels. The EA opens a separate order for each TP, each with the same volume.
Each TP gets the same volume. Volume 0.04 with 4 TPs = 4 orders, each with 0.04 lots.
7.4 Breakeven (BE)
Move Stop Loss to entry price when profit reaches the trigger distance.
Parameters:
betrg— Breakeven trigger in points (profit distance to activate BE). Set to 0 to disable BE.beofst— Breakeven offset in points (how far above/below entry to place SL). Default = 0 (SL at exact entry).
When profit reaches 30 points, SL moves to entry price (offset = 0).
When profit reaches 50 points, SL moves to entry + 5 points (locks small profit).
7.5 Trailing Stop
Trail the Stop Loss behind price as profit increases.
Parameters:
trailtrig— Trailing trigger in points (profit distance to activate trailing). Set to 0 to start trailing immediately.traildist— Trailing distance in points (how far behind price the SL follows).trailstep— Trailing step in points (minimum movement before SL updates). Default = 10.
When profit reaches 30 points, SL trails 20 points behind price, updating every 5 points.
trailtrig=0 means trailing starts immediately (SL trails from the first tick).
7.6 Timeframe Tagging
Tag orders with a timeframe so you can close only specific timeframe positions. The EA assigns a unique magic number to each timeframe.
Parameter: tf — Timeframe string (case-insensitive).
Supported: 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 1D, 1W, or any custom string.
This order gets a unique magic number for "1h" timeframe. Close actions with tf=1h will only close these positions.
No tf = general (no timeframe filter). Close actions without tf will close all positions.
Note: TradingView uses "1M" for 1 Month and "1m" for 1 Minute. Since the EA is case-insensitive, both map to the same magic number. Use a different label for monthly timeframes (e.g., "1mo").
7.7 Pending Orders
Place pending orders at a specific price. Required: price (the pending order price).
Supported actions:
buylimit— Buy Limit (below current price)selllimit— Sell Limit (above current price)buystop— Buy Stop (above current price)sellstop— Sell Stop (below current price)
Pending orders support SL, TP, timeframe, and all other parameters just like market orders.
7.8 Close Actions
Close positions and cancel pending orders. Timeframe filter is optional.
Supported actions:
closebuy— Close all buy positions (and cancel buy pending orders)closesell— Close all sell positions (and cancel sell pending orders)closeall— Close all positions (and cancel all pending orders)
Closes ALL positions and cancels ALL pending orders for this symbol.
Closes only buy positions tagged with tf=1h. Other timeframes are not affected.
Closes all sell positions (no timeframe filter = all timeframes).
7.9 Volume / Lot Size
The EA supports 3 lot size modes, configured in the Expert Advisor settings:
Mode 1: Fixed Lot
Uses a fixed lot size for every order. No SL required in the signal.
If volume is sent in the signal, it overrides the EA setting. If not sent, EA uses the FixedLot from Expert settings.
Mode 2: Balance Percentage
Calculates lot size based on a percentage of account balance. sl must be sent in the signal. If SL is not sent, EA falls back to Fixed Lot mode. Send volume as the percentage (e.g., volume=5 means risk 5% of balance).
volume=5 means risk 5% of account balance. EA calculates lot size so that if SL is hit, you lose only 5% of your balance. If volume is not sent, EA uses the Risk Balance % from Expert settings.
Mode 3: Risk Amount (in dollars)
Calculates lot size based on a fixed dollar amount to risk. sl must be sent in the signal. If SL is not sent, EA falls back to Fixed Lot mode. Send volume as the dollar amount (e.g., volume=500 means risk $500).
volume=500 means risk $500. EA calculates lot size so that if SL is hit, you lose only $500. If volume is not sent, EA uses the Risk Amount from Expert settings.
Full Example (All Parameters)
A complete signal with all parameters combined:
Buy 0.04 XAUUSD on 1h timeframe with SL=2000pts, 4 TP levels, breakeven at 50pts profit (offset 5pts), trailing starts at 100pts (dist=20, step=5), comment "Scalp".
8. EA Settings Guide
These settings are configured in the Expert Advisor inputs when you attach TV2Broker to your chart. They are not sent in the TradingView alert message.
8.1 Risk Management
- Lot size mode — Choose how lot size is calculated:
FixedLot— Uses a fixed lot size for every orderAuto_Lot— Calculates lot size as a percentage of account balance (requires SL in signal)Risk_Amount— Calculates lot size based on a fixed dollar amount to risk (requires SL in signal)
- Default lot size — The fixed lot size used when mode is FixedLot, or as fallback when SL is not sent
- Risk Balance % — The percentage of balance to risk (used in Auto_Lot mode)
- Risk Amount — The dollar amount to risk (used in Risk_Amount mode)
8.2 Target Type (Points / Prices)
Controls how the EA interprets sl and tp values in signals:
- Points — SL and TP are sent as distance in points from entry price. Example:
sl=2000means 2000 points below entry (buy). - Prices — SL and TP are sent as exact price levels. Example:
sl=2400.50means SL at price 2400.50.
8.3 Symbol Settings
- Symbol Prefix — Added before the symbol name. Example: prefix "." turns "XAUUSD" into ".XAUUSD"
- Symbol Suffix — Added after the symbol name. Example: suffix "m" turns "XAUUSD" into "XAUUSDm". Leave empty for auto-detection.
- Symbol Mapping — Map TradingView symbols to broker symbols. Example: "USOIL:WTI" maps USOIL to WTI. Multiple mappings separated by comma.
8.4 Pyramiding (Position Scaling)
Allows the EA to open multiple orders on the same symbol in the same direction.
- Enable Pyramiding — Turn ON/OFF the pyramiding feature
- Max Pyramid Orders — Maximum number of orders per direction (0 = unlimited)
- Entry 2-10 — Lot size for each additional entry. Entry 1 uses the default lot size. Leave 0 to skip that entry index.
- Use Last Defined Lot — If true, entries beyond Entry 10 use the last defined lot size
8.5 Trading Parameters
- Max Lot Size — Maximum lot size per order. EA will not exceed this value.
- Max Open Orders — Maximum number of simultaneously open positions (0 = unlimited)
- SL Shift (points) — Shifts the Stop Loss by X points. Example: SL=2000 + SLShift=50 = actual SL at 2050 points.
- TP Shift (points) — Shifts the Take Profit by X points.
- Entry Shift (points) — Shifts the pending order entry price by X points.
- Start Time / End Time — Trading session window (server time). EA ignores signals outside this window.
- Max Spread — Maximum allowed spread in points (0 = no limit). EA skips signals when spread is too high.
8.6 Daily Profit/Loss Limits
Automatically stops trading when daily profit or loss reaches the configured limit.
- Enable Max Daily Profit — Turn ON/OFF the daily profit limit
- Max Daily Profit — Maximum realized profit per day (0 = no limit)
- Enable Max Daily Loss — Turn ON/OFF the daily loss limit
- Max Daily Loss — Maximum realized loss per day (0 = no limit)
- Daily Limit Action — What happens when limit is reached:
Close Active Orders— Closes all open positions but continues accepting new signalsIgnore New Signals— Keeps open positions but blocks new signalsClose and Ignore— Closes all positions and blocks new signals
8.7 Account Profit/Loss Limits
Stops trading when total account profit or loss reaches the configured limit (not daily — cumulative).
- Enable Account Profit Limit — Turn ON/OFF the account profit limit
- Account Profit Limit — Total account profit that triggers stop (0 = no limit)
- Enable Account Loss Limit — Turn ON/OFF the account loss limit
- Account Loss Limit — Total account loss that triggers stop (0 = no limit)
- Account Limit Action — Same options as Daily Limit Action (see above)
7.10 Order Comments
Add a
commentto tag your orders. The comment appears in MT5 terminal and trade history.