Support Board
Date/Time: Fri, 29 Nov 2024 14:54:14 +0000
[Programming Help] - ACSIL: sc.ATR() - Output SCFloatArrayRef FloatArrayOut_2: No Vulues
View Count: 2038
[2020-04-10 14:47:20] |
User36703 - Posts: 29 |
Hello, please can somebody help me with the issue below. I am not able to get the ATR array output (FloatArrayOut_2) from the function. I am using this syntax according the intructions: SCFloatArrayRef ATR(SCBaseDataRef BaseDataIn, SCFloatArrayRef FloatArrayOut_1, SCFloatArrayRef FloatArrayOut_2 , int Length, unsigned int MovingAverageType);
Code: sc.AutoLoop = 1; SCFloatArray TrueRangeArray; SCFloatArray AverageTrueRangeArray; if (CalculationMethod == 1) { BarIndex = sc.Index; } else if (CalculationMethod == 0) { BarIndex = sc.Index - 1; } int ATRPeriodLength = Input_ATRPeriodLength.GetInt(); sc.DataStartIndex = ATRPeriodLength - 1; sc.ATR(sc.BaseDataIn, TrueRangeArray, AverageTrueRangeArray, ATRPeriodLength, MOVAVGTYPE_SIMPLE); float actualTR = TrueRangeArray[BarIndex]; float actualATR = AverageTrueRangeArray[BarIndex]; I get actualTR value from the function, but I am not able to get values from AverageTrueRangeArray output, only zero is returned. Thank you. |
[2020-05-15 11:36:36] |
User462086 - Posts: 196 |
Just ran into this too. The following worked for me using manual looping. Something similar might work with automatic looping: #include "sierrachart.h" SCDLLName("Test_scATR") SCSFExport scsf_Test_scATR(SCStudyInterfaceRef sc){ SCString DebugMessage; SCSubgraphRef Subgraph = sc.Subgraph[0]; SCFloatArrayRef TR = Subgraph.Arrays[0]; // output array 1 SCFloatArrayRef ATR = Subgraph.Arrays[1]; // output array 2 SCInputRef Length = sc.Input[0]; SCInputRef MAtype = sc.Input[1]; if (sc.SetDefaults){ sc.GraphName = "Test_scATR"; sc.AutoLoop = 0; Subgraph.Name = "Subgraph"; Subgraph.DrawStyle = DRAWSTYLE_IGNORE; Length.Name = "Length"; Length.SetInt(14); MAtype.Name = "Moving Average Type"; MAtype.SetMovAvgType(MOVAVGTYPE_SIMPLE); return; } // prevent write to log on exit if (sc.LastCallToFunction) return; // fill arrays for (int i = Length.GetInt(); i < sc.ArraySize; i++){ sc.ATR(sc.BaseDataIn, TR, ATR, i, Length.GetInt(), MAtype.GetMovAvgType()); } // check array values for (int i = Length.GetInt(); i < sc.ArraySize; i++){ DebugMessage.Format("TR[%d]=%g | ATR[%d]=%g", i, TR[i], i, ATR[i]); sc.AddMessageToLog(DebugMessage,0); } } |
[2023-01-27 01:47:07] |
User909252 - Posts: 20 |
I'm having the same issue with ATR only outputting 0 with autolooping. Any thoughts Sierra? |
[2023-01-31 21:20:37] |
Sierra_Chart Engineering - Posts: 17228 |
We will put together a proper code example for you. You cannot pass in temporarily defined arrays into this function sc.ATR.
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, use the Teton service: Sierra Chart Teton Futures Order Routing Date Time Of Last Edit: 2023-01-31 21:20:50
|
[2023-02-01 21:50:31] |
Sierra_Chart Engineering - Posts: 17228 |
Code example: SCSFExport scsf_AverageTrueRangeExample(SCStudyInterfaceRef sc)
{ SCSubgraphRef Subgraph_ATR = sc.Subgraph[0]; SCInputRef Subgraph_Length = sc.Input[1]; if (sc.SetDefaults) { sc.GraphName = "Average True Range Example"; sc.GraphRegion = 1; sc.ValueFormat = VALUEFORMAT_INHERITED; sc.AutoLoop = 1; //Automatic looping Subgraph_ATR.Name = "ATR"; Subgraph_ATR.DrawZeros = false; Subgraph_ATR.PrimaryColor = RGB(0,255,0); Subgraph_ATR.DrawStyle = DRAWSTYLE_LINE; Subgraph_Length.Name = "Moving Average Length"; Subgraph_Length.SetInt(14); Subgraph_Length.SetIntLimits(1, MAX_STUDY_LENGTH); return; } sc.DataStartIndex = Subgraph_Length.GetInt() - 1; sc.ATR(sc.BaseDataIn, Subgraph_ATR.Arrays[0], Subgraph_ATR, Subgraph_Length.GetInt(), MOVAVGTYPE_SIMPLE); float TrueRange = Subgraph_ATR.Arrays[0][sc.Index]; } 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, use the Teton service: Sierra Chart Teton Futures Order Routing |
To post a message in this thread, you need to log in with your Sierra Chart account: