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

TradingView Plans
Get TradingView Plan

2. MetaTrader 5 Setup

Download TV2Broker Expert
Download MetaTrader 5

3. Expert Advisor Installation

Step 1: Open Data Folder
Open Data Folder
Step 2: Navigate to MQL5
MQL5 Folder
Step 3: Open Experts Folder
Experts Folder
Step 4: Add TV2Broker EA
TV2Broker Path

4. Configure DLL Settings

You must allow DLL imports in your MetaTrader settings to allow our Expert Advisor to communicate securely with our servers.

Allow DLL

Add the following URL to your allowed WebRequest URLs:

https://www.tv2broker.com

5. Final Configuration

Step 1: Enable Auto Trading
Enable Auto Trading
Step 2: Add TV2Broker to Chart
Add TV2Broker

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.

Accessing Alert Settings
Step 2: Configure Alert Message

In the alert window, write your signal message inside the highlighted yellow box.

Configuring Alert Message
Step 3: Set Up Webhook

In the final step, add and configure your webhook settings.

https://www.tv2broker.com/webhook
Setting Up Webhook

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.

key=001122 symbol=XAUUSD action=buy volume=0.01
key=001122 symbol=XAUUSD action=sell volume=0.01

7.2 Stop Loss & Take Profit

Add sl and tp1 in points (not pips). The EA converts points to price automatically.

key=001122 symbol=XAUUSD action=buy volume=0.01 sl=2000 tp1=2000

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.

key=001122 symbol=XAUUSD action=buy volume=0.04 sl=2000 tp1=1000 tp2=2000 tp3=3000 tp4=4000

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).
key=001122 symbol=XAUUSD action=buy volume=0.01 betrg=30 beofst=0

When profit reaches 30 points, SL moves to entry price (offset = 0).

key=001122 symbol=XAUUSD action=buy volume=0.01 betrg=50 beofst=5

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.
key=001122 symbol=XAUUSD action=buy volume=0.01 trailtrig=30 traildist=20 trailstep=5

When profit reaches 30 points, SL trails 20 points behind price, updating every 5 points.

key=001122 symbol=XAUUSD action=buy volume=0.01 trailtrig=0 traildist=20 trailstep=5

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.

key=001122 symbol=XAUUSD action=buy volume=0.01 tf=1h

This order gets a unique magic number for "1h" timeframe. Close actions with tf=1h will only close these positions.

key=001122 symbol=XAUUSD action=buy volume=0.01 tf=15m

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)
key=001122 symbol=XAUUSD action=buylimit volume=0.01 price=2500
key=001122 symbol=XAUUSD action=sellstop volume=0.01 price=2500 sl=2000 tp1=2000

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)
key=001122 symbol=XAUUSD action=closeall

Closes ALL positions and cancels ALL pending orders for this symbol.

key=001122 symbol=XAUUSD action=closebuy tf=1h

Closes only buy positions tagged with tf=1h. Other timeframes are not affected.

key=001122 symbol=XAUUSD action=closesell

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.

key=001122 symbol=XAUUSD action=buy volume=0.05

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).

key=001122 symbol=XAUUSD action=buy volume=5 sl=2000

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).

key=001122 symbol=XAUUSD action=buy volume=500 sl=2000

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.

7.10 Order Comments

Add a comment to tag your orders. The comment appears in MT5 terminal and trade history.

key=001122 symbol=XAUUSD action=buy volume=0.01 comment=My Strategy

Full Example (All Parameters)

A complete signal with all parameters combined:

key=001122 symbol=XAUUSD action=buy volume=0.04 sl=2000 tp1=1000 tp2=2000 tp3=3000 tp4=4000 betrg=50 beofst=5 trailtrig=100 traildist=20 trailstep=5 tf=1h comment=Scalp

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 order
    • Auto_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=2000 means 2000 points below entry (buy).
  • Prices — SL and TP are sent as exact price levels. Example: sl=2400.50 means 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 signals
    • Ignore New Signals — Keeps open positions but blocks new signals
    • Close 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)

Chat with us now if you need help and we'll walk you through every step.

Scroll to Top