Login Page - Create Account

Support Board


Date/Time: Mon, 23 Dec 2024 00:19:49 +0000



Post From: Problem with ACSIL code

[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