Announcement

Collapse
No announcement yet.

Invalid timestamps returned by RequestHistory

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

  • Invalid timestamps returned by RequestHistory

    I am having a problem with the timestamps returned by the RequestHistory method. The first bar is usually ok; it has a timestamp in the specified day range. However all subsequent bars have their timestamp set to "30/12/1899 00:00".

    For example, I am making the following call for 5min bars:

    int handle = esignal.get_RequestHistory("$INDU", "5", barType.btDAYs, 2, -1, -1)

    I then call esignal.get_IsHistoryReady(handle) to see if data is available or wait for the OnBarsReceived callback if it is not.

    Once the data is ready, I then use the esignal.get_GetBar method to loop over the bars as follows.

    int numBars = esignal.get_GetNumBars(handle);

    for (int i=0; i < numBars; i++)
    {
    BarData bar = esignal.get_GetBar(handle, i);
    DateTime timestamp = bar.dtTime; // Timestamp is wrong after the first row!!!!!
    ...
    }

    I don't think I am doing anything wrong here. Has anyone else experienced this problem?

    I am using .NET 1.1 on Windows XP Professional SP2 with eSignal 8.0.

  • #2
    Your index into the get_GetBar function is wrong. The latest bar has an index of 0, the previous bar -1, the previous to that -2, and so on.

    If you don't mind reading the latest bar first then scanning backwards, then simply replace you call with this:

    BarData bar = esignal.get_GetBar(handle, -i);


    If you need to scan from oldest to most recent, then replace your call with this:

    BarData bar = esignal.get_GetBar(handle, -(numBars - 1) + i);


    Good luck.

    Mikey

    Comment


    • #3
      Thanks Mikey, works fine now.

      I can see it does just that in VB snippet of the Developer Reference. I should pay closer attention in future :-)

      Comment

      Working...
      X