Login Page - Create Account

Support Board


Date/Time: Sun, 29 Dec 2024 00:14:45 +0000



Post From: Problems with sc.OpenChartOrGetChartReference()

[2016-02-10 20:59:32]
bjohnson777 (Brett Johnson) - Posts: 284
If I call sc.OpenChartOrGetChartReference() with "OpenChartParameters.DaysToLoad = 0;" it will open the new chart windows correctly. If I call it with something like 250, it will keep loading the same chart windows over and over again until SC is closed.

I'm using ung and ugaz as the 2 test symbols with historical/daily bars. They open fine if I do it manually.

I simplified the code for testing and is shown below.

The sprintf debug output is below the code.

//code is inside "if(sc.Index == 0)" and is only run on the first bar.
for(i=0; i<pStockIndexNodeCount; i++) {
  if(pStockIndexArray[i].Name[0]=='\0') {continue;} //safety
  OpenChartParameters.Reset();
  OpenChartParameters.PriorChartNumber = pStockIndexArray[i].ChartNumber;
  OpenChartParameters.Symbol = pStockIndexArray[i].Name; //regular string
  OpenChartParameters.ChartDataType = DAILY_DATA;
  OpenChartParameters.HistoricalChartBarPeriod = HISTORICAL_CHART_PERIOD_DAYS;
  OpenChartParameters.DaysToLoad = 0; //0=same as calling chart
  OpenChartParameters.LoadWeekendData = 0; //don't want to see this on daily bars
  
  //debug before the call
  sprintf(debugstr, "Chart Pre: PreCNum=%d Sym=\"%s\" CDType=%d HistBarPd=%d DaysLoad=%d Wkend=%d",
  OpenChartParameters.PriorChartNumber, OpenChartParameters.Symbol.GetChars(), OpenChartParameters.ChartDataType,
  OpenChartParameters.HistoricalChartBarPeriod, OpenChartParameters.DaysToLoad, OpenChartParameters.LoadWeekendData);
  debug_PrintStringToFile(debugstr);
  
  pStockIndexArray[i].ChartNumber = sc.OpenChartOrGetChartReference(OpenChartParameters);
  
  //debug after the call
  sprintf(debugstr, "Chart Post: PreCNum=%d Sym=\"%s\" CDType=%d HistBarPd=%d DaysLoad=%d Wkend=%d CNum=%d",
  OpenChartParameters.PriorChartNumber, OpenChartParameters.Symbol.GetChars(), OpenChartParameters.ChartDataType,
  OpenChartParameters.HistoricalChartBarPeriod, OpenChartParameters.DaysToLoad, OpenChartParameters.LoadWeekendData,
  pStockIndexArray[i].ChartNumber);
  debug_PrintStringToFile(debugstr);
  
  } //end for()

This is with "OpenChartParameters.DaysToLoad = 0;" and works as expected.
Chart Pre: PreCNum=0 Sym="ung" CDType=1 HistBarPd=1 DaysLoad=0 Wkend=0
Chart Post: PreCNum=0 Sym="ung" CDType=1 HistBarPd=1 DaysLoad=4380 Wkend=0 CNum=2
Chart Pre: PreCNum=0 Sym="ugaz" CDType=1 HistBarPd=1 DaysLoad=0 Wkend=0
Chart Post: PreCNum=0 Sym="ugaz" CDType=1 HistBarPd=1 DaysLoad=4380 Wkend=0 CNum=3

This is with "OpenChartParameters.DaysToLoad = 250;" and was stopped after a few sets of opens.
Chart Pre: PreCNum=0 Sym="ung" CDType=1 HistBarPd=1 DaysLoad=250 Wkend=0
Chart Post: PreCNum=0 Sym="ung" CDType=1 HistBarPd=1 DaysLoad=250 Wkend=0 CNum=2
Chart Pre: PreCNum=0 Sym="ugaz" CDType=1 HistBarPd=1 DaysLoad=250 Wkend=0
Chart Post: PreCNum=0 Sym="ugaz" CDType=1 HistBarPd=1 DaysLoad=250 Wkend=0 CNum=3

Chart Pre: PreCNum=0 Sym="ung" CDType=1 HistBarPd=1 DaysLoad=250 Wkend=0
Chart Post: PreCNum=0 Sym="ung" CDType=1 HistBarPd=1 DaysLoad=250 Wkend=0 CNum=4
Chart Pre: PreCNum=0 Sym="ugaz" CDType=1 HistBarPd=1 DaysLoad=250 Wkend=0
Chart Post: PreCNum=0 Sym="ugaz" CDType=1 HistBarPd=1 DaysLoad=250 Wkend=0 CNum=5

Chart Pre: PreCNum=0 Sym="ung" CDType=1 HistBarPd=1 DaysLoad=250 Wkend=0
Chart Post: PreCNum=0 Sym="ung" CDType=1 HistBarPd=1 DaysLoad=250 Wkend=0 CNum=6
Chart Pre: PreCNum=0 Sym="ugaz" CDType=1 HistBarPd=1 DaysLoad=250 Wkend=0
Chart Post: PreCNum=0 Sym="ugaz" CDType=1 HistBarPd=1 DaysLoad=250 Wkend=0 CNum=7

Chart Pre: PreCNum=0 Sym="ung" CDType=1 HistBarPd=1 DaysLoad=250 Wkend=0
Chart Post: PreCNum=0 Sym="ung" CDType=1 HistBarPd=1 DaysLoad=250 Wkend=0 CNum=8
Chart Pre: PreCNum=0 Sym="ugaz" CDType=1 HistBarPd=1 DaysLoad=250 Wkend=0
Chart Post: PreCNum=0 Sym="ugaz" CDType=1 HistBarPd=1 DaysLoad=250 Wkend=0 CNum=9

Last thing: On the doc page, the "DAILY_CHART" enum name needs to be changed to "DAILY_DATA".

Thanks