How to connect Amibroker with Tradetron

Connecting Amibroker with Tradetron is done through API calls

So what are API calls?

You can set your own variables in Tradetron by sending requests.

These requests are sent as URL https requests (one way)

The process is the same, irrespective of the platform.

The Url request is tagged with a unique token id [which you will have to procure from us] and is limited to one single strategy.


The URL call, along with the unique token also carries the variable name and its value.


This request is then updated in the tradetron database

Once the variable is updated, in your tradetron strategy, you can use Get Runtime keyword to fetch the value.


If the fetched value matches the condition a trade will be fired from Tradetron.

Tradetron strategy, when running, keeps checking for the update in the variable. So when the update happens, an action related to that value will be triggered.

Let us understand this with an example.

Assume that you are going long on Nifty 50 index future when

  • Instrument: Nifty 50 Index Future
  • Lots: 1


  • Buy: Close crosses EMA(20) from bottom to top
  • Sell: Close cross EMA(20) from top to bottom
  • Short: Close cross EMA(20) from top to bottom [Reverse trade]
  • Cover: Close crosses EMA(20) from bottom to top


ALF Code

Buy = Cross(C,EMA(C,20));
Sell = Cross(EMA(C,20),C);

Short = Cross(EMA(C,20),C);
Cover = Cross(C,EMA(C,20));




Public Sub callurl(varname,val)
Dim oStream
Set oXMLHTTP = CreateObject("Msxml2.ServerXMLHTTP")


url = ""+token+"&key="+varname+"&value="+val

oXMLHTTP.Open "GET", url, False
oXMLHTTP.setRequestHeader "Cache-Control", "no-cache"
oXMLHTTP.setRequestHeader "Pragma", "no-cache"
End Sub

pb = GetScriptObject();

signalBuy = Buy[BarCount-1]>0;
signalSell = Sell[BarCount-1]>0;
signalShort = Short[BarCount-1]>0;
signalCover = Cover[BarCount-1]>0;

if (signalSell==true AND StaticVarGet("NIFTY"+"sell")==0 ){

else if (signalSell != True){

if (signalCover==true AND StaticVarGet("NIFTY"+"cover")==0 ){

else if (signalCover != True){

if (signalBuy==True AND StaticVarGet("NIFTY"+"buy")==0 ){

else if (signalBuy != True){

if (signalShort==True AND StaticVarGet("NIFTY"+"short")==0 ){

else if (signalShort != True){

}//end main if




This code will:

  • Set variable, "NIFTY" to 1 and 4 when close crosses EMA(20) upwards.
  • Set variable, "NIFTY" to 2 and 3 when close crosses EMA(20) downwards

Now in Tradetron, you can you create two sets,

Set 1 for Long Entry and Long Exit & Set 2 for Short Entry and Short Exit

Each condition builder, you will use Get Runtime Keyword to check the value





You will mention your appropriate positions in the positioning builder

Now when your AFL code runs and a condition is satisfied, it will trigger a URL request to tradetron

Tradetron will then check if the value of the variable matches and then fires the trade accordingly.

You can download the AFL code for your reference from here

You can duplicate the strategy for your reference from here

Note: This Strategy is only for your reference and will not work once duplicated into your account You will have to get a unique token from use and map it in your AFL code for it to work.

Note: Please note that, new token for a strategy is generated at a nominal cost of 2500 + 18% GST RS. If you want us to set this up for you, there will be a one time cost along with the token genration charge for one strategy.

If you have any queries, please free to write to us at