TRADINGVIEW ALERTS TO METATRADER TRADE COPIER

 

This is the user guide for 'TradingView Alerts to MetaTrader' trade copier.


This signal/trade copier for TradingView -> MetaTrader consists of three parts:

  • Google chrome browser on your computer
  • Copier EA
  • Bridge app running over Windows OS (i.e. Windows 10/11, Windows Server 2016 or above)


That bridge app will seamlessly scan TradingView alert popup at Google Chrome and feedback to this Copier EA for trade process (through secured data interchange).

The reason to use TradingView alert popup is that's available for all users - while other alert approach, e.g. webhook, might be applicable only for paid members.


1. Please download Google Chrome browser if you haven't it at your computer.


2.  Install MT4 or MT5 copier EA. 


Put “TVToMT4Copier.ex4” or “TVToMT5Copier.ex5” to \MQL4\Experts\ or \MQL5\Experts\ folder.


At MT4 or MT5, “Menu” → “Tools” → “Options”, at below selection, click “Allow DLL Import” - as this EA needs network authentication for use.




Open any chart and attach this Copier EA to chart. At the first EA variable, please enter your license key.  And also enable algo or auto trading at MT5 or MT4.    



> Please attach this copier EA to one MT4 or MT5 chart ONLY.  One copier EA can accommodate multiple TradingView chart alerts.


If you have two more symbols to copy, please kindly refer to 'Special Note for Multiple Symbol Copy' section below.


* If you don't have Chrome installed at your computer or VPS, please install Chrome in advance.


3. Unzip TVBridge.zip file. This is the bridge app that will run over Windows OS.


4. Go to TVBridge unzipped folder and modify config.ini file.

input your license key at license_key=

e.g. license_key=abc+metatrader@gmail.com

you could set browser width and height variable or just use the default.

save this config.ini file





 5. Start TVBridge app.


6. After license check, click 'Start' button of bridge app.




It will print a message:


'Have enabled a new session of special mode of Chrome.  Please login your TradingView account at that Chrome.  To click 'Start' button again will close that Chrome'.  


It will initiate a new session of special mode of your Chrome browser with TradingView home page. 




7. Please login your TradingView account at that Chrome window.


If you're using Gmail for TradingView login, please log in from TradingView 'Email' section other than 'Google' section.  



- if you have any concern on this login method, you could enable TradingView 2FA login.




8. Enable alert at your TradingView indicator - click 'Add alert on xxxx'


9. Click 'Show pop-up' and 'Create'

10.  Then the bridge app will start scanning if alert popup occurs.  Once alert is detected, it will show on the log window and feedback to Copier EA for further trade process.



11.  Please be aware the time stamp shown on bridge app is slightly different with alert time on TradingView.

TradingView uses their server time - while bridge app uses your computer time.  You could compare the TradingView's bar leftover time vs your computer time

Or you could do self calibrate your computer time to minimize the difference.



Please keep one TradingView chart opened when you receive alerts.





12. Below illustrations show the live trade copy at MT4/MT5:




This copier is to fetch TradingView alert popup.  Please ensure you've selected 'Show toast notification' at that alert setup window.






MT4/MT5 Copier EA settings


Lots mode - 4 options: 'fixed lots', 'Lots by equity percentage', 'Lots by loss percentage', 'Lot info from TradingView'  Each has its own variable to set.


Symbol mapping list - that's for special trade symbol mapping.  if that's not set, EA will use the same symbol name from TradingView for trade.


if MT4/MT5 has different symbol name, please set symbol mapping to convert.

its format is:


TradingView symbol name

comma

MT4/MT5 symbol name

semi-colon


for instance


ES1!,SP500;


if two pairs, cascade this string


ES1!,SP500;NQ1!,USTEC;


Close trade by opposite signal - default is true; will close trade if opposite signal.  you could turn that off if that's not your preference

Reverse trade - default is false; if turned 'true', ea will place SHORT trade if LONG signal

TakeProfit in pointdefault is zero, i.e. no sl price will be set

StopLoss in point - default is zero, i.e. no sl price will be set

Group take profit in $ - take profit by group of trades in $ amount

Group stop loss in $ - take loss by group of trade in $ amount

Trailing stop switch - default is false, i.e. disabled 

BreakEven switch - default is false, i.e. disabled 

Use ATR as SL- default is false; Use ATR value x its multiplier as SL price; Need to set its applied timeframe.

Use SL ratio for TP- default is false; Use SL price distance to order open price multiplied by a ratio to be TP price.


Keywords for LONG or SHORT trade - EA has listed some common keywords to identify an alert message as a LONG or SHORT signal.  you could supplement your own.


Excluded keywords from opening trade - NOT to open trade if those keywords are shown at messages.


Enable close trade keywords - enable keyword check to close trade.


Keywords to close LONG or SHORT trade - EA close trades for those keywords.

If you want to close all trades, set keywords list to 'Keywords to close both LONG & SHORT trades'.


If the close trade alerts from TradingView contain xx%, EA will follow the close ratio to partially close the applicable local trades, e.g. 'close long 50%'


Taking TP price from TradingView

default is off.  If enabled, the copier EA will use the TP prices described at TradingView signal texts.

Taking SL price from TradingView

default is off.  If enabled, the copier EA will use the SL prices described at TradingView signal texts.


* For instance, if the TP/SL price text format at TradingView signals is

BUY TP:1.06218, SL:1.03218

To parse this content, below variables should be set as

TP price head strings et as

TP:

SL price head stringset as

SL:


* Please note that SL setting priority is (a) Use TradingView's, (b) ATR SL, (c) SL point.  


TP setting priority is (a) Use TradingView's, (b) Use SL ratio for TP, (c) TP point.


'Close by Trade ID' feature

This is designed for trade exit needs of TradingView martingale strategy. Default is disabled.

1. At TradingView alert message, add trade ID identity at strategy.entry and strategy.exit commnet (or alert_message) field.

e.g. trade entry:

LONG ID:LONG#1

LONG ID:LONG#2

trade exit

CLOSE LONG ID:LONG#1

CLOSE LONG ID:LONG#2

2. At MT4/MT5 copier side,

'Close trades by ID' ---> set to true to enable

'ID head string' ---> set ID: as head string to parse

'ID tail string' ---> leave blank to match above TradingView alert messag example as it has no tail string


Enable multiple TP/SL parsing from TradingView

If you want to parse multiple TP or SL from TradingView alert, enable this option.  If that alert has two TPs, the copier ea will place two separate orders with different TP prices.




At TradingView side, the alert could be something like (the values are in price other than point/tick):

Buy TP1:1245.50 TP2:1305.50 SL:1145.25


Below is the pinescript alert code snippet that you could use to modify your TradingView indicator codes:


//@version=5

indicator(title = "AlertTest Multiple TPSL", overlay = true)

tp1Ticks = 1000
tp2Ticks = 2000
slTicks = 2000

sigBuy = close >= open
sigSell = close < open

if sigBuy
    tp1Pr = close + syminfo.mintick * tp1Ticks
    tp2Pr = close + syminfo.mintick * tp2Ticks
    slPr = close - syminfo.mintick * slTicks
    alert("Bullish candle, BUY TP1:" + 
     str.tostring(tp1Pr, format.mintick) +
     " TP2:" +
     str.tostring(tp2Pr, format.mintick) +
     " SL:" +
     str.tostring(slPr, format.mintick), 
     alert.freq_once_per_bar_close)
if sigSell
    tp1Pr = close - syminfo.mintick * tp1Ticks
    tp2Pr = close - syminfo.mintick * tp2Ticks
    slPr = close + syminfo.mintick * slTicks
    alert("Bearish candle, SELL TP1:" + 
     str.tostring(tp1Pr, format.mintick) +
     " TP2:" +
     str.tostring(tp2Pr, format.mintick) +
     " SL:" +
     str.tostring(slPr, format.mintick), 
     alert.freq_once_per_bar_close)

