• Home
  • Products
    • Login
    • Product Info
    • User Guide
    • Pricing
  • Services
    • Stock Brokers
    • Freelancers
  • Help
    • Documentation
    • Knowledge Base
    • FAQ
  • Company
    • About Us
    • Contact Us
    • Terms & Conditions
  • Home
  • Products
    • Login
    • Product Info
    • User Guide
    • Pricing
  • Services
    • Stock Brokers
    • Freelancers
  • Help
    • Documentation
    • Knowledge Base
    • FAQ
  • Company
    • About Us
    • Contact Us
    • Terms & Conditions

AutoTrader Web

home/Documentation/AutoTrader Web
Expand All Collapse All
  • Index
  • Getting Started
  • Portfolio Management System (PMS)
  •  Copy Trading (Master-Child Auto-Copy)
    • Master-Child Copy - Performance
  • PMS vs Master-Child
  • Trading View
  •  Supported Brokers
    • Symphony XTS
    • Zerodha
    • Angel Broking
    • Dhan
    • Aliceblue
    • Fyers
    • Nuvama
    • IIFL
    • Zebu
    • Finvasia
    • Motilal Oswal
    • Kotak
    • Mastertrust
    • Five Paisa
    • Choice Broking
    • FlatTrade
    • Tradejini
    • Upstox
    • SAS Online
    • Profitmart
  •  Client Setup
    • Desktop Client
    • AmiBroker Library
    • Excel Library or Tools
    • Java Library
    • MetaTrader Library
    • C# Library
    • Python Library
    • HTTP REST
  •  User Interface
    • User Registration
    •   Settings
      • General
      • Trading Accounts
      • Pseudo Accounts
      • Group Accounts
      • API Key
    •   AutoTrader
      • Activity
      • Instruments
    •   Trading
      • Summary
      • Positions
      • Orders
      • Margins
      • Holdings
      • Trade
    •   User
      • Account
      • Profile
  •  API (Application Programming Interface)
    • Place Regular Order
    • Place Cover Order
    • Place Bracket Order
    • Place Advanced Order
    • Cancel Order
    • Cancel Child Orders
    • Cancel All Orders
    • Modify Order
    • Modify Order Price
    • Modify Order Quantity
    • Square-off Position
    • Square-off Portfolio
    • Read Orders
    • Read Positions
    • Read Margins
    • Read Holdings
    • Read Portfolio Summary
    • Fetch All Trading Accounts
    • Create or Update Trading Account
    • Validate Trading Account Credentials
    • API Parameters
    • API Rate Limits
    • Email Limits
    • Postman
  • Pricing
  • Precautions
  •  Broker Independence
    • API Functions
    • Pseudo Account
    • Instruments (Trading Symbols)
  • Quantity Multiplier
  • Architecture

MetaTrader Library

6450 views February 12, 2024 Pritesh 8

MetaTrader users should use the library that we provide in order to achieve automation. In this section, we will look at how it is done.

The library is fully compatible with MT4 & MT5. In case you face any problems, try manual installation as per steps given below or contact the support team for help.

Migration

Those migrating from our previous generation AutoTrader system should take a note that the API functions have changed. Most notable change is the addition of Pseudo Account which is an additional parameter in all the functions.

Installation

  1. Install AutoTrader Desktop client
  2. Start Desktop client
  3. Go to the Settings tab
  4. Click MetaTrader Library Install button
  5. The system will automatically try to locate MetaTrader folders and do the installation

Manual Installation

Just in case, the installation fails; you can try doing a manual installation.

  • Download library
  • Open it with WinZip or WinRar & extract the files
  • Copy the files from Include folder to your MetaTrader’s Include folder.
    • A sample path is given below, you need to find appropriate path on your computer
    • C:\Users\<windows_user>\AppData\Roaming\MetaQuotes\Terminal\F762D69EEEA9B4430D7F17C82167C844\MQL5\Include
    • If you are using MT4, then the folder above will be MQL4

Client Setup

  1. Install & open AutoTrader Desktop client
  2. Go to it’s settings tab & change the communication path as given below. Make sure you find similar path on your computer
    1. C:\Users\<windows_user>\AppData\Roaming\MetaQuotes\Terminal\Common\Files\autotrader
  3. Note: The desktop client must be running & in MONITORING state for the APIs to work.

Integration

Once the library is installed, then next step is to integrate it into your trading strategy.

Code

As with any other library, in order to use it’s functions in your strategy code; you must include it in your strategy’s code at the top.

#include <autotrader.mqh>

That’s about it. Now you are all set to use the API functions provided in the library.

Regular Order

string id = placeOrder(AT_ACCOUNT, 
	NSE, "SBIN", SELL, LIMIT, INTRADAY, 1, 
	192.44, 0.0, true);

Bracket Order

string id = placeBracketOrder(AT_ACCOUNT, 
	NSE, "SBIN", BUY, LIMIT, 1, 
	192, 0.0, 1, 1, 0, true);

Cover Order

string id = placeCoverOrder(AT_ACCOUNT, 
	NSE, "SBIN", BUY, LIMIT, 1, 
	192, 190.5, true);

Cancel Order

string orderId = placeOrder(AT_ACCOUNT, 
	NSE, "SBIN", SELL, LIMIT, INTRADAY, 1, 
	192.44, 0.0, true);

// You can even store the orderId 
// in a static variable

// Somewhere later in your code, 
// when you want to cancel this order

cancelOrder(AT_ACCOUNT, orderId);

API Functions

All API functions are available inside “Include\autotrader.mqh“. Do NOT modify this file.

Note: A detailed explanation is provided for each function along with examples in the API documentation.

Parameters

The library defines certain parameters that you can set in the chart parameters window. They are given below:

  • AT_ACCOUNT: Pseudo account
  • AT_EXCHANGE: Instrument’s exchange
  • AT_SYMBOL: Instrument’s symbol
  • AT_PRODUCT_TYPE: Default Product type
  • AT_QUANTITY: Default Quantity
  • AT_PRICE_PRECISION: Price precision for rounding
  • AT_DEBUG: Print additional logs
  • AT_AVOID_REPEAT_ORDER_DELAY: Avoid repeat order delay (in seconds)

Broker independent instrument’s Exchange & Symbol can be looked up on this global instruments search tool.

MetaTrader Chart Parameters
MetaTrader Chart Parameters – Derivatives

Logs

Here’s a look at sample logs that print information of the order being placed.

MetaTrader Logs
MetaTrader Logs

Trading in Multiple Accounts

There are two approaches to achieve trading into multiple accounts. You can go through them in Trading Strategies For Multiple Accounts.

Approach 1: One Strategy Instance Per Account

To trade in multiple accounts in AmiBroker, you need to run multiple charts or scanners. You need to have one chart/scanner per account.

Approach 2: One Strategy for All Accounts

All the API functions provided by us take account number as a parameter. So instead of using just a single AT_ACCOUNT chart parameter, you can always hard-code the account in the code. Here is a sample:

// Place order in ACC1
placeOrder("ACC1", AT_EXCHANGE, AT_SYMBOL, BUY, MARKET, 
	AT_PRODUCT_TYPE, AT_QUANTITY, 0, defaultTriggerPrice(), false);

// Place order in ACC2
placeOrder("ACC2", AT_EXCHANGE, AT_SYMBOL, BUY, MARKET, 
	AT_PRODUCT_TYPE, 0, buyPrice, defaultTriggerPrice(), false);

GitHub

If you are interested to look at the code of this library, it is available on GitHub.

Was this helpful?

8 Yes  2 No
Related Articles
  • Master-Child Copy – Performance
  • Tradejini
  • Dhan
  • FlatTrade
  • Supported Brokers
  • Symphony XTS

© 2025 Stocks Developer. All Rights Reserved.