So many brokers use MT4&5 to provide robust functionality to traders. We have built a bot that trades for you on the platform from your commands. TradingView to Metatrader will provide you with a webhook that connects to your account and allows opening and closing of trades automatically! Make sure to install the EA on your metatrader and add the webhook you received in the settings. You can download the bots to use here
- Metatrader 4 Automation EA and Trade Plugin
- Metatrader 5 Automation EA and Trade Plugin
Here is how it works.
The Syntax: [command] [symbol] [param]=[value]
- command specifies what we will do like buy, close, sell or cancel
- symbol specifies which coin to perform the command on like EURUSD. It can be ommitted in some commands like checking the balance.
- param grants us control of specific features like price and quantity. Most parameters are shortened using the first letter such as price can be sent as p or price
- value specifies the param value. Example: quantity=20%. Below are the list of all supported parameters.
-
Price (P)
The entry price of your order. It converts your trade to a stop or limit order. Specified as the price value, as a percentage of the current market price, or as points. For example P=2%, P=1.1234, P=200 -
Quantity (Q - opening OQ and closing CQ)
Can be sent in lot size or percentage. The default is the minimum lot size if it is not set. -
Type (T - buy, long, 1, sell, short, -1)
You can filter what type of trade to close by adding the type parameter. -
Stop_Loss (SL) and Take_Profit (TP)
Similar to price, It can be specified in points, price, or percentage from the entry price. -
Magic (M)
A unique number to identify your trades. You can use this to identify different strategies. -
Expiry (E)
Set the expiry period for pending orders in minutes. Example E=30. -
Session (S)
Set the market session to execute trades. Example: S=06:23-12:32. -
Orders (O)
Specify the number of orders you want to apply a command to. -
Orders_Offset (OO)
Specify the number of orders to skip chronologically.
For advanced functionality like trailing, break even and news filters, you will need the trade plugin added on another chart otherwise the parameters below will have no effect.
-
Trailing Trigger (TT) – The point at which your trailing stop loss for open trades will trigger. It can be specified in points or as a percentage.
-
Trailing Distance (TD) - This is the distance between which your stop loss and the current market price should be maintained. It can be specified in points or as a percentage.
-
Trailing Step (TS) - This is the number of points/percentage movement in the market after which your SL should be adjusted. It can be specified in points or as a percentage.
For your own testing, you can add :ignore to any command to exclude everything else after the notation. This is useful if you want to add helpful text to see later.
Example:sell EURUSD :ignore price=299
Supported Commands
- Opening a trade
- Modifying an open trade
- Cancelling a pending order
- Closing a trade
- Checking the balance
Opening a Trade
Annotations: buy, long, 1, sell, short, -1
Parameters Allowed are P, Q, OQ, M, SL, TP, TT, TD, TS, BE and E
TradingView offers placeholders that can generate the words buy
, sell
, long
or short
automatically. You can use commands like {{strategy.order.action}}
while creating strategy alerts to transform your commands. See below on Advanced usage.
-
buy
will buy the minimum lot size on the symbol containing the EA. It is not advisable to omit the symbol as your commands become harder to analyze. -
sell AUDCAD sl=100 tp=200
will open a sell trade on AUDCAD with a stop loss of 100 points away or 10 pips and a risk reward of 1:2 as the take profit is double the stop loss.
Modify Existing Trades
Annotations: modify, update
Parameters Allowed are O, OO, S, T, TP, SL and M.
You can update the existing TP and SL of already open trades by sending new values
-
update EURUSD orders=2 oo=2 sl=10 tp=1.234
will modify the last 2 orders if I have 4 orders open to have a stop loss of 1 pip and a precise take profit at that price.
Cancelling Pending Orders
Annotations: cancel, exit
Parameters Allowed are O, OO, S, T and M.
Orders that have not become open trades are canceled instantly by this command.
-
cancel EURUSD orders=2 oo=2
will cancel the last 2 orders if I have 4 orders open.
Closing a position
Annotations: close, flat and 0 (zero)
Parameters Allowed are Q, CQ, M, O, OO, S and T
-
close USDJPY q=50% t=long
will close half of the total open lots in the market for buy trades. -
close GBPUSD
will close all GBPUSD trades.
View Balance
Annotations: bal, balance, funds
No custom parameters are accepted
-
funds
will return your account balance
Advanced Use Case
You can also combine commands using TradingView placeholders.
{{strategy.market_position}} SOLUSDT OQ=10% CQ=100% L=5
opens a market position when the strategy says long or short of 10% with 5X leverage the USDT balance and closes the whole position when the strategy says flatSee more about how to generate tradingview dynamic alerts using placeholders