plot(close, color = na)



Allowed symbol list

default is the blank string. it will take all symbol alerts from TradingView. if setting a string of allowed symbols, this copier ea will only accept the alert signals of those symbols.  if symbol more than one, add comma in between, e.g. EURUSD,GBPUSD.  Please use MT4/MT5 symbol names at this list.  


There are two maximum order count settings: (a) maximum order count for all symbols; (b) maximum order count for each symbol


Alert and panel setting variables are self explanatory.





QUICK NOTE FOR TRADINGVIEW STRATEGY ALERT SETTING


1. If you have that TradingView strategy source codes, below are the quickest method to add alert messages so MT4/MT5 copier can recognize with no or less setup changes.

(a) Add 

comment = "ENTER LONG"

at strategy entry for long trade.  For instance:

strategy.entry("Long", direction=strategy.long, qty=1, comment = "ENTER LONG")

(b) Add

comment = "ENTER SHORT"

at strategy entry for short trade.  For instance:

strategy.entry("Short", direction=strategy.long, qty=1, comment = "ENTER SHORT")

(c) add

comment = "EXIT LONG"

at strategy exit for long trade.  For instance:

strategy.exit("Long Stop", from_entry = "Long", qty_percent = 100, stop=low, profit=longProfitTicks, comment = "EXIT LONG")

(d) add

comment = "EXIT SHORT"

at strategy exit for long trade.  For instance:

strategy.exit("Short Stop", from_entry = "Short", qty_percent = 100, stop=low, profit=longProfitTicks, comment = "EXIT SHORT")

(e) if your strategy have strategy.close_all

add 

comment = "EXIT ALL"

at strategy.close_all 

and input

close,exit

at MT4/MT5 copier's "Keywords to close both LONG & SHORT trades" variable


2. When you enable alert setting for that TradingView strategy, just simply input

{{strategy.order.comment}}



Then all alert messages will follow what you have set at comment fields.





* How to set up and use lot info at TradingView alert 


1. select 'Lot info from TradingView' at 'Lots mode' variable


2. set lot info prefix string.

'TradingView lot info head string' - default text is 'Lot:'


For instance 

Buy Lot:2

Copier EA will use 2 lots to copy trade.


If your TradingView alert message is something like


Buy Lot 2 at 1.34563


'TradingView lot info head string' - input Lot and then one more space


That is to precisely fetch the string before and after the lot number 


3. TraidingView lot info to MT ratio

default is 1.0.  if setting 0.1, 2 lot info from TradingView will be multiplied by 0.1.  the result is 0.2 lot for copy trade.



* Special Note for Multiple Symbol Copy


1. If you have two more symbol trades to copy but each symbol has the same TP/SL/Lot setting, just attach this copier EA to one chart only. 


This copier EA can accomodate multiple symbol copies.


2. If each symbol has different TP/SL/Lot setting, there are two approaches.  You could use either one approach.


Assume EURUSD and AUDUSD are the symbols that you want to copy:


(a) Approach 1:


Open any two charts and attach the copier EA to each chart respectively.


At the first copier EA, fill in EURUSD at 'Allowed symbol list' variable.  And supplement EURUSD 'TP in Points' or 'SL in Points' or 'Lot' options at this copier EA.


At the second copier EA, fill in AUDUSD at 'Allowed symbol list' variable.   And supplement AUDUSD 'TP in Points' or 'SL in Points' or 'Lot' options at this copier EA.


BTW, please set MT4/MT5 symbol names at 'Allowed symbol list'.

 

(b) Approach 2:


If you have TradingView indicator/strategy source codes, you can attach to one chart with one copier EA.  


Write each symbol's TP price or SL price or Lot info at that TradingView alert message.


Let the copier EA to follow those TP/SL/Lot info shown on messages.  The alert message format and EA setting are listed at early explanations of this blog article.



Popular posts from this blog

FREE EVALUATION WITH LIMITED SYMBOLS

TRADE COPIER USER GUIDE LIST

METATRADER TO NINJATRADER TRADE COPIER