Login Page - Create Account

Support Board


Date/Time: Wed, 25 Dec 2024 14:05:21 +0000



Referencing data using sc.GetExactMatchForSCDateTime

View Count: 1070

[2015-11-24 15:51:03]
wwwingman - Posts: 185
Hi

I am using sc.GetExactMatchForSCDateTime to reference data from other time frames.
It works *most* of the time. I would expect it work all the time. Maybe I missed something.

I use two charts, main is 5 mn, secondary is 1 mn. Same session time/loaded number of days etc. Data is IQFeed.
I use the main start date time to find the index of the secondary index.

On 10 days of ES globex session (~2700 bars) I have 12 mistakes, meaning the index is not found.
The data seems ok, and the mistakes don't seem to appear on special moments like start/end of day/session/whatever.

Here is core of the code:

  for ( int _barIndex = sc.UpdateStartIndex ; _barIndex < sc.ArraySize - 1 ; _barIndex++ )
  {  
    //
    // Handle _barIndex bar
    //
    SCDateTime   _startDateTime     = sc.BaseDateTimeIn[_barIndex];
    int     _proxyStartIndex   = sc.GetExactMatchForSCDateTime(_proxyChartNumber, _startDateTime);
    
    if( _proxyStartIndex == -1 )
    {
      logMsg.Format("ERROR : date<%s> _proxyStartIndex<%d>", sc.FormatDateTime(sc.BaseDateTimeIn[_barIndex]).GetChars(), _proxyStartIndex);
      sc.AddMessageToLog(logMsg,0);
      continue;
    }
  }

Please advise.

-- W.
[2015-11-24 18:00:27]
Sierra Chart Engineering - Posts: 104368
What specifically is meant by?:
It works *most* of the time.

Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2015-11-24 18:08:44]
wwwingman - Posts: 185
What specifically is meant by?: It works *most* of the time.

It means, on rare occasions, the function returns a -1 error code.
It always happens on the same bars. But I do not see something specific in those bars.

I gave in the first message an example : on ES, 2700 bars, you have 12 missed calls. Thats 12/2700 or 4 calls per 1000 calls.

-- W
[2015-11-24 18:11:09]
Sierra Chart Engineering - Posts: 104368
The question is, is there actually an exact match where -1 is returned. We would not know without checking the bars where that occurred and we cannot do that.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
Date Time Of Last Edit: 2015-11-24 19:03:10
[2015-11-24 18:15:40]
wwwingman - Posts: 185
deleted.
Date Time Of Last Edit: 2015-11-24 18:16:24
[2015-11-24 18:32:09]
wwwingman - Posts: 185
The question is, is an exact match found where -1 is returned.

sc.GetExactMatchForSCDateTime returns an exact match when it DOES NOT return -1.

FWIW : I made a simple loop, looking for a secondary index with an exact same date time start as the main chart bar index.
And it works 100% of the time. As I would expect.
Which means, for me, there is a problem with sc.GetExactMatchForSCDateTime, or a misunderstanding on my side.

With this code : 100% correct indexes.


  for ( int _barIndex = sc.UpdateStartIndex ; _barIndex < sc.ArraySize - 1 ; _barIndex++ )
  {  
    //
    // Handle _barIndex bar
    //
    SCDateTime   _startDateTime     = sc.BaseDateTimeIn[_barIndex];
    
    // compute secondary index (instead of sc.GetExactMatchForSCDateTime)
    int     _proxyStartIndex   = -1;
    for (int _i=0 ; _i < _proxyDateTimeData.GetArraySize() ; _i++)
    {
      if ( _startDateTime == _proxyDateTimeData[_i] )
      {
        _proxyStartIndex = _i;
        break;
      }
    }
    
    if( _proxyStartIndex == -1 )
    {
      logMsg.Format("ERROR : date<%s> _proxyStartIndex<%d>", sc.FormatDateTime(sc.BaseDateTimeIn[_barIndex]).GetChars(), _proxyStartIndex);
      sc.AddMessageToLog(logMsg,0);
      continue;
    }
  }

[2015-11-24 19:08:12]
Sierra Chart Engineering - Posts: 104368
What we meant is there actually an exact match where -1 is returned? As we said, this is the question we cannot answer.

Here is the actual code:
int GetExactMatchForSCDateTime(int ChartNumber, const SCDateTime& DateTime)
  {
    int Index = GetContainingIndexForSCDateTime(ChartNumber, DateTime);

    SCDateTimeArray ChartDateTimeArray;
    GetChartDateTimeArray(ChartNumber, ChartDateTimeArray);

    if (ChartDateTimeArray[Index] == DateTime)
      return Index;
    else
      return -1;
  }

Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
Date Time Of Last Edit: 2015-11-25 05:56:47
[2015-11-24 22:32:45]
wwwingman - Posts: 185
OK. Thank you for your help.

I have no more questions.

For the record, and other programmers, here is what I finally understood :

1. There was a bug on my side. It led to wrong results on the loop I indicated above and on the sc.GetExactMatchForSCDateTime.

2. sc.GetExactMatchForSCDateTime WILL GIVE 100% matches IF you set the "Include Columns with no data" on both charts.
The problem is that on very low activity we may have missing bars. This option will force us to have all the 5 mn bars and all the 1 mn bars. All the 5 mn bars will have a matching 1 mn bar index.

3. Having the "include columns with no data" option will not solve the problem of mixing charts of different nature like 5 mn + renko charts. Using GetContainingIndexForSCDateTime seem to be the only solution.

-- W.

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account