AlgoJi APIBridge Documentation - Upstox, Zerodha, Interactive Brokers, Sharekhan - AlgoJi

AlgoJi APIBridge documentation contains setup instructions and sample code with explanation. We have primarily used Amibroker in setup example; however, for Excel, Python or MT4 integration, contact us through email. Table of Content

APIBridge Features

  1. Supported Brokers: Zerodha, Upstox, Nirmal Bang, Interactive Brokers, IIFL, 5paisa, GRD, CompositeEdge, AliceBlue
  2. Integration with Amibroker, Excel, Python, MT4 etc
  3. Allows trading for Multi-Strategies in Multi-Timeframe and Multi-Markets in Multi-Client Account Allows Multi-Order Types: L, M, SL-L, SL-M, BO, CO etc.
  4. Send custom order quantity for each trade based on your risk management rules
  5. Automatically select Multi-Strikes through your code for options trading
  6. Automatically select multi-expiry contracts through your code for options trading
  7. Trade using charts or without charts through scanner
  8. Does not needs VPS, reconnects to internet after internet interruption
  9. Custom Target, SL, time-based signals etc. for your code
  10. Maintain independent cycle of Long Entry, Long Exit, Short Entry and Short Exit signals.

Limitless possibilities with custom development…

APIBridge Demonstration with Live Trades

Click here for APIBridge Demo with Live Trades

APIBridge System Requirements

  1. Amibroker (32 or 64 bit). Any version upwards from 5.50 will work. Amibroker should be connected with live data.
  2. VC++ runtime environment 2015 (32 bit). Windows-10 has this pre-installed, or you can install fresh from:
  3. Upstox API: Login to upstox developer ->

Click Create New App -> App Name: anything you want, Redirect Url: Subscribe to Interactive API.  Once you click create, you will get API key and secret. For Zerodha API or Omnesys API setup instructions, contact your administrator

  1. APIBridge integrated AFL.

If any of above 4 items are missing, you will not be able to start auto trading.

APIBridge Setup Instructions for Amibroker

  1. This software does not require installation! Simply download zipped folder, and extract it. Right-click on APIBridgeLauncher.exe -> Send To->Desktop (create shortcut)
  2. Login with your APIBridge ID
  3. Go to Tools->Application Settings. Under API, put your upstox api key, secret and redirect url. Important: make sure you copy-paste these settings correctly, or it will not work. Click Save after filling up this information
  4. Under Amibroker tab, give the installation path for Amibroker. Usually this is C:Program Files (x86)AmiBroker
  5. Login to APIBridge and Start Amibroker.
  6. In Amibroker, go to Tools->Preferences->Intraday. Check the option START time of interval (recommended). Click Apply.
  7. In your strategy AFL from which you want to fire signals, append the code

That’s all! these are one-time settings only.

APIBridge Mock Trade Settings

– Before trading live, mock trading is recommended to ensure everything is working correctly. Mock trading should be done after market hours to ensure no orders are actually placed on exchange. Example for NSE after 3:30pm – You can trade through charts or through scanner (without using charts) – Mock Trading after market hours, or during exchange mock trading session is preferable to Paper Trading mode. In Paper Trading mode, actual orders are not sent to exchange. There is semi-automatic mode also available which can be used as required. Mock Trading through charts:

  1. Setup multi-chart layout just as you would like to trade in live market. Ensure that APIBridge integrated AFL is used on each chart, and that chart parameters are correctly set.
  2. Under the settings tab in APIBridge, add scrips with correct settings for trading
  3. Click ‘Start Trading’ button in APIBridge
  4. Start bar-replay in amibroker. The step-interval should the minimum interval your data vendor allows- typically 1-minute. You can increase the Speed (steps/sec) to 5.

Mock Trading through Scanner:

  1. Setup scanner with correct settings. Refer article: . You can select date range to trigger signals on particular date.
  2. Ensure that all stocks are added under APIBridge Settings, and Start Trading

Live Trade Settings:

– If there is no issue in mock trading, you can move forward to live trading. Amibroker will automatically trigger signals as per new data Trading Without Third-party Platform Trading strategies which are based directly on Price or Quantitative Analysis (and which do not require charting), can be programmed directly in APIBridge without using a third-party commercial software such as Amibroker, Excel or MT4. For such development requirement contact us

APIBridge AFL Coding Guide

Use the Amibroker Autotrade AFL Toolkit for set of pre-built code snippets.

Syntax: Algoji_Signal(ID,Type,Symbol,OrderType,TrigPrice,Price,Qty,InstrumentName,StrategyTag)

• ID (mandatory): unique id for each signal sent via Amibroker. If two signals have the same id, the status for the respective order placed may be wrong.
• Type (mandatory): can be either LE, LX, SE or SX. LE: Long Entry, LX: Long Exit, SE: Short Entry, SX: Short Exit
• Symbol (mandatory): symbol name which will be matched to Input Symbol in API Bridge. If you want to send strike/expiry also through Amibroker, you can combine it in syntax “Symbol | Expiry | Strike | OptionType”
• OrderType (optional): can be L, M, SLL or SLM
• TrigPrice (optional): should be 0 or Null for market/limit orders. If you want to send extra parameters for OCO order, you can combine it in syntax “TrigPrice | StopLoss | SquareOff | TrailingTicks”
• Price (optional): should be 0 or Null for market orders
• Qty (optional): Order Quantity
• InstrumentName (mandatory): For upstox API, it should be any of the following EQ|FUTIDX|FUTSTK|OPTIDX|OPTSTK|FUTCOM
• StrategyTag (optional): It can be any string to identify which particular Amibroker strategy is sending the signals.

Example 1: Send Market Order in Equities to create Short position:
AlgoJi_Signal(“8”, “SE”,”SBIN”,”L”,””,””,”1″,”EQ”,”STAG_1″);

Example 2: Send Stop Limit Order in Equities to create Short position:
AlgoJi_Signal(“8”, “SE”,”SBIN”,”SLL”,”302.50″,”302″,”1″,”EQ”,”STAG_1″);

Example 3: Send Stop Market Order in Equities to create Long position:
AlgoJi_Signal(“8”, “LE”,”SBIN”,”SLM”,”302″,”302.50″,”1″,”EQ”,”STAG_1″);

Example 4: Send OCO Order in Equities for Long trade:
AlgojiBroadcastSignal(“6”, “LE”,”SBIN”,”SLL”,”302|1.5|3″,”302.10″,”1″,”EQ”,”STG1″);

Example 5: Send Limit Order in BankNifty Futures to create Short position:

Example 6: Send Limit Order in BankNifty Options to exit Long position:

Example 7: Send Market order in Currency Futures to exit Long position:

Coding Guide for LE, LX, SE, SX APIBridge takes 4 types of signals, LE: Long Entry, LX: Long Exit, SE: Short Entry, SX: Short Exit. Please note:

  1. Exit signal is matched for initial Entry signal coming from the same strategy. If no Entry position was taken, the Exit signal is ignored. If, entry was taken for quantity Q, then exit order is also fired for same quantity Q. This is to prevent any code misfiring.
  2. For scale-in, scale-out strategies, you should fire signals with only LE and SE (do not use LX or SX). This is a simple way to avoid conditional checks applied by APIBridge.

Testing & Debugging:

  1. Login to APIBridge. Login again to your upstox account.
  2. Go to Tools->Application Settings and verify all settings are correct.
  3. Go to Settings window in APIBridge and check that stock has been added with proper parameters.
  4. Go to Amibroker->Tools->Formula Editor. This will open new blank AFL file.
  5. Copy only the function call you want to test. Example: AlgojiBroadcastSignal(“5”, “LE”,”SBIN”,””,””,””,”1″,”EQ”,””,””,””,””,””);
  6. In AFL Editor, click Tools->Verify Syntax. This will execute function call and order will be placed.

Amibroker Troubleshooting:

Note that all Amibroker related issues are independent of APIBridge, or it’s plugin. These issues should be identified/resolved without integrating with APIBridge. Troubleshooting guide has been shifted to

You may also want to take the free amibroker course with afl templates, assignments and video tutorials