Functions supported by Upstox Bridge

Order Details:

GetOrderCTag( Exch, TrdSym, CTag, IsLive )
GetOrderIds( Exch, TrdSym, ProdType )
GetOrderIdsBridge( Exch, TrdSym, StgyCode, Source, IsLive )
GetLastOrderId( Exch, TrdSym, ProdType, IsLive )

GetChildOrders( OrderId, IsLive )
GetOrderDiscQty( OrderId, IsLive )
GetOrderExch( OrderId, IsLive )
GetOrderExchId( OrderId, IsLive )
GetOrderExchTime( OrderId, IsLive )
GetOrderExchToken( OrderId, IsLive )
GetOrderFilledPrice( OrderId, IsLive )
GetOrderFilledQty( OrderId, IsLive )
GetOrderInstToken( OrderId, IsLive )
GetOrderMessage( OrderId, IsLive )
GetOrderParentId( OrderId, IsLive )
GetOrderPendingQty( OrderId, IsLive )
GetOrderPrice( OrderId, IsLive )
GetOrderProdType( OrderId, IsLive )
GetOrderQty( OrderId, IsLive )
GetOrderStatus( OrderId, IsLive )
GetOrderTag( OrderId, IsLive )
GetOrderTime( OrderId, IsLive )
GetOrderTrans( OrderId, IsLive )
GetOrderTrdSym( OrderId, IsLive )
GetOrderTriggerPrice( OrderId, IsLive )
GetOrderType( OrderId, IsLive )
GetOrderValidDate( OrderId, IsLive )
GetOrderVariety( OrderId, IsLive )


Position Details:

GetAvgBoughtPrice( Exch, TrdSym )
GetAvgBoughtPriceBridge( Exch, TrdSym, StgyCode, Source, IsLive )
GetAvgBoughtPriceProduct( Exch, TrdSym, ProdType )
GetAvgSoldPrice( Exch, TrdSym )
GetAvgSoldPriceBridge( Exch, TrdSym, StgyCode, Source, IsLive )
GetAvgSoldPriceProduct( Exch, TrdSym, ProdType )
GetBoughtQty( Exch, TrdSym )
GetBoughtQtyBridge( Exch, TrdSym, StgyCode, Source, IsLive )
GetBoughtQtyProduct( Exch, TrdSym, ProdType )
GetSoldQty( Exch, TrdSym )
GetSoldQtyBridge( Exch, TrdSym, StgyCode, Source, IsLive )
GetSoldQtyProduct( Exch, TrdSym, ProdType )

GetTotalMtm( Exch )
GetTotalMtmBridge( StgyCode, Source, IsLive )

GetMtm( Exch, TrdSym )
GetMtmBridge( Exch, TrdSym, StgyCode, Source, IsLive )
GetMtmProduct( Exch, TrdSym, ProdType )
GetNetQty( Exch, TrdSym )
GetNetQtyBridge( Exch, TrdSym, StgyCode, Source, IsLive )
GetNetQtyProduct( Exch, TrdSym, ProdType )

GetTotalPositionsBridge( StgyCode, Source, IsLive )
GetPositionsListBridge( StgyCode, Source, IsLive )
GetClosedPositionsBridge( StgyCode, Source, IsLive )
GetOpenPositionsBridge( StgyCode, Source, IsLive )

GetEntryTradesBridge( Exch, TrdSym, StgyCode, Source, IsLive )
GetLongTradesBridge( Exch, TrdSym, StgyCode, Source, IsLive )
GetShortTradesBridge( Exch, TrdSym, StgyCode, Source, IsLive )
GetTotalTradesBridge( Exch, TrdSym, StgyCode, Source, IsLive )


Symbol Details:

GetLotSize( Exch, TrdSym )
GetTickSize( Exch, TrdSym )


Bridge Status:



Order Requests:

