Support Board
Date/Time: Wed, 25 Dec 2024 13:16:16 +0000
Passing SCGraphData Object as argument
View Count: 1135
[2015-11-06 01:27:47] |
reticent67 - Posts: 4 |
Hi, I’m coding a strategy based on four custom studies I have coded. Each study has multiple subgraphs. I am using a SCGraphData object and mapping my subgraphs in with GetStudyArraysFromChartUsingID() to SCFloatArray’s. SCGraphData D_S;
sc.GetStudyArraysFromChartUsingID(DS.GetChartNumber(), DS.GetStudyID(), D_S); int RefChartIndex = sc.GetContainingIndexForDateTimeIndex(DS.GetChartNumber(), sc.Index); SCFloatArray DubStoch = D_S[0]; SCFloatArray DS_Sig = D_S[5]; SCFloatArray DS_OB = D_S[6]; SCFloatArray DS_OS = D_S[7]; This works fine when I generate signals from within the strategy function, but since I have multiple studies and each study generates multiple signals, I would like to create a helper function for each study. However, when I try to pass the SCGraphData object (in this case D_S), the data doesn’t get passed with it. Well, the data for the main subgraphs – the double stochastic and its signal line – remains at zero for every bar. But the values for the overbought and oversold lines show they got passed when I debug. Is there a trick to passing the Graph Data object? Or is it better to just pass each float array as a parameter? |
[2015-11-06 03:21:39] |
Sierra Chart Engineering - Posts: 104368 |
We are not totally clear what you are doing. Our only suggestion is to pass SCGraphData by reference when passing it to a function.
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-06 22:42:24] |
reticent67 - Posts: 4 |
Sorry for the confusion, I will attempt to clarify. Here is a simple example of what I’m trying to do using a double stochastics crossover. If I use the following code, everything works as expected… SCGraphData DS;
sc.GetStudyArraysFromChartUsingID(DS_in.GetChartNumber(), DS_in.GetStudyID(), DS); int RefIndex = sc.GetExactMatchForSCDateTime(DS_in.GetChartNumber(), sc.BaseDateTimeIn[sc.Index]); SCFloatArray DubStoch = DS[0]; SCFloatArray DS_Sig = DS[5]; SCFloatArray DS_OB = DS[6]; SCFloatArray DS_OS = DS[7]; //Create New order object … if (DubStoch[RefIndex] < DS_OS[RefIndex] && sc.CrossOver(DubStoch, DS_Sig) == CROSS_FROM_BOTTOM) sc.BuyEntry(BuyOrder); if (PositionData.PositionQuantity > 0 && DubStoch[RefIndex] > DS_OB[RefIndex] && sc.CrossOver(DubStoch, DS_Sig) == CROSS_FROM_TOP) sc.BuyExit(BuyOrder); However, if I create a function to generate the trading signals and pass the graph data object (whether by reference or by value), the subgraph values for DubStoch (the main subgraph) and DS_Sig (it’s signal line) always remain at zero and no trades are executed. But the overbought and oversold lines correctly receive their values - 90 and 10, respectively. SCGraphData DS;
sc.GetStudyArraysFromChartUsingID(DS_in.GetChartNumber(), DS_in.GetStudyID(), DS); int RefIndex = sc.GetExactMatchForSCDateTime(DS_in.GetChartNumber(), sc.BaseDateTimeIn[sc.Index]); //Create New order object … if (calcDoubleStoch(DS, sc, RefIndex) > 0)) sc.BuyEntry(BuyOrder); if (PositionData.PositionQuantity > 0 && calcDoubleStoch(DS, sc, RefIndex) < 0)) sc.BuyExit(BuyOrder); } //Declared outside of study function... int calcDoubleStoch(SCGraphData &DS, SCStudyInterfaceRef sc, int Index) { SCFloatArray DubStoch = DS[0]; SCFloatArray DS_Sig = DS[5]; SCFloatArray DS_OB = DS[6]; SCFloatArray DS_OS = DS[7]; if (DubStoch[Index] < DS_OS[Index] && sc.CrossOver(DubStoch, DS_Sig) == CROSS_FROM_BOTTOM) return 1; if (DubStoch[Index] > DS_OB[Index] && sc.CrossOver(DubStoch, DS_Sig) == CROSS_FROM_TOP) return -1; else return 0; } |
[2015-11-15 00:40:50] |
Sierra Chart Engineering - Posts: 104368 |
We apologize for the delay. We see where the mistake is: SCFloatArray DubStoch = DS[0]; SCFloatArray DS_Sig = DS[5]; SCFloatArray DS_OB = DS[6]; SCFloatArray DS_OS = DS[7]; Needs to be: SCFloatArrayRef DubStoch = DS[0]; SCFloatArrayRef DS_Sig = DS[5]; SCFloatArrayRef DS_OB = DS[6]; SCFloatArrayRef DS_OS = DS[7]; Let us know if that helps and solves the problem. Once again we apologize for the delay. 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: 2017-10-23 06:03:00
|
[2015-11-15 03:08:56] |
Sierra Chart Engineering - Posts: 104368 |
As we went to update the documentation related to this, we see this function already demonstrates how to take a reference to one of the SCGraphData arrays: scsf_ReferenceDataFromAnotherChart(SCStudyInterfaceRef sc) This function is located in the /ACS_Source/Studies8.cpp file 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-15 03:10:44
|
To post a message in this thread, you need to log in with your Sierra Chart account: