How to Connect AmiBroker with Tradetron (AFL to Live Orders)

Huzefa Kudrati Updated Oct 3, 2026 6 min read

How to Connect AmiBroker with Tradetron (AFL to Live Orders)

To connect AmiBroker with Tradetron, your AFL code sends a URL request to Tradetron's API whenever a signal fires. The request carries your strategy's unique token, a variable name and a value (for example NIFTY = 1 for buy). Your Tradetron strategy reads that variable with the Get Runtime keyword and places the trade when the value matches.

How the connection works

AmiBroker scans your charts and runs your AFL. Tradetron runs your strategy in the cloud and talks to your broker. The bridge between them is a simple web request.

Flow diagram: AmiBroker AFL detects an EMA cross, sends a URL request with auth-token, key and value to Tradetron, the Tradetron strategy checks Get Runtime NIFTY equals 1, and the order goes to your brokerOne URL call per signal; Tradetron does the rest

The request looks like this (with your own token in place of the placeholder):

https://api.tradetron.tech/api?auth-token=YOUR_TOKEN&key=NIFTY&value=1
  • auth-token identifies the strategy. It is unique, and limited to one single strategy.
  • key is the variable name you choose, such as NIFTY.
  • value is what you're setting the variable to, such as 1 for a buy signal.

Tradetron stores the value, and your running strategy keeps checking it. When the value changes to one your conditions are waiting for, the matching trade fires.

Step 1: Get the token for your strategy

  1. Build (or duplicate) the Tradetron strategy that will receive the signals.
  2. Go to Strategies → My Strategies and open the three-dot menu on that strategy.
  3. Click API OAuth Token. The window shows the strategy's link and token.
  4. Copy the token. You'll paste it into the AFL in Step 2.

API OAuth Token window in Tradetron showing the Link ID, API Controlled option, Hybrid Mode and the API linkMy Strategies → three-dot menu → API OAuth Token

Step 2: Add the signal code to your AFL

The example below trades NIFTY 50 index futures, 1 lot, on a 20-period EMA cross:

Signal Rule Value sent
Buy Close crosses above EMA(20) 1
Sell Close crosses below EMA(20) 2
Short Close crosses below EMA(20) (reverse trade) 3
Cover Close crosses above EMA(20) 4
Buy   = Cross(C, EMA(C, 20));
Sell  = Cross(EMA(C, 20), C);
Short = Cross(EMA(C, 20), C);
Cover = Cross(C, EMA(C, 20));
TradeActive = 1;

_SECTION_BEGIN("TTron");
EnableScript("VBScript");
<%
Public Sub callurl(varname, val)
    Dim oXMLHTTP
    Set oXMLHTTP = CreateObject("Msxml2.ServerXMLHTTP")
    token = "YOUR_TOKEN"
    url = "https://api.tradetron.tech/api?auth-token=" + token + "&key=" + varname + "&value=" + val
    oXMLHTTP.Open "GET", url, False
    oXMLHTTP.setRequestHeader "Cache-Control", "no-cache"
    oXMLHTTP.setRequestHeader "Pragma", "no-cache"
    oXMLHTTP.Send
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 (TradeActive)
{
    if (signalSell == True AND StaticVarGet("NIFTYsell") == 0)
    { pb.callurl("NIFTY", "2"); StaticVarSet("NIFTYsell", 1); }
    else if (signalSell != True) StaticVarSet("NIFTYsell", 0);

    if (signalCover == True AND StaticVarGet("NIFTYcover") == 0)
    { pb.callurl("NIFTY", "4"); StaticVarSet("NIFTYcover", 1); }
    else if (signalCover != True) StaticVarSet("NIFTYcover", 0);

    if (signalBuy == True AND StaticVarGet("NIFTYbuy") == 0)
    { pb.callurl("NIFTY", "1"); StaticVarSet("NIFTYbuy", 1); }
    else if (signalBuy != True) StaticVarSet("NIFTYbuy", 0);

    if (signalShort == True AND StaticVarGet("NIFTYshort") == 0)
    { pb.callurl("NIFTY", "3"); StaticVarSet("NIFTYshort", 1); }
    else if (signalShort != True) StaticVarSet("NIFTYshort", 0);
}
_SECTION_END();

Replace YOUR_TOKEN with the token from Step 1. The StaticVarSet flags make sure each signal is sent once per occurrence, not on every refresh of the chart.

Step 3: Read the signal in Tradetron with Get Runtime

In the Tradetron strategy, create two sets:

  • Set 1: long entry and long exit
  • Set 2: short entry and short exit

In each condition, compare the Get Runtime keyword (variable name NIFTY) with a Number keyword:

Set Condition Rule
Set 1 Entry (buy) Get Runtime NIFTY == 1
Set 1 Exit (sell) Get Runtime NIFTY == 2
Set 2 Entry (short) Get Runtime NIFTY == 3
Set 2 Exit (cover) Get Runtime NIFTY == 4

Tradetron condition: Get Runtime NIFTY equals Number 1The buy condition: Get Runtime NIFTY == 1

Then add the positions (NIFTY 50 futures, 1 lot) in each set's position builder.

You can duplicate the reference strategy to start from. It won't receive signals until you generate a token for your own copy and put it in your AFL.

Step 4: Test before you trade

  1. Deploy the Tradetron strategy Live Offline: the strategy runs and records every trade, but nothing is sent to the exchange.
  2. Open AmiBroker with the AFL applied to a live NIFTY futures chart during market hours.
  3. When a cross happens, check the deployment's Notification Log in Tradetron: you should see the runtime value and the resulting trade.
  4. Once signals arrive and trades match your chart for a few sessions, redeploy Live Auto at 1x.

Things to know before you rely on it

  • Your computer is part of the system. If AmiBroker or your internet connection is down, no signals are sent. Tradetron can't fire a trade it never heard about.
  • The variable holds the last value. Design the values so a missed or overwritten signal can't leave you in a position you didn't intend.
  • Exits belong in Tradetron too. Add a stop loss on each leg or a Universal Exit, so a position is protected even if AmiBroker goes quiet.

Frequently asked questions

How do I connect AmiBroker to Tradetron?

Add a function to your AFL that calls Tradetron's API URL with your strategy's token, a variable name and a value whenever a signal fires. In the Tradetron strategy, use the Get Runtime keyword to compare that variable with the value and trigger entries and exits.

Where do I get the auth token for AmiBroker?

In Tradetron, go to Strategies → My Strategies, open the three-dot menu on the strategy and choose API OAuth Token. Each token works for one strategy only.

Does AmiBroker need to stay open?

Yes. The signals are generated by AFL running on your computer, so AmiBroker must be running with the chart open during market hours.

What is the Get Runtime keyword?

It reads the current value of a runtime variable, such as one set by an API call from AmiBroker, so you can compare it in a condition, like Get Runtime NIFTY == 1.

Can I test the AmiBroker connection without placing real orders?

Yes. Deploy the strategy Live Offline: it runs and records every trade from the AmiBroker signals, but nothing is sent to the exchange.

Want to join Tradetron?

Thousands of traders have moved to algo trading. Leave your number and our team will help you get started.