IB syntax for DDE links in VBA

Discussion in 'Automated Trading' started by jtrader33, Feb 11, 2011.

  1. I'm trying to avoid putting DDE links directly into Excel cells and instead establish the links in VBA and store the returned data into a VBA array. I'm getting tripped up on the very first step however, because I can't establish the DDE links in VBA (and as a result receive no data to populate my array with). Here is what I am trying to use into to get the market data via DDE:


    Sub GetMktData()
    Dim chan As Long, App as String, Topic as String, data As Variant, Item as String

    App = "Account123"
    Topic = "tik"
    Item = "id1?bid"

    chan = Application.DDEInitiate( App, Topic )
    data = Application.DDERequest( chan, Item )
    MsgBox(data(1))
    Application.DDETerminate chan

    End Sub

    I've tried numerous variations of 'Item', but 'data' always returns as empty. (I suspect that the problem lies in what I am using for 'Item', but I'm not certain.) Does anyone have suggestions on how I can get this to work or what I'm doing wrong? Could be a problem with the general approach, but my feeling is that it is an IB specific syntax issue. I've tried gettting answers from IB customer service but would have been better off using a ouija board. Appreciate any suggestions.
     
  2. TraDaToR

    TraDaToR

    I must be stupid but I thought you needed to enter the formula in an excel cell to create a DDE link, be it to retrieve datas, submit orders or anything else.
     
  3. Ha. Don't worry, I'm sure when this is resolved one way or the other, I'll be the stupid one. Anyhow, I believe the above method should return into the 'data' variable the same information that would populate an Excel cell with formula:

    =Account123|tik!id1?bid
     
  4. Alex123

    Alex123

    Hi, bs2167.

    Have you found a solution for importing DDEs straight into VBA arrays yet? I'm looking to do the same and would appriciate any pointers you might have on this. Thanks
     
  5. Alex123

    Alex123

    Hi, bs2167.

    Have you found a solution for importing DDEs straight into VBA arrays yet? I'm looking to do the same and would appreciate any pointers you might have on this. Thanks

    PS Sorry if this is a duplicate - didn't see the first one come up.
     
  6. Alex123

    Alex123

    OK, so far I have noticed that is you first set up a Control Link (that's the one that has SecType, Exchange, Currency etc in it) in a spread-sheet, you can then get data using your syntax in VBA. Maybe the Control Link should go somewhere in DDEInitiate or DDERequest to get it all done in VBA only.. Haven't figured out where and using what syntax yet... That's one sh1t reference guide that IB has for DDE - not even a mention of either DDEInitiate or DDERequest in it. :mad: