DDE and Excel VBA

Discussion in 'Automated Trading' started by EEUT84, Mar 13, 2011.

  1. Hi PocketChange,

    Have you tried your macro with thinkorswim, or do you use only Open-E-Cry? I can't get a DDE request to work with thinkorswim. Someone suggested the DDE server might not be configured to accept requests. Do you know anything about this? Is Open-E-Cry suitable for options trading?

    I only can monitor 4-5 symbols simultaneously, but I would like to do so without any data loss. So far I've been unable to achieve this. Also I prefer not to use a database if that's possible.

    If anyone else has comments, feel free to reply. I've attached my current code as a .bas file. You'll have to remove the .txt extension.

    Thanks,
    billyrubin09
     
    #21     Aug 15, 2011
  2. Be careful with the ActiveX - it can really swamp your machine.
    I tried getting 20 or so symbols to update using the 5 second Realtime bars....CPU usage went to 100% !
     
    #22     Aug 15, 2011
  3. We've pulled data feeds from TOS about 2 years ago. They had an efficient mechanism for sending an entire option chain as an array.
    The mechanism was ok for options but the underlying lagged.

    We're not married to OEC as our excel formulas and VBA code are broker agnostic. We've built rapport with their techs and programmers and value having direct access to them and their prompt responses to our issues. OEC is suitable for Options trading but be careful burning up your quote/symbol subscription limit.

    This thread may help regarding TOS DDE/RTD and contains VBA code examples to get you over excel's default 100 ms update limit.
    http://www.elitetrader.com/vb/showthread.php?s=&threadid=216959

     
    #23     Nov 26, 2011
  4. PocketChange,
    Do you have code that shows how to request an array on TOS? I did not know that this was even possible.I haven't worked on this in a while, I'm not sure my client even cares any more, but it would be nice to have a solution available. I never managed to get 3 columns of data to line up correctly for one stock. I would usually get 2 correct and 1 would lag behind.
     
    #24     Nov 27, 2011
  5. Mr Pocket Change

    Just wanted to thank you for posting your code - this is the only place that I managed to find where I could get the DDE updates to automatically fire a macro. You saved me a few days (at least) of frustration.

    Gary
     
    #25     Apr 26, 2013
  6. I don't understand how there appears to be so little about this on the internet but I could not get a DDE update to trigger a VBA code. The only way in which I got it to work was by the following code


    Code:
    Private Sub Worksheet_Calculate()
    
    Dim shtname As String
    shtname = "NSEA-MZ3"
    
    'check to see that a new time has been added
    
    On Error GoTo ErrHandler_DDEProblem
    
    If CDbl(Worksheets(shtname).Range("A13").Value) <> CDbl(Worksheets(shtname).Range("A11").Value) _
       And Not (Application.WorksheetFunction.IsNA(Worksheets(shtname).Range("A11").Value)) Then
    
    Worksheets(shtname).Range("A13").Value = Worksheets(shtname).Range("A11").Value
    
       Call mymacro(shtname)
    
    End If
    Exit Sub
    
    ErrHandler_DDEProblem:
    MsgBox "Problem with the DDE Link which is triggering the model", vbctritical
    Exit Sub
    
    
    End Sub
    
    where this is an event code macro - eg go on the tab, RIGHT click the mouse, and then edit code, and cell A11 contains the DDE link relating to the time of the update,

    and cell D14 contains a formula =A11*1 this is needed to reliably trigger the worksheet calculate event.

    The setonlinkdata may be quicker but it is hard to locate which cell has actually changed.

    The Private Sub Worksheet_Change(ByVal Target As Excel.Range) apparently will not work with DDE as there is a bug in Excel.

    Maybe my problems only arise with my version of Excel.

    Gary
     
    #26     Aug 9, 2013
  7. crmorris

    crmorris

    rather than looking for a location of change, why not find the link via symbol / side / etc? the setlinkondata can be fine tuned with a lot of precision.
     
    #27     Aug 9, 2013
  8. Can you please explain a bit more??

    Do you mean like Pocket Change (I have understood him correctly suggests) have the original data in a range and then search through the two ranges to look for a difference. If so, is this not going to take time, extra programming, and the risk that two or more items of data changed at the same time (or during the comparison?(

    Gary
     
    #28     Aug 9, 2013