Login Page - Create Account

Support Board


Date/Time: Wed, 27 Nov 2024 14:42:12 +0000



Post From: Can you add support for milliseconds for sc.GetContainingIndexForSCDateTime

[2023-08-24 02:32:13]
AlinGA - Posts: 14
so, I have this example code


********************************************************************************************************/

#include "sierrachart.h"

SCDLLName("Test9999")


void WriteIntToLog (SCStudyInterfaceRef sc, const int integervalue, SCString Label)
{
  SCString Messagetw;
  Messagetw.Format(" %s : %i", Label.GetChars(), integervalue);
  sc.AddMessageToLog(Messagetw, 1);
}

void WriteFloatToLog (SCStudyInterfaceRef sc, const float floatvalue, SCString Label)
{
  SCString Messagetwf;
  Messagetwf.Format(" %s : %f", Label.GetChars(), floatvalue);
  sc.AddMessageToLog(Messagetwf, 1);
}

/****************************************************************************/
SCSFExport scsf_Test9999(SCStudyInterfaceRef sc)
{
  
  if (sc.SetDefaults)
{
sc.GraphName = "Test9999";
    sc.StudyDescription = "More info pls DM me at https://twitter.com/MnuchinB";

    sc.AutoLoop = 1;
sc.GraphRegion = 0;
    sc.ValueFormat = VALUEFORMAT_INHERITED;
    // sc.MaintainHistoricalMarketDepthData = 1;
// sc.UsesMarketDepthData = 1;


  }

  // Data processing

  // WriteIntToLog(sc, i, "");
  // WriteFloatToLog(sc, f, "");


  // E.G.
int CurrentBarDate = sc.BaseDateTimeIn[sc.Index].GetDate();
int CurrentBarTime = sc.BaseDateTimeIn[sc.Index].GetTimeInMilliseconds();

SCDateTime DateTime(CurrentBarDate ,CurrentBarTime );
int Index = sc.GetContainingIndexForSCDateTime(sc.ChartNumber, DateTime);
WriteIntToLog(sc, Index, "Index");


}

