Founding pricing available nowPricing review on May 1Early customers keep their price for life

Connecting darwintIQ to MetaTrader

This guide shows how to connect MetaTrader 4 or MetaTrader 5 to the darwintIQ API and use the provided example Expert Advisors as a starting point.

What This Integration Is For

This integration is useful when you want to:

  • fetch darwintIQ data directly inside MetaTrader
  • display model, support/resistance, or trend data on the chart
  • verify API access from the trading terminal
  • use the examples as a base for your own execution or analysis workflows

Platform Requirement

The example EAs use MetaTrader's built-in WebRequest() function to call the darwintIQ API. MetaTrader blocks external HTTP requests by default, so you must explicitly allow the API domain before the examples will work.

Enable WebRequest

In both MT4 and MT5:

  1. Open Tools -> Options -> Expert Advisors.
  2. Enable Allow WebRequest for listed URL:.
  3. Add https://api.darwintiq.com.
  4. Click OK.
  5. Remove and reattach the EA, or reload the chart.

If this step is skipped, the EA will fail with a WebRequest error and no API data will be returned.

Minimum Setup

  1. Open the example EA in MetaEditor.
  2. Replace the placeholder API token with your real token.
  3. Compile the EA.
  4. Allow https://api.darwintiq.com in MetaTrader.
  5. Attach the EA to a chart.
  6. Check the Experts tab for request or parsing errors.

How the Integration Works

At a high level, the MetaTrader integration follows this pattern:

  1. The EA calls a darwintIQ endpoint such as /v1/models, /v1/supres, or /v1/trendmatrix.
  2. The API response is parsed inside the EA.
  3. The parsed values are displayed on the chart or used as input for your own trading logic.
  4. The request is repeated on a timer or on new bars, depending on the EA configuration.

Scope of the Examples

The included examples are primarily integration and visualization examples. They are not meant to hide or compensate for backend model quality issues with extra discretionary logic inside MetaTrader.

They do not implement production-ready order handling, execution controls, or robust risk management by default.

Included Example EAs

The repository includes minimal examples for both MT4 and MT5:

  • darwintIQ_Model_Api_Demo Calls the models API, parses the first returned model, and shows a compact summary in a chart label.

  • darwintIQ_SupRes_EA Fetches the latest support and resistance snapshot and draws levels, regression channel lines, and swing structure directly on the chart.

  • darwintIQ_TrendMatrix_EA Fetches the latest trend matrix snapshot and renders a compact multi-timeframe direction and strength panel.

The MT5 files are direct ports of the MT4 examples so both platforms stay aligned.

Troubleshooting

If the examples do not work as expected, check the following first:

  • WebRequest failed The API domain is usually not allowlisted in Tools -> Options -> Expert Advisors.

  • HTTP 401 or authorization errors Your API token is missing, expired, or invalid.

  • Parse failures or empty results The response shape may have changed, the selected endpoint may return no data, or the symbol may not match available data.

  • No useful output on the chart Your broker's symbol naming may differ from the API symbol, for example EURUSD.a instead of EURUSD.

  • Frequent repeated requests Check the EA timer and polling settings to make sure the refresh interval matches your intended usage.

Production Guidance

Before using this approach in live trading, harden the examples:

  • replace naive string parsing with a proper JSON parser for MQL
  • add risk management such as lot sizing, stop-loss, take-profit, max spread, and slippage limits
  • implement duplicate-entry protection so the EA does not repeatedly open the same position
  • add trading session filters and failure handling
  • keep the local EA logic aligned with backend entry logic instead of compensating weak backend models with ad hoc overrides
  • test thoroughly in the MetaTrader Strategy Tester before using a live account

The current examples are best treated as reference implementations for connectivity and visualization.

Example Request

GET https://api.darwintiq.com/v1/models?symbol=EURUSD&sort=fitness

Useful starting points include:

  • /v1/models
  • /v1/supres
  • /v1/trendmatrix

Repository

Public example code is available here:

https://github.com/darwintIQ/API