Build a custom indicator
A start-to-finish walkthrough: set up the project, integrate the SDK, and submit your custom indicator to the marketplace.
Prerequisites
Before you start, have the following ready. We explain each so you know why it matters.
MetaTrader 5 (MT5) — The trading platform where your indicator runs. You need it installed so you can attach and test your indicator on a chart.
MetaEditor — The built-in editor for writing MQL5 code. It comes with MT5 (press F4 in MT5 to open it). You will write and compile your indicator here.
API Key — A secret string that identifies your customer (or you during testing) to TheMarketRobo. You get it from the platform after registration. The indicator asks for it as an input so users can paste it when attaching the indicator.
Indicator Version UUID — A unique 36-character ID (e.g. xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx) that you reserve in the Vendor Portal for this specific version of your indicator. You put this constant in your code so the SDK can register the session with the server.
Basic MQL5 — You should know how to write a simple Custom Indicator (buffers, OnCalculate). The SDK does not replace your indicator logic; it runs alongside it for session registration and heartbeats.
For indicators you do not need: a config class, a magic number, or any remote config/symbol logic. The SDK uses the same base class (CTheMarketRobo_Base) with a one-argument constructor (indicator version UUID only).
For local testing, create a new test license in your Vendor Portal and use its API key with the staging API URL (see Test step). Do not use production licenses for development.
Get the code
Clone the official sample library (with submodules so the SDK is included). This gives you both a working sample indicator and the SDK source.
Where things live:
• Indicators/sample-in/SampleTMRZigZag.mq5 — A full ZigZag indicator that already integrates the SDK. Open it in MetaEditor to see how everything is wired (class, buffers, OnInit, OnCalculate, OnTimer, OnChartEvent).
• Include/themarketrobo/ — The SDK folder. It contains TheMarketRobo_SDK.mqh (the single file you include) and the rest of the SDK (Core, Services, etc.). Use the folder name in lowercase.
Project setup
Copy the themarketrobo folder (lowercase) into your MetaTrader 5 Include directory. In MQL5, Include is where library headers live; the compiler looks there when you use #include <...>.
In your indicator .mq5 file, add this line at the top (after #property and before inputs). You only need this one include — it pulls in the rest of the SDK automatically.
If it compiles without errors, the SDK is set up correctly.
Using AI to integrate
Our recommendation: use Antigravity with Claude Opus 4.6 (latest) to integrate the SDK into your indicator in under 10 minutes. Modern AI coding assistants with large context windows can ingest the full SDK repository and your existing indicator code, then produce a correctly wired integration because our documentation and SDK code are explicit and straightforward.
How to do it: Open your AI assistant (we recommend Antigravity + Claude Opus 4.6), then provide (1) the full SDK repository — sdk-mql5-lib — and (2) your indicator source code (or the sample indicator from mql5-sample-lib as reference). Ask the model to integrate TheMarketRobo SDK into your indicator: extend CTheMarketRobo_Base with the one-argument constructor, implement on_calculate, and wire OnInit, OnDeinit, OnCalculate, OnTimer, and OnChartEvent to your class.
The SDK is designed for this: the integration booklet and in-repo docs explain every step, and the codebase is structured so an AI can follow the same patterns as the sample indicator. In practice, the assistant will handle the bulk of the boilerplate; you only need to replace the indicator version UUID, verify the buffers and event forwarding, and test. For many developers this path is faster than following the manual steps below — use it if you prefer to iterate with AI, then lean on the rest of this guide for testing and submission.
How the indicator and SDK work together
MQL5 calls fixed-named functions: OnInit, OnDeinit, OnCalculate, OnTimer, OnChartEvent. You create one instance of your indicator class (which extends the SDK base) and forward each of these calls to that instance.
What the SDK does for indicators: (1) In on_init(api_key) it registers the session with the server (no magic number). (2) It starts a 1-second timer; in OnTimer it sends heartbeats and refreshes the JWT token. (3) It uses OnChartEvent for internal events. (4) On shutdown or token failure it stops the timer and can alert the user (indicators cannot remove themselves from the chart).
What you do: Put your indicator logic inside on_calculate (same as any MQL5 indicator). Return the number of bars calculated. The SDK does not touch your buffers or your math.
So: OnInit → create your class, call on_init(InpApiKey). OnDeinit → call on_deinit(reason), then delete. OnCalculate / OnTimer / OnChartEvent → forward to the same instance. That’s the full integration.
Implement your indicator class
Step 5a — Your indicator class. Create a class that extends CTheMarketRobo_Base. The constructor takes one argument: the indicator version UUID (string). No config object, no magic number. Override on_calculate with the full MQL5 signature; put your indicator logic there and return rates_total (or the number of bars you calculated).
Step 5b — Global pointer. Declare a global pointer to your class (e.g. CMyIndicator* g_indicator = NULL;). MQL5 event handlers are global functions, so they need this pointer to call into your instance.
Step 5c — OnInit. (1) Set up your indicator buffers with SetIndexBuffer (required by MQL5). (2) Check that InpApiKey is not empty. (3) Create your indicator with new CMyIndicator(). (4) Call g_indicator.on_init(InpApiKey) — for indicators you pass only the API key (no magic number). If it returns anything other than INIT_SUCCEEDED, delete the instance and return that code. Do not call EventSetTimer() yourself; the SDK sets up a 1-second timer inside on_init.
Step 5d — OnDeinit, OnCalculate, OnTimer, OnChartEvent. In OnDeinit, call on_deinit(reason) so the SDK can send the end-of-session request and kill the timer, then delete the instance and set the pointer to NULL. In OnCalculate, forward all parameters to g_indicator.on_calculate(...) and return its return value. In OnTimer and OnChartEvent, forward to on_timer() and on_chart_event(...) so the SDK can run heartbeats and handle internal events. Always check CheckPointer(g_indicator) != POINTER_INVALID before calling.
For more method details and constants, see the .
Reserve UUID and configure
The Indicator Version UUID tells the server which product version is running. You get it from the Vendor Portal: create or open your indicator product, then reserve a version and copy its UUID (36 characters, format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).
In your code, replace the placeholder in the constant with your real UUID, e.g. const string INDICATOR_VERSION_UUID = "your-actual-uuid-from-portal"; Use the same UUID in the constructor of your indicator class. If the UUID is wrong or not reserved, session start will fail.
Test locally
1. Allow WebRequest. In MetaTrader 5 go to Tools → Options → Expert Advisors. In "Allow WebRequest for listed URL:" add both https://api.themarketrobo.com and https://api.staging.themarketrobo.com. Without this, the SDK cannot reach the server.
2. Use a test license. For local testing, create a test license in your Vendor Portal and use its API key. Do not use production licenses or real customer keys for development.
3. Compile and attach. In MetaEditor press F7 to compile. Fix any errors (include path, missing semicolons, etc.). In MT5, attach the indicator to any chart. In the inputs dialog, paste your API key and click OK.
4. Check the Experts tab. Open the Experts tab in the Toolbox. You should see messages like "SDK session started successfully!" and heartbeat logs. If you see "API Key is required" or "Start session failed", check the key and the allowed URL. The SDK logs with prefixes like SDK Info: and SDK Error: to help you debug.
Submit for review
When your indicator works locally, follow the Robot & Indicator Submission Guide: prepare the product file (your compiled .ex5 or source), specifications, media gallery (screenshots), and pricing. Submit everything via the Vendor Portal.