How to integrate FYERS API Bridge with front-end platforms?

You can send Signals in FYERS API Bridge through an external program such as Amibroker/MT4/TradingView/Python/C# etc.

Understanding How Signals Work:

The FYERS API Bridge works based on “Signals”. A Signal is basically an indication (not decision) to Buy or Sell with specific conditions. The Bridge processes 4 types of Signals:

  • Long Entry (LE): Equivalent to fresh Buy for creating a Long position.
  • Long Exit (LX): Equivalent to Sell for reducing/square-off Long position.
  • Short Entry (SE): Equivalent to fresh Sell for creating Short position.
  • Short Exit (SX): Equivalent to Buy for reducing/square-off Short position.

For placing orders, the Bridge requires values either from Signal or from the Symbol Settings window. Any values given in Symbol Settings window over-ride the Signal values.

As per the above process diagram, the sequence of Signal processing is as follows:

  1. A signal is received in Bridge.
  2. Values are taken from Symbol Settings window by matching symbol given in Signal with “Input Symbol”.
  3. Signal Setting rules are applied from Application Settings -> Signal Settings.
  4. Risk Management rules are applied from Application Settings -> Global Risk Management.
  5. Order is sent to FYERS API.
Integration Specific Files

FYERS API Bridge connects with signal generation applications at three levels. Contact us for these integration specific files.

Easiest – Zero Programming Effort

TradingView: An external app TVConnector to fetch & process alerts

Intermediate – Programming via Scripts

Amibroker: AFL codes for adding to strategy, dll plugin files

MT4: Mq4, ex4 and mqh files

NinjaTrader: ninjascript files

Advanced – Socket Programming

Python/C#/Excel VBA: Code for socket connection

Note: Multiple Targets, Partial exits, custom position sizing, scalping, multi-leg execution etc. may be available via Bridge.

Signal Format & Coding Guide

FYERS API Bridge allows you to customize all values at each signal, such as quantity, or order type. You can program your own strategy to place orders with all custom values at each signal. For controlling order params via code, you should leave blank values in the Bridge under Symbol Settings. The mandatory values for each Symbol are marked with * under Symbol Settings.

The Signal format is:


• ID (mandatory): should be a unique id for each signal. If two signals are provided with the same id, the application may misbehave.

• Type (mandatory): can be either LE, LX, SE or SX.

• Symbol (mandatory): symbol name which will be matched to Input Symbol under Symbol Settings. If you want to send strike/expiry also through Amibroker, you can combine it in syntax “Symbol | Expiry | Strike | OptionType”

• OrderType (optional): can be Limit, Market, SLL or SLM. It can be combined for ProductType using “|”.

• 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 (optional): It should be any of the following EQ|FUTIDX|FUTSTK|OPTIDX|OPTSTK|FUTCUR|FUTCOM

• StrategyTag (optional): It can be any string to identify which particular strategy is sending Signals

Coding Examples

All example Signal codes given below are sent using mostly blank columns in Bridge to place the order.

Example 1: Send Market Order in Equities to create Short position:

FYERS_Signal(“1”, “SE”,”SBIN”,”Market|MIS”,””,””,”100″,”EQ”,””);

Example 2: Send Stop Limit Order in Equities to create Short position:

FYERS_Signal(“1”, “SE”,”SBIN”,”SLL|MIS”,”302.50″,”302″,”100″,”EQ”,””);

Example 3: Send Stop Market Order in Equities to create Long position:

FYERS_Signal(“8”, “LE”,”SBIN”,”SLM|MIS”,”302″,”0″,”100″,”EQ”,”STG1″);

Example 4: Send Bracket Order in Equities for Long trade:


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

FYERS_Signal(“6”, “LE”,”BANKNIFTY”,”Limit|NRML”,””,”28400″,”20″,”FUTIDX”,”STG1″);

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

FYERS_Signal(“6”, “LX”,”BANKNIFTY|28Nov2019|28400|CE”,”Limit|NRML”,””,”102.50″,”20″,”OPTIDX”,”STG1″);

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

FYERS_Signal(“6”, “LX”,”EURINR|27Nov2019″,”Market|NRML”,””,”0″,”1000″,”FUTCUR”,”STG1″);

Was this article helpful?

Related Articles