Amibroker API Integration - AlgoJi

Amibroker Developer Ecosystem

You may remember, we earlier discussed that Amibroker has an open ecosystem for developers. The Amibrokoker development kit is available for free in the downloads section. The ADK is a great tool to build Amibroker plugins in Dot Net or Java.

You can build three types of plugins in Amibroker:

Data Plugins

AFL Plugins

And Optimizer Plugins

Data plugins are used to connect with external data sources. You can code a data plugin to fetch data from any api.

AFL plugins can be used to build additional functionality in AFL. For example, AFL does not have functions for co-integration tests or option pricing. You can code such functions in dot net languages and tie it up with AFL engine.

Optimizer plugins are used for including any custom optimization algorithms.

AFL Scripting Integration

You can also use VB Script and Java Script directly in Amibroker. The EnableScript function is used to enable the scripting host.

The AFL scripting host is an interface between AFL language and scripting technologies

Even though these scripts can be used inside AFL, they are seldom required. AFL itself is sufficiently powerful to carry out most of the tasks.

AFL also supports COM technology. The COM dlls can written in any language of your choice- dot net. Java, python etc. You can do calculation in language of your choice and run them at full compiled code speed.

The Amibroker help files have plenty of sample code to help you get started in further development. Even if you are get stuck somewhere, the technical support of Amibroker is very good. They usually answer your emails within 4 hours.

There are already plugins available for R, Python and TWS API.  So Amibroker is not just any other retail software. How much you can do in Amibroker simply depends upon the time you spend in learning Amibroker.

Paper Trading AFL

Have a look at this- this is the paper trading setup we will provide you soon. You can turn Amibroker into complete trading platform to send Limit or Market Orders.

Amibroker will maintain order log of orders that have been sent, cancelled or filled. Amibroker will also record all completed trades in separate excel file for further analysis. Therefore, Amibroker itself will be a complete system to test algo trading without using any other software.

In case of Limit Orders, you can chose between many options for execution. For example, consider signal generated by a mean reverting strategy. By sending a limit order at the price of candle’s low, you can wait for a better price to get filled.

Even If you are using a trend following strategy, you can push a buy limit order at the best bid, rather than sending a market order. You also have the option of choosing bid versus ltp for limit order price. The ltp has a better chance of getting filled. If you want to be more aggressive, you can send order at ask price, rather than the ltp price.

If you are using a momentum strategy, you can trigger market order instead of a limit order.

You can test out all combinations of execution which suits your strategy best. The best part is, you do not need to play around with real money to know your profitability.

We will soon also add Stop-loss entry orders in this paper trading system. It helps you to wait until market confirms the signal. For example, when you get a buy signal, you can wait until the high of previous candle is breached. In this scenario, you can place a stop buy order at the high of the previous candle.

Amibroker API Integration

Coming lastly to the API integration part, again you have multiple options for Amibroker.

For trading in international markets, Amibroker connects seamlessly with Interactive Broker’s TWS API. You can pull live data as well as historical data from the TWS API. Amibroker also has a plugin for managing live orders to IB API. The trading panel with buttons I showed you earlier, was actually made using TWS API. You can manage over 20 order types from AFL when using the IB API.

For trading in Indian markets, the most stable system is the Symphoy Presto API. You can send signals from Amibroker to Presto. Presto then pushes appropriate execution strategy to match your signal generation strategy. For example, you can use bracket orders, order slicing, peg to market, define custom execution prices. You can also modify open limit orders from the AFL itself. The Symphony Presto was launched more than 5 years back and is a very stable system.

The MasterTrader v3.0 is another API for auto trading with Amibroker. It has a very simplified interface. Any AFL strategy can be automated in just few clicks using the MTv3. Even though it is extremely simple to use, it offers execution strategies for trading Amibroker signals.

You can also trade using the Nest Plus API. It is an inexpensive API which costs under Rs. 300 per month. It does not provide you any execution strategies, but you can use limit orders and market orders from the code itself. The Nest Plus API requires writing a strong AFL code for managing order execution part. The Nest Plus API is also quite a stable product and can be used both at dealer level and individual level. It is not so popular because it requires extensive coding, but if you learn coding, you will have a inexpensive algo solution.

Similar to Nest Plus API, you can also use the Pi bridge. However, the pi bridge does not allow full automation and has limitations when compared to Nest Plus API.

Trade Tiger bridge is a similar solution to the Pi bridge. It has limited functionality in terms of available order types.