Login Page - Create Account

Support Board


Date/Time: Fri, 29 Nov 2024 17:32:57 +0000



Post From: ACSIL: sc.ATR() - Output SCFloatArrayRef FloatArrayOut_2: No Vulues

[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);
  }
}