Skip to main content

As you would know, Tradetron is a SaaS based application that has simplified automated trading up to a great extent. Using Tradetron you can create your strategies, backtest them and finally deploy them live using your broker’s interface. However, many of us who are practicing algorithmic trading since before the advent of Tradetron might already have our strategies defined elsewhere (Amibroker, TradingView, Python, etc). If you want to reuse those strategies and leverage the Tradetron platform to automate them, you’ll need to learn Tradetron API Integration.

How to find the Best Strategies from Tradetron Marketplace?

How do Tradetron APIs work?

Tradetron has a very simple API interface. Every strategy in Tradetron has an API OAuth token associated with it. This token can be used to access the strategy programmatically from 3rd party applications like Amibroker.

The Oauth token can be generated from the strategies page

The key and value at the end of the URL play an important role here. In the above URL, key is “position” and its value is “1”.

Whenever you fire this API from outside, the ‘key’ gets stored as a runtime variable of that strategy. And this runtime variable can be used in the condition builder for taking positions.

The below strategy logic buys current month Nifty futures when the value of runtime variable “position” is set to 1

Amibroker vs Tradetron – A Comprehensive Comparison

How to fire Tradetron APIs?

Every application would have its own way of firing Tradetron APIs. 

In Amibroker, you can use InternetOpenURL() function to call any API. 

ih = InternetOpenURL( "" );

printf( "API Response: " );

if( ih )


     while( ( str = InternetReadString( ih ) ) != "" )


         printf( "%s", str );


     InternetClose( ih );



The value of the ‘Position’ variable can be calculated in the AFL code based on strategy logic.

If your strategy logic is built in Python, you may use the below sample code to invoke Tradetron API

import requests

import json

url = ""

payload = ""

headers = {

  'Authorization': 'Bearer 9436e843-e5d9-42b1-b24a-2a4592320103',

  'Content-Type': 'application/json'


response = requests.request("GET", url, headers=headers, data=payload)


From TradingView, you can invoke API from alerts via webhook, these webhooks send an HTTP post request to Tradetron. Example below:

Tradetron TradingView Integration

Tradetron Amibroker Integration

Pros and Cons of Tradetron API Integration

API Integration with Tradetron is a very powerful feature, but still, it should be used judiciously considering all the pros and cons.


  1. You can build complex strategy rules using Amibroker, Python, etc, and integrate them with Tradetron through APIs. Sometimes it’s not possible to code complex strategies in Tradetron directly.
  2. Any 3rd party application can be integrated with Tradetron using these lightweight REST APIs


  1. API integration may add up to a few milliseconds of latency, the time it takes to execute these APIs and instantiate runtime variables.

Final Thoughts

The Tradetron platform has opened up endless possibilities for retail traders to build their own algorithmic trading systems. With features such as API integration, we can leverage the powerful execution features of Tradetron and yet can have the strategy logic defined elsewhere. This can have many use cases, more than what you can think of!

If you haven’t already, start your Tradetron journey today.

Leave a Reply