Requesting time to IB's TWS via Excel DDE interface

Discussion in 'Automated Trading' started by travis, Jan 28, 2006.

  1. travis

    travis

    I would like to know what kind of "=UserName|tik!id1?" code I need to use in order to request the local time (continously updated).

    There doesn't seem to be a way to request it, so if that's the case I ask you - how do I create within my DDE Excel sheet a macro or excel formula that continously updates the time in a given cell?

    In other words, I need to have the time (continously updated every minute, no seconds needed) in a cell of an excel sheet, like this: 10.03...10.04...10.05...

    Thank you.
     
  2. Do you specifically need IB's time, e.g. to verify synchronization with your computer's time, or might "=NOW()" do the trick?
     
  3. travis

    travis

    I am using "now" already but I can't figure out how to get my Support and Resistance sheet to work with it. If I could, I would have no more problems, because I am not concerned with IB's time, but only with my own computer time.

    Basically I want this sheet to retrieve today's high and low, update Support and Resistance with that data, but only up to the open. (I can't do it manually because I am away).

    Obviously I am doing all this work on a future, that trades continuously.

    If you would like to see my Support and Resistance sheet, in order to help me better, send me a private message with your email.

    Thanks for your help.
     
  4. Sorry, I don't have time to debug your worksheet, but after reading your last post, I'm wondering if an excel timer might be what you need. The specific VBA method of interest is called "Application.OnTime". You set a timer for a specific time (e.g. now plus 1 minute), and in the timer handler function, you do whatever periodic calculations you want, then set the timer again.
     
  5. EMZ

    EMZ

    Try the following

    Sub TimeDisplay()
    Sheets("Sheet1").Range("A1") = Now
    Application.OnTime Now + TimeValue("00:01:00"), "TimeDisplay"
    End Sub

    It will place the present time every minute in cell A1, Sheet1

    You'd need to format A1 with your required time format eg hh:mm:ss

    I hope this helps.
     
  6. travis

    travis

    Thanks to everyone. I have used =now() and at the moment it seems to be the right answer to my problem, as it updates the cell each time the macro is used. I will let you know any further developments.
     

  7. Known as a "Volatile Function" (cf google), Now() will will update (ie recalculate) every time any cell on the sheet changes.

    Should you have any other cells dependent on the Now() cell, they, in turn will be recalced etc etc.
     
  8. travis

    travis

    Yes, you are right, it worked out perfectly. It was all I needed. Thanks to everyone.