Support Board
Date/Time: Sun, 22 Dec 2024 19:12:31 +0000
Problem with ACSIL code
View Count: 1243
[2015-05-28 16:27:27] |
Entropy - Posts: 36 |
I have the following code in my ACSIL strategy: /*==========================================================================*/ float Highest(SCFloatArrayRef In, int StartIndex, int Length) { float High = -FLT_MAX; // Get the high from the last Length indexes in the In array for (int SrcIndex = StartIndex; SrcIndex > StartIndex - Length; --SrcIndex) { if (SrcIndex < 0 || SrcIndex >= In.GetArraySize()) continue; if (In[SrcIndex] > High) High = In[SrcIndex]; } return High; } /*==========================================================================*/ float Lowest(SCFloatArrayRef In, int StartIndex, int Length) { float Low = FLT_MAX; // Get the low from the last Length indexes in the In array for (int SrcIndex = StartIndex; SrcIndex > StartIndex - Length; --SrcIndex) { if (SrcIndex < 0 || SrcIndex >= In.GetArraySize()) continue; if (In[SrcIndex] < Low) Low = In[SrcIndex]; } return Low; } /*==========================================================================*/ SCFloatArrayRef PercentRank(SCFloatArrayRef In, SCFloatArrayRef Out, int Index, int Length) { if (Index >= In.GetArraySize()) return Out; if(Index < 1 || Length < 1) return Out; if (Index < Length -1) Length = Index+1; float High = Highest(In, Index, Length); float Low = Lowest(In, Index, Length); float Range = High - Low; if (Range == 0) Out[Index] = Out[Index-1]; else Out[Index] = 100.0f * (In[Index] - Low) / Range; return Out; } I access it from the strategy like this: sc.RSI(sc.Close, sc.Subgraph[0], MOVAVGTYPE_WILDERS, RSI.GetInt()); PercentRank(sc.RSI, sc.Subgraph[1], sc.Index, STH.GetInt()); When I compile I get the following error which don't understand how to correct: -- Starting build of Custom Studies Source files: SC-FloxStochRSI.cpp. -- 17:19:44 "C:\SierraChart\CPPCompiler\bin\g++.exe" "C:\SierraChart\ACS_Source\SC-FloxStochRSI.cpp" -march=i686 -mtune=i686 -O2 -shared -static -static-libgcc -static-libstdc++ -s -fno-rtti -fno-exceptions -o "C:\SierraChart\Data\SC-FloxStochRSI.dll" C:\SierraChart\ACS_Source\SC-FloxStochRSI.cpp: In function 'void scsf_FloxStochRSI(SCStudyInterfaceRef)': C:\SierraChart\ACS_Source\SC-FloxStochRSI.cpp:189:60: error: invalid initialization of non-const reference of type 'SCFloatArrayRef {aka c_ArrayWrapper<float>&}' from an rvalue of type '<unresolved overloaded function type>' PercentRank(sc.RSI, sc.Subgraph[1], sc.Index, STH.GetInt()); ^ C:\SierraChart\ACS_Source\SC-FloxStochRSI.cpp:42:17: error: in passing argument 1 of 'c_ArrayWrapper<float>& PercentRank(SCFloatArrayRef, SCFloatArrayRef, int, int)' SCFloatArrayRef PercentRank(SCFloatArrayRef In, SCFloatArrayRef Out, int Index, int Length) ^ -- End of Build -- 17:19:45 Any ideas on how to fix this error? Cheers |
[2015-05-28 16:59:56] |
Sierra Chart Engineering - Posts: 104368 |
This line: PercentRank(sc.RSI, sc.Subgraph[1], sc.Index, STH.GetInt()); Needs to be changed for it to receive the output array of the prior call for its input array: PercentRank(sc.Subgraph[0], sc.Subgraph[1], sc.Index, STH.GetInt()); It would never make sense to pass a function pointer. 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-05-28 17:02:54] |
Entropy - Posts: 36 |
I should have seen that! Thanks! It now compiles! Cheers Date Time Of Last Edit: 2015-05-28 17:03:17
|
To post a message in this thread, you need to log in with your Sierra Chart account: