Support Board
Date/Time: Sat, 28 Dec 2024 09:22:52 +0000
Problems with sc.OpenChartOrGetChartReference()
View Count: 691
[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 |
[2016-02-10 21:08:20] |
bjohnson777 (Brett Johnson) - Posts: 284 |
...always one more thing to test after I hit the post button... This appears to be linked with sc.GetChartBaseData(). If I use the negative chart number (sync the charts) with the 250 days above, it loops forever. If I use the positive chart number (chart bars not sync'd), it works. //this block of code is run in the main body of the study
for(i=0; i<pStockIndexNodeCount; i++) { //Safety. Skip charts that didn't load. if(pStockIndexArray[i].ChartNumber <= 0) {continue;} //Define a GraphData object to get the remote BaseData from the given chart. SCGraphData RemoteBaseData; sc.GetChartBaseData((-1 * pStockIndexArray[i].ChartNumber), RemoteBaseData); //LOOPS FOREVER //sc.GetChartBaseData(pStockIndexArray[i].ChartNumber, RemoteBaseData); //WORKS //Define a reference array to the remote array (like SC_LAST or SC_HLC). SCFloatArrayRef RemoteBaseArray = RemoteBaseData[pInputDataIndex]; //Safety check. if(RemoteBaseArray.GetArraySize() == 0) {continue;} //nothing to do } //end for() Thanks |
[2016-02-12 22:17:32] |
Sierra Chart Engineering - Posts: 104368 |
Last thing: On the doc page, the "DAILY_CHART" enum name needs to be changed to "DAILY_DATA". This appears to be linked with sc.GetChartBaseData(). If I use the negative chart number (sync the charts) with the 250 days above, it loops forever. If I use the positive chart number (chart bars not sync'd), it works. This must be the reason for the problem because the Days to Load setting is getting changed when you do this. Therefore, a new chart keeps getting opened because there is no longer a matching chart because the DaysToLoad parameter is different compared to the existing chart because it is not set to zero. We made a small change where the Days to Load setting in an existing chart does not have to be an exact match but has to be equal or greater than the OpenChartParameters.DaysToLoad parameter when calling sc.OpenChartOrGetChartReference(OpenChartParameters); This will solve the problem. 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 |
[2016-02-13 00:02:13] |
bjohnson777 (Brett Johnson) - Posts: 284 |
Confirmed build 1369 solved the problem. Thanks. I've run into a problem with the opened chart arrays not being synced. I'll start a new thread for that. |
To post a message in this thread, you need to log in with your Sierra Chart account: