Documentation
HomeGithubDiscordBlog
  • What is OpenAlgo?
  • OpenAlgo Architecture
  • Mini FOSS Universe
  • Community Support
  • OpenAlgo GPT
  • New Features
    • Fast Scalper
    • API Analyzer
    • Traffic/Latency Monitor
    • Chartink Integration
  • Monetization
  • Connect Brokers
    • Brokers
      • 5Paisa
      • 5paisa (XTS)
      • AliceBlue
      • AngelOne
      • Compositedge
      • Dhan
      • Dhan(Sandbox)
      • Firstock
      • FlatTrade
      • Fyers
      • Groww
      • IIFL (XTS)
      • Jainam Retail (XTS)
      • Jainam Dealer (XTS)
      • Kotak Securities
      • Paytm
      • Pocketful
      • Shoonya
      • Tradejini
      • Upstox
      • Wisdom Capital
      • Zebu
      • Zerodha
  • Installation Guidelines
  • Getting Started
    • Windows Installation
      • Pre-Requesites
      • Setup
      • Install Dependencies
      • Ngrok Config
      • Environmental Variables
      • Start OpenAlgo
      • SSL Verification Failed
      • Accessing OpenAlgo
    • Windows Server Installation
    • Mac OS Installation
      • Pre-Requesties
      • Setup
      • Install Dependencies
      • Ngrok Config
      • Environmental Variables
      • Start OpenAlgo
      • Install certifi
      • Accessing OpenAlgo
    • Amazon Elastic Beanstalk
    • Ubuntu Server Installation
    • Docker Development
    • Testing OpenAlgo in Cloud
    • Upgrade
  • Latency
  • API Documentation
    • V1
      • Accounts API
        • Funds
        • Orderbook
        • Tradebook
        • PositionBook
        • Holdings
      • Orders API
        • Placeorder
        • PlaceSmartOrder
        • BasketOrder
        • SplitOrder
        • ModifyOrder
        • CancelOrder
        • CancelAllOrder
        • ClosePosition
        • OrderStatus
        • OpenPosition
      • Data API
        • Quotes
        • Depth
        • History
        • Intervals
        • Symbol
        • Ticker
      • Order Constants
      • HTTP Status Codes
      • Rate Limiting
      • API Collections
  • Symbol Format
  • MCP
  • Trading Platform
    • Amibroker
      • AmiQuotes
      • Button Trading Module
      • Button Trading with Split Orders
      • Button Trading with Stoploss
      • SmartOrder Chart Module
      • Trailing Stoploss Execution Module
      • Line Trading Module
      • Equity Exploration Module
      • CSV Exploration Module
      • Options Button Trading Module
      • Spot/Futures to Options Module (Single Leg)
      • Spot/Futures to Options Module (Two Leg)
      • Time Based Execution
    • Tradingview
    • ChartInk
    • Python
      • Strategy Management
      • EMA Crossover Strategy
      • Supertrend Strategy
      • Supertrend Strategy with yfinance data
      • Voice Based Orders
    • NodeJS
    • Metatrader 5
      • Download & Install Library
      • OpenAlgo MQL5 Functions
      • Include the Header File
      • Sample Expert Advisor
    • Excel
    • Google Spreadsheets
    • N8N
    • Chrome Extension
  • Strategy Management
  • Developers
    • Design Documentation
      • Architecture
      • API Layer
      • Broker Integerations
      • Database Layer
      • Authentication Platforms
      • Configuration
      • Utilities
      • Broker Integration Checklist
  • Change Log
    • Version 1.0.0.24 Launched
    • Version 1.0.0.23 Launched
    • Version 1.0.0.22 Launched
    • Version 1.0.0.21 Launched
    • Version 1.0.0.20 Launched
    • Version 1.0.0.19 Launched
    • Version 1.0.0.18 Launched
    • Version 1.0.0.17 Launched
    • Version 1.0.0.16 Launched
    • Version 1.0.0.15 Launched
    • Version 1.0.0.14 Launched
    • Version 1.0.0.13 Launched
    • Version 1.0.0.12 Launched
    • Version 1.0.0.11 Launched
    • Version 1.0.0.10 Launched
    • Version 1.0.0.9 Launched
    • Version 1.0.0.8 Launched
    • Version 1.0.0.7 Launched
    • Version 1.0.0.6 Launched
    • Version 1.0.0.5 Launched
    • Version 1.0.0.4 Launched
    • Version 1.0.0.3 Launched
    • Version 1.0.0.2 Launched
    • Version 1.0.0.1 Launched
    • Version 1.0.0.0 Launched
Powered by GitBook
On this page
  • OpenAlgoAPI Function Documentation
  • PlaceOrder
  • PlaceSmartOrder
  • ModifyOrder
  • CancelOrder
  • ClosePosition
  • CancelAllOrders
  1. Trading Platform
  2. Metatrader 5

OpenAlgo MQL5 Functions

Below is the API documentation for the OpenAlgoAPI functions provided in your MQL5 header file:


OpenAlgoAPI Function Documentation

PlaceOrder

Places an order with the specified parameters by sending a POST request to the OpenAlgo API.

Parameters:

  • actionParam: The trade action, either "BUY" or "SELL".

  • quantityParam: The quantity of the asset to trade.

  • apiUrlParam: The URL of the OpenAlgo API.

  • apiKeyParam: The API key for authentication with OpenAlgo.

  • strategyParam: The name of the trading strategy.

  • symbolParam: The symbol for the asset being traded.

  • exchangeParam: The exchange on which the trade will be executed.

  • productParam: The product type of the order.

  • priceTypeParam: The price type of the order.

  • priceParam (optional): The price at which to place the order.

  • triggerPriceParam (optional): The trigger price for stop-loss or stop-limit orders.

  • disclosedQuantityParam (optional): The disclosed quantity of the order.

Usage:

PlaceOrder("BUY", 10, "http://127.0.0.1:5000", "your_api_key", "Meta Strategy", "SBIN-EQ", NSE, MIS, MARKET);

PlaceSmartOrder

Places an order that considers the current open position size and matches the position size given in the position book.

Parameters:

  • Inherits all parameters from PlaceOrder.

  • positionSizeParam: The size of the position to be matched for the order.

Usage:

PlaceSmartOrder("SELL", 5, 10, "http://127.0.0.1:5000", "your_api_key", "ReversalStrategy", "TATASTEEL-EQ", NSE, MIS, LIMIT, 150.00);

ModifyOrder

Modifies an existing order with new parameters.

Parameters:

  • Inherits all parameters from PlaceOrder.

  • orderidParam: The ID of the order to be modified.

Usage:

ModifyOrder("123456789", "BUY", 10, 155.00, "http://127.0.0.1:5000", "your_api_key", "Meta Strategy", "YESBANK-EQ", NSE, CNC, LIMIT);

CancelOrder

Cancels an existing order.

Parameters:

  • orderidParam: The ID of the order to be canceled.

  • apiUrlParam: The URL of the OpenAlgo API.

  • apiKeyParam: The API key for authentication with OpenAlgo.

  • strategyParam: The name of the trading strategy.

Usage:

CancelOrder("123456789", "http://127.0.0.1:5000", "your_api_key", "Meta Strategy");

ClosePosition

Closes all open positions associated with a given strategy.

Parameters:

  • apiUrlParam: The URL of the OpenAlgo API.

  • apiKeyParam: The API key for authentication with OpenAlgo.

  • strategyParam: The name of the trading strategy to close positions for.

Usage:

ClosePosition("http://127.0.0.1:5000", "your_api_key", "Meta Strategy");

CancelAllOrders

Cancels all orders associated with a given strategy.

Parameters:

  • apiUrlParam: The URL of the OpenAlgo API.

  • apiKeyParam: The API key for authentication with OpenAlgo.

  • strategyParam: The name of the trading strategy to cancel orders for.

Usage:

CancelAllOrders("http://127.0.0.1:5000", "your_api_key", "Meta Strategy");

Note: Replace placeholder values like "your_api_key" and "http://127.0.0.1:5000" with actual API keys and URLs as required by your setup. All functions assume the existence of a network communication setup within the MetaTrader 5 environment, as well as an OpenAlgo API that responds to the specified endpoints. Ensure proper error handling and API rate limiting as per the service provider's specifications.

PreviousDownload & Install LibraryNextInclude the Header File

Last updated 9 months ago