MetaTrader is a popular online Forex trading platform supported by many different brokers. You can open positions and orders, check balance, cancel, close and modify trades and also retrieve the account balance.
How It Works
TradingView to MT5 allows you to automate your TradingView strategy or indicators by creating alerts on your chart and setting the alert message according to the commands below. This platform uses a telegram channel to manage your alerts and show the results in realtime.You can also manually trade from Telegram by typing your command in the message box of the channel that has the designated TradingView.to bot, or send your alerts to the webhook you create using the Alert Detector TTA extension. For strategies, you can generate the action automatically when your alert is fired using placeholders like {{strategy.market_position}} to generate an action for buy, sell and flat. See more about generating dynamic alerts here.
Note: You only need to attach the Expert Advisor to one chart on MetaTrader. It will automatically allow trading on all pairs offered by your broker.
Commands
Syntax : action symbol param=value
Example : buy EURUSD Quantity=0.1
Commands are not case sensitive. Example:
Both buy EURUSD QuantiTY=0.1 and Buy eurusd Quantity=0.1 are correct.You can send up to 5 commands by adding new ones in the next line. Example:
buy EURUSD q=0.01Sell AUDCAD tp=100 Quantity=0.1close Gold type=buy
One word parameters can be sent as the full word or the first letter of the word . Example: Both
buy EURUSD q=0.1andbuy EURUSD quantity=0.1result to the same thing.There should be no spacing between the param and value in a command.
buy EURUSD quantity = 1is wrong and should bebuy EURUSD quantity=1
1. Open a Buy Or Sell Trade
buy, long, 1 are recognized for buy trades while sell, short, -1 are sell commands .
Optional Parameters
Quantity (Q) - The size of a trade in lots or percentage. Can also be Opening Quantity (OQ) Default is the minimum lot size for that symbol. When using percentage, if the SL is not passed, the lot size calculated as (Balance*risk*Leverage)/10000000.
Price (P) - Converts the trade into a limit/stop order. Can be actual price, percentage, or points.
Take Profit (TP) - Price where you want to close the position in profit. Can be actual price, percentage, or points
Stop Loss (SL) - Price to cut loss if market moves against the trade. Can be actual price, percentage, or points.
Magic (M) - A unique number identifier for different strategies.
Trailing Trigger (TT) - The point at which the trailing stop loss triggers, specified in points or percentages.
Trailing Distance (TD) - Distance to maintain between the stop loss and current market price. Specified in points or percentages.
Trailing Step (TS) - Increment at which the stop loss adjusts, specified in points or percentages.
Balance (B) - Minimum balance required to open a trade.
Gap (G) - Maximum allowed spread to open a trade.
Expiry (E) - Expiry period for pending orders in minutes.
Session (S): Market session for executing trades. Example:
S=06:23-12:32Delay (D): Adds a delay in command execution. The maximum delay is 5 seconds.
Note:
You can generate dynamic prices for P, TP, and SL parameters in MetaTrader using four placeholders:
Open,High,Low,Close,Highest, andLowest.TT, TD, and TS are used together to achieve Trailing.
Examples:
buy P={highest[5]}- places a buy stop of the current symbol that the EA is running on at the highest price of the last 5 candles as per your chart timeframe.
sell AUDCAD TP={close[1]}places a sell trade with take profit at the closing price of the last candle.
Buy EURUSD Q=0.5 p=1.23456 E=10opens a buy limit order if the market price is greater than 1.23456 otherwise a sell stop, that expires in 10 minutes if not filled.
Sell EURUSD Q=0.5 p=-2%places a sell limit order at a price 2% above the current market price.
-1 EURUSD q=0.1 G=20 B=500opens a short trade on your account only if the spread is less than 20 points and the account balance is equal to or more than 500
Buy EURUSD Q=0.5 P={highest[5]} TP={close[1]} SL={lowest[10]}places a buy stop on the highest price in the last 5 candles. The TP is the last close and stop loss is the lowest price for the last 10 candles.
{{strategy.order.action}} EURUSD Q=0.5 TT=100 TD=50 TS=10dynamically changes between buy and sell based on strategy execution. Trailing starts when profit reaches 10 pips, stop Loss is trailed at a distance of 5 pips behind the current price and stop Loss is moved every 1 pip the price moves in favor of the trade.
2. Update An Open Trade
update and modify are action commands to update an open trade.
Optional Parameters
Type (T) - Specifies the order type to update either buy or sell.
Take Profit (TP) - Updates the take profit position set as price, percentage or points.
Stop Loss (SL) - Updates the stop loss position set as price, percentage or points.
Trailing Distance (TD) - Updates/Creates the trailing distance of the trade.
Trailing Trigger (TT) - Updates/Creates the trailing trigger of the trade.
Trailing Step (TS) - Updates/Creates the trailing step of the trade.
Magic (M) - Unique identifier for different strategies. Updates the specific strategy with the unique identifier.
Orders (O): Number of orders to apply a command to.
Orders Offset (OO): Number of orders to skip chronologically.
Delay (D): Adds a delay in command execution. The maximum delay is 5 seconds.
Examples:
update EURUSD T=short SL=-1 Moves stop loss to breakeven point.
UPDATE EURUSD SL=0 Cancels your stop loss.
MODIFY EURUSD TT=200 TD=100 TS=50 Modifies the values of the trailing parameters.
3. Close An Open Trade
close, flat and 0 are actions to exit an open trade.
Optional Parameters
Quantity (Q) - Defines the quantity to close. Can also be set as CQ representing closing quantity.
Type (T) - Specifies the order type (
LongorShort) Useful when there are multiple open orders of different types.Magic (M) - Unique identifier for different strategies. Closes the specific strategy with the unique identifier.
Orders (O): Number of orders to close.
Orders Offset (OO): Number of orders to skip chronologically before starting to close.
Examples:
close EURUSD closes all EURUSD trades.
0 EURUSD T=short CQ=50% closes 50% of all short trades.
flat EURUSD m=2102 cq=100% closes 100% of the trade that has the strategy with ID 2102.
4. Cancel Pending Orders
cancel and exit actions to cancel pending trades.
Optional Parameters
Type (T) - Specifies the order type (
LongorShort) Useful when there are multiple open orders of different types.Magic (M) - Unique identifier for different strategies. Closes the specific strategy with the unique identifier.
Examples:
cancel XAUUSD cancels all Gold pending orders.
cancel EURCAD cancels all EURCAD pending trades.
5. Balance Check
balance, fundsand bal are actions to request the account balance.
Examples:
balance returns the account balance.