CancelAmoBridge( OrderId, IsAsync )
CancelOCOMainBridge( OrderId, IsAsync )
CancelCOMainBridge( OrderId, IsAsync )
CancelSimpleOrderBridge( OrderId, IsAsync )
ExitOCOBridge( OrderId, IsAsync, StgyCode, IsLive )
ExitCOBridge( OrderId, IsAsync, StgyCode, IsLive )
ModifyOCOMainBridge( OrderId, Qty, LmtPrice, TrgPrice, IsAsync )
ModifyOCOSlBridge( OrderId, TrgPrice, IsAsync )
ModifyOCOTgtBridge( OrderId, LmtPrice, IsAsync )
ModifyCOSlBridge( OrderId, TrgPrice, IsAsync )
ModifySimpleOrderBridge( OrderId, OrdType, Qty, LmtPrice, TrgPrice, IsAsync, DiscQty )
PlaceAmoBridge( Exch, TrdSym, SignalType, OrdType, Qty, ProdType, LmtPrice, TrgPrice, Validity, CTag, DiscQty, IsLive, StgyCode, IsAsync, TagAPI )
PlaceOCOBridge( Exch, TrdSym, SignalType, Qty, LmtPrice, SqOffValue, StoplossValue, TrailTicks, OrdType, TrgPrice, CTag, IsLive, StgyCode, IsAsync, TagAPI )
PlaceCOBridge( Exch, TrdSym, SignalType, Qty, StoplossPrice, OrdType, LmtPrice, CTag, IsLive, StgyCode, IsAsync, TagAPI )
PlaceSimpleOrderBridge( Exch, TrdSym, SignalType, OrdType, Qty, ProdType, LmtPrice, TrgPrice, Validity, CTag, DiscQty, IsLive, StgyCode, IsAsync, TagAPI )



Exch : “NSE_EQ”, “NSE_FO”, “BSE_EQ”, “NCD_FO”, “MCX_FO”
OrdType : “M”, “L”, “SL”, “SL-M”
ProdType : “I”, “D”
SignalType : “BUY”, “SELL”, “SHORT”, “COVER”
Validity : “DAY”
StgyCode : Must be 2 character, alphanumeric, unique to identify a strategy.
CTag : 3-15 characters, alphanumeric, unique to identify a order
IsLive : True to place order in Live Market or False for Paper Trading
IsAsync : True to place order in background or False to place in main thread
TagAPI : 3-8 characters, alphanumeric.
Qty|DiscQty : Number (Integer)
LmtPrice|TrgPrice : Number
SqOffValue|StoplossValue : Number
TrailTicks : Number (Integer)
StoplossPrice : Number

For full list of functions, please refer this link.

Was this article helpful?

Related Articles


  1. Avatar suresh


    Can i use the below in my bridge code? so that it automatically adjusts the SL on meeting a certain condition
    ModifyOCOSlBridge( OrderId, TrgPrice, IsAsync )
    the trade to finish.

    1. Hi Suresh,
      Yes, you can use ModifyOCOSlBridge to adjust the stoploss price.

      Get the ParentOrderId using CTag = GetOrderCTag(…)
      Get All ChildOrders = GetChildOrders(ParentOrderId)
      Split the ChildOrders by Comma to get ChildOrder Array
      Loop through the Child Order Array and check for the order type
      If OrdType = “SL”, then it is a stoploss order, just call the
      ModifyOCOSlBridge to change the stoploss price.

  2. Avatar suresh

    Thank you sir for the elaborate reply. I will try it out .

    1. Avatar suresh

      if close > buyprice*1.25
      ParentOrderId = GetOrderCTag( Exch,TrdSym,CTag );
      ChildOrders = GetChildOrders(ParentOrderId);
      OrderIds = Split(ChildOrders,”,”);
      Trgprice = buyprice*1.05

      for( i = 0; i < BarCount; i++ )

      If (OrdType = "SL")

      Bridge.ModifyOCOSlBridge( OrderId, TrgPrice, IsAsync );
      End If

      Please correct me, am i missing out something above?

      1. Hi Suresh,

        Are you trying this in AFL?
        The above code has issues.
        1. You should loop through the child orders instead you are looping on BarCount
        2. OrdType undeclared.
        3. OrderId is not declared in ‘Bridge.ModifyOCOSlBridge( OrderId, TrgPrice, IsAsync );’

        1. Avatar suresh

          Yes i tried this in AFL, after unsuccessful attempts i am moving to CO orders as that reduces the complexity.

          1. Avatar suresh

            I tried with CO orders, Amibroker doesnt throw error, but there are too many invalid MOIFYCOSLBridge orders in the logs. Every time the ami scan runs modifyCOSl function is getting logged unlike EXITCO.
            Below is my piece of code
            if (LastValue(Freeorder)) {
            POrderId = Bridge.GetOrderCTag(Exch,TrdSym,BuyTag);
            ChildOrders = Bridge.GetChildOrders(POrderId);
            Trgprice = BuyPrice;
            Bridge.ModifyCOSlBridge( ChildOrders, TrgPrice, IsAsync );
            how to solve this sir?

  3. Avatar Swapnil Ashok Bagul

    hi team,
    i am try to get ToTal MTM Bridge value in upstoxXL for my paper trading but cell showing (#VALUE!)
    so kindly tell me what i doing wrong ex. GetMtmBridge( NSE_EQ, MRPL, ZZ, XLBRIDGE,FALSE) = #VALUE! in upstoxXL

  4. Hi swapnil,
    The #VALUE! error means, you are passing incorrect data type.
    String variables needs to be enclosed with ”
    =GetMtmBridge(“NSE_EQ”, “MRPL”, “ZZ”, “XLBRIDGE”, FALSE)

    *The StgyCode should match with the one with which you placed order.

    1. Avatar Swapnil Ashok Bagul

      yes i know but i am not write any variables in this formula i am using cell range ex.=GetMtmBridge(A1,B1, C1,D1,E1) BUT still error came in #VALUE!

      1. @swapnil
        We checked at our end.
        The ‘GetMtmBridge’ UDF has additional parameter ‘DynamicValue’.
        This additional parameter is used to trigger excel calc, so that the MTM will update like RTD.
        You need to pass LTP (or any value that updates automatically) as additional parameter.
        =GetMtmBridge(A1, B1, C1, D1, E1, LTP)

  5. Avatar Swapnil Ashok Bagul

    hi team

    today, i want Previous Day Open value for stock “BHEL” but when i use formula =GetPrevDayOpen(“BHEL”) this will provide me date 18th Open value

    kindly suggest

    1. @Swapnil,
      Thanks for notifying this.
      We confirm the issue and will be rectified in the coming release.
      For time being, you can do the below,
      once daily in the morning and before login, delete the below files in the folder C:\Users\Public\Documents\Data\UpstoxNet

      or Create a batch file to delete with one click
      @echo off

      cd /d C:\Users\Public\Documents\Data\UpstoxNet

      del /q /f Bhav_Eq.txt
      del /q /f Bhav_Fut.txt
      del /q /f Bhav_Opt.txt
      del /q /f Avg_HighLow.txt
      del /q /f Avg_Volume.txt
      del /q /f Volatility_Eq.txt

      1. Avatar Swapnil

        thanks it working
        i add code in login micro
        Call deletFile
        Sub DeletFile()
        On Error Resume Next
        Kill (“C:\Users\Public\Documents\Data\UpstoxNet\Bhav_Eq.txt”)
        Kill (“C:\Users\Public\Documents\Data\UpstoxNet\Bhav_Fut.txt”)
        Kill (“C:\Users\Public\Documents\Data\UpstoxNet\Bhav_Opt.txt”)
        Kill (“C:\Users\Public\Documents\Data\UpstoxNet\Avg_HighLow.txt”)
        Kill (“C:\Users\Public\Documents\Data\UpstoxNet\Avg_Volume.txt”)
        Kill (“C:\Users\Public\Documents\Data\UpstoxNet\Volatility_Eq.txt”)

        End Sub

  6. Avatar Anuma

    I am new to Amibroker and just learning the AFL.
    I am finding it a bit difficult to understand these formula posted in these article.
    Is there a more in detailed help manual which explains which formula does what?
    OR any suggestions for newbies like me?


Leave A Comment?