Support Board
Date/Time: Sat, 08 Feb 2025 16:49:34 +0000
Help getting SCGraphData data using a loop
View Count: 861
[2020-07-17 22:21:53] |
User254520 - Posts: 16 |
Please look at the below request and let me know if I need to submit any other supporting documentation/screen shots, or format the question a better way. I'm trying to get the "SCGraphData" studies data using an array with a loop. Please help with the problem at the bottom of this request in BOLD. I am including relevant information above to paint a complete picture. The example has 1 chart with 3 studies applied to it. - The first study is the custom study, and the next two are Sierra's built-in studies. //////// Structures ////// struct Study { int number; SCGraphData subgraphs; }; struct Chart { int number; std::vector<Study> studies; }; std::vector<Chart> v_charts; //// Filling up the "v_charts" vector with chart numbers and studies IDs std::string chart_name = ""; std::string study_name = ""; SCString subgraph_name = ""; for (int chart_number = 1; chart_number < 10; chart_number++) { chart_name = sc.GetChartName(chart_number); if (chart_name == "") continue; Chart chart; chart.number = chart_number; for (int study_number = 1; study_number < 30; study_number++) { study_name = sc.GetStudyNameFromChart(chart_number, study_number); if (study_name == "") continue; SCGraphData sc_study; sc.GetStudyArraysFromChartUsingID(chart_number, study_number, sc_study); Study study; study.number = study_number; study.subgraphs = sc_study; chart.studies.push_back(study); } v_charts.push_back(chart); } ////////////////the following code works////// SCGraphData sc_study1; sc.GetStudyArraysFromChartUsingID(1, 1, sc_study1); v_charts[0].studies[0].subgraphs = sc_study1; SCGraphData sc_study2; sc.GetStudyArraysFromChartUsingID(1, 2, sc_study2); v_charts[0].studies[1].subgraphs = sc_study2; SCGraphData sc_study3; sc.GetStudyArraysFromChartUsingID(1, 3, sc_study3); v_charts[0].studies[2].subgraphs = sc_study3; /////////////The following code doesn't work////// //[b]If i put the above in a loop, the result of last iteration of the loop will overwrite all the previous iterations; in other words: the output of the 3 studies will be the same as the output of the study in the last iteration.[/b] for (Chart& chart : v_charts) { for (Study& study : chart.studies) { SCGraphData subgraphs; sc.GetStudyArraysFromChartUsingID(chart.number , study.number, subgraphs); study.subgraphs = subgraphs; } } Thank you so much for your help! |
[2020-07-18 12:58:11] |
User254520 - Posts: 16 |
I figured out how to get it to work. Please close this post. Thank you |
To post a message in this thread, you need to log in with your Sierra Chart account: