DDE Syntax for Excel "idn"

Discussion in 'Automated Trading' started by J.P., Mar 26, 2009.

  1. J.P.


    Can someone please explain the function of "n" in the DDE syntax "idn." For example, in the TwsDde.xls workbook, on the Tickers page, when using the function


    in a cell to obtain the Last price, the "n" starts at 0 and increases by one each time you Clear Links and then again Request Market Data (but it obtains the same data each time). However the identical function that I've placed in another section of the workbook does not change (the "n" does not increase in value). So, on the Tickers page there would be "id1" or "id2" etc. while on another page it would retain the original "id0" both having identical prices.

    My question is, How is the "n" value increasing and what is the purpose of the increasing "n" value when it is being utilized (in this example) to obtain the Last price?

    (IB's DDE documentation only states, "id= idn, where n is some integer. For orders, n must always increase, even from session to session.")
  2. TraDaToR



    n has to increase only for "ord" req( and thus "exec" req since you request exec on "ord" req and then see details on "exec" req for the same id). the last submitted order id is saved in TWS jts folder and thus you have to dedicate a cell on your worksheet to store the last id and make it increase when you want to submit a new order.

    Other than that, to request data, you can simply keep the same data id per instrument from session to session. You just have to be sure each instrument has its own id.
  3. J.P.


    TraDaToR, thank you for that explanation.

    Best Regards