it should iterate thru the sc.Index from 0 to sc.ArraySize - 1
instead this is the log, all past indexes are all over the place, once it gets on live data works as it should

Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 248910 | 2023-08-23 22:25:53.154
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 255248 | 2023-08-23 22:25:53.154
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 260210 | 2023-08-23 22:25:53.154
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 196422 | Number times prior message previously added: 10623 | 2023-08-23 22:25:53.162
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 201342 | 2023-08-23 22:25:53.162
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 226008 | 2023-08-23 22:25:53.162
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 226608 | Number times prior message previously added: 2 | 2023-08-23 22:25:53.162
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 237599 | 2023-08-23 22:25:53.162
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 238685 | 2023-08-23 22:25:53.162
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 239548 | 2023-08-23 22:25:53.162
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 244626 | 2023-08-23 22:25:53.162
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 248158 | 2023-08-23 22:25:53.162
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 248800 | 2023-08-23 22:25:53.162
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 248962 | 2023-08-23 22:25:53.162
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 248987 | 2023-08-23 22:25:53.162
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 249286 | 2023-08-23 22:25:53.162
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 249419 | 2023-08-23 22:25:53.162
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 249928 | 2023-08-23 22:25:53.162
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 250515 | 2023-08-23 22:25:53.162
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 259874 | 2023-08-23 22:25:53.162
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 260210 | 2023-08-23 22:25:53.162
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 201205 | Number times prior message previously added: 11841 | 2023-08-23 22:25:53.169
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 201820 | 2023-08-23 22:25:53.169
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 212912 | 2023-08-23 22:25:53.169
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 213512 | 2023-08-23 22:25:53.169
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 214232 | 2023-08-23 22:25:53.169
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 226008 | 2023-08-23 22:25:53.169
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 226893 | Number times prior message previously added: 1 | 2023-08-23 22:25:53.169
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 231422 | 2023-08-23 22:25:53.169
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 237849 | 2023-08-23 22:25:53.169
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 245607 | 2023-08-23 22:25:53.169
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 249476 | 2023-08-23 22:25:53.169
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 252560 | 2023-08-23 22:25:53.169
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 259939 | 2023-08-23 22:25:53.169
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 260210 | 2023-08-23 22:25:53.169
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 214335 | Number times prior message previously added: 12402 | 2023-08-23 22:25:53.177
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 226008 | 2023-08-23 22:25:53.177
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 226680 | Number times prior message previously added: 2 | 2023-08-23 22:25:53.177
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 240114 | 2023-08-23 22:25:53.177
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 245896 | 2023-08-23 22:25:53.177
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 249399 | 2023-08-23 22:25:53.177
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 259667 | 2023-08-23 22:25:53.177
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 259677 | 2023-08-23 22:25:53.177
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 260210 | 2023-08-23 22:25:53.177
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 235889 | Number times prior message previously added: 13039 | 2023-08-23 22:25:53.185
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 250780 | 2023-08-23 22:25:53.185
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 260210 | 2023-08-23 22:25:53.185
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 260210 | Number times message previously added: 33700 | 2023-08-23 22:26:02.774
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 260210 | Number times message previously added: 29 | 2023-08-23 22:26:12.316
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 260210 | Number times message previously added: 18 | 2023-08-23 22:26:22.474
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 260210 | Number times message previously added: 15 | 2023-08-23 22:26:32.138
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 260210 | Number times message previously added: 21 | 2023-08-23 22:26:41.989
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 260211 | 2023-08-23 22:26:42.208
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 260211 | Number times message previously added: 22 | 2023-08-23 22:26:51.834
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 260211 | Number times message previously added: 30 | 2023-08-23 22:27:01.783
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 260211 | Number times message previously added: 20 | 2023-08-23 22:27:13.063
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 260211 | Number times message previously added: 26 | 2023-08-23 22:27:22.692
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 260212 | 2023-08-23 22:27:23.017
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 260212 | Number times message previously added: 32 | 2023-08-23 22:27:32.563
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 260212 | Number times message previously added: 21 | 2023-08-23 22:27:42.537
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 260212 | Number times message previously added: 24 | 2023-08-23 22:27:52.172
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 260212 | Number times message previously added: 27 | 2023-08-23 22:28:01.684
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 260213 | Number times prior message previously added: 27 | 2023-08-23 22:28:10.894
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 260213 | Number times message previously added: 28 | 2023-08-23 22:28:20.663
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 260213 | Number times message previously added: 18 | 2023-08-23 22:28:30.184
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 260213 | Number times message previously added: 37 | 2023-08-23 22:28:39.717
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 260213 | Number times message previously added: 20 | 2023-08-23 22:28:49.336
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 260213 | Number times message previously added: 22 | 2023-08-23 22:28:58.855
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 260213 | Number times message previously added: 32 | 2023-08-23 22:29:08.493
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 260214 | Number times prior message previously added: 9 | 2023-08-23 22:29:12.646
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 260214 | Number times message previously added: 18 | 2023-08-23 22:29:22.202
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 260214 | Number times message previously added: 21 | 2023-08-23 22:29:31.741
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 260214 | Number times message previously added: 13 | 2023-08-23 22:29:41.263
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 260214 | Number times message previously added: 15 | 2023-08-23 22:29:51.125
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 260214 | Number times message previously added: 24 | 2023-08-23 22:30:00.864
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 260215 | Number times prior message previously added: 3 | 2023-08-23 22:30:02.167
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 260215 | Number times message previously added: 33 | 2023-08-23 22:30:11.715
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 260215 | Number times message previously added: 26 | 2023-08-23 22:30:21.782
Chart: NQU23-CME[M] 50 Trades #1 | Study: Test9999 | Index : 260215 | Number times message previously added: 30 | 2023-08-23 22:30:31.749