Announcement

Collapse
No announcement yet.

OnBarsReceived event does not always fire

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • OnBarsReceived event does not always fire

    I have a problem working with OnBarsReceived event in the desktopSampleVB code provided here http://share.esignal.com/groupconten...r=&groupid=185

    I am trying to process multiple history requests in this code and having problems with OnBarsReceived event. It seems that it does not fire sometimes after I send a history request.

    Here is one of the tests I did.

    I added a line
    requestHistoryHandle = esignal.RequestHistory("AMGN", "5", btDAYS, 1, -1, -1)
    after the line
    requestHistoryHandle = esignal.RequestHistory(sym, "5", btDAYS, 1, -1, -1)

    in getSym procedure (so I have two history requests in getSym procedure now)

    while in ProcessHistory sub I added the line
    SaveFile (sBar) {to save just the last bar}
    after
    esignal.ReleaseHistory (historyHandle)

    SaveFile is a simple file writing procedure I wrote (in the same project) which I verified to work.

    The idea was that once I start the form and click on "HistoryServer" it would save two files, one for the symbol provided in the textBox and another for AMGN (which is hard coded). What I found was that it saved only one file, for AMGN, and OnBarsReceived event did not fire the first time for the symbol from the txtBox, regardless of what that symbol was. I confirmed that the event did not fire by placing a breakpoint within OnBarsReceived Sub, execution was stopped at the breakpoint only after the second history request.

    Also, sometimes a symbol just goes "bad" when I debug the frmMain (I start it, enter symbol in txtBox, click on "HistoryServer" and then get stopped at a breakpoint somewhere in the code) and step through the Subs and then exit at an arbitrary point. From then on, no history data can be obtained for that symbol, even though I can get data for other symbols. The only way to "fix" it is to restart eSignal and restart VB project, and sometimes even this does not help and I have to restart my computer.

    What to do it about it (besides restarting thing, which is a non-solution)?

    Any help is greatly appreciated!

  • #2
    Hi magictrader,

    Don't release your history handle until you are done processing the data.

    Can you give some more detail about symbols going "bad?" You mentioned the code stops at a breakpoint. At what point does it seem to be stopping?

    Comment


    • #3
      Hi magictrader,
      I have had problems with events not occuring when I expect them to. Some of these I have traced back to what appears to be some latency in eSignal. That is, it appears that your code can execute faster than eSignal is prepared to respond. Let me describe two problems and my solutions.

      1) When you release a handle, series of handles, or the eSignal object, it takes some time for the release to occur. In Visual Basic, I have learned to insert a 10-30 second "Wait" which gives eSignal time to "forget about it" before you re-initiate.

      2) When you request a handle, eSignal appears to respond with a zero value when it is not ready to give you a handle - resulting in a bogus handle and no events. I have found that you need to trap the zero and hit eSignal again to initiate the request and get a valid handle - actually, my code loops up to 1000 times before giving up on getting a non-zero handle.

      Best of Luck,
      Cone Killer
      Last edited by Cone Killer; 06-27-2007, 12:55 PM.

      Comment


      • #4
        I have the problem, too.
        RequestHistroy returns a valid handle, which is > 0, and my code will not release the handle unless OnBarsReceived fires.
        But sometimes the event never fires, especially when I request end-of-days.
        If I give an invalid symbol, such as "hello, i'm not a symbol", when I call RequestHistory, sometimes OnBarsReceived fires, and GetNumBars return 0, sometimes the event never fires

        Comment


        • #5
          I didn't see this and started another thread. Same problem, but I think there are missing ticks. Will check for cookies=0.

          Comment

          Working...
          X