Login Page - Create Account

Support Board


Date/Time: Fri, 14 Mar 2025 17:21:24 +0000



Post From: must recalculate the study to see correct values?

[2022-06-24 02:16:41]
User133994 - Posts: 80
To whom it may concern,

Attached is the ACSIL custom study code that I'm using. It works "as expected" when I press the "recalculate" menu item, but other times (i.e. when SC does a full recalculate automatically) which happens often, the study doesn't show any useful information. Rather, the region just paints "bars" at full height without a scale. I think I saw "NaN" at one time, but not anymore.

Nonetheless, I've tried adding the exception after the default block of "isfullrecalculation" to not run the code, but I need the historical bars to show the results of the study--so that won't work.

It is doing "automatic looping" so I'm not doing manual anything.

Please help me find the bug where it somehow thinks all the data is garbage and paints nothing. And, also, why is it all "fixed" when I press the "recalculate" item on the "chart" menu? I wonder why all the other "fullrecalculation" events cause garbage output (until it is cleaned up when I press the "recalculate" menu item)?

Thanks in advance!


SCSFExport scsf_DynamicHHLL(SCStudyInterfaceRef sc)
{

  SCSubgraphRef Subgraph_HH = sc.Subgraph[0];
  SCSubgraphRef Subgraph_LL = sc.Subgraph[1];

  SCInputRef Input_Study1 = sc.Input[0];
  SCInputRef Input_Study1Subgraph = sc.Input[1];

  SCInputRef Input_Lookback = sc.Input[4];
  SCInputRef Input_LookbackSubgraph = sc.Input[5];

  // Set configuration variables
  
  if (sc.SetDefaults)
  {
    // Set the configuration and defaults
    
    sc.GraphName = "DynHHLL v 0.05";
    sc.GraphRegion = 4;
    
    // Set the Length input and default it to 30
Input_Lookback.Name = "Input Study to determine Lookback Range";
    Input_Lookback.SetStudyID(100);
    
    Input_LookbackSubgraph.Name = "Lookback Study Subgraph";
    Input_LookbackSubgraph.SetSubgraphIndex(0);

    Subgraph_HH.Name = "DynHighestHigh";
    Subgraph_HH.DrawStyle = DRAWSTYLE_LINE;
    Subgraph_HH.PrimaryColor = RGB(0,255,0);

    Subgraph_LL.Name = "DynLowestLow";
    Subgraph_LL.DrawStyle = DRAWSTYLE_LINE;
    Subgraph_LL.PrimaryColor = RGB(0,255,255);

    Input_Study1.Name = "Input Study 1";
    Input_Study1.SetStudyID(11);

    Input_Study1Subgraph.Name = "Study 1 Subgraph";
    Input_Study1Subgraph.SetSubgraphIndex(0);


    sc.AutoLoop = 1;
    
    return;
  }
  
  
if(sc.ArraySize<50) return;

  // Get the subgraph specified with the Study 1
  // Subgraph input from the study specified with
  // the Input Study 1 input.
  SCFloatArray Study1Array;
  sc.GetStudyArrayUsingID(Input_Study1.GetStudyID(),Input_Study1Subgraph.GetSubgraphIndex(),Study1Array);

  SCFloatArray LookbackStudyArray;
  sc.GetStudyArrayUsingID(Input_Lookback.GetStudyID(),Input_LookbackSubgraph.GetSubgraphIndex(),LookbackStudyArray);


  int lookback = static_cast<int>(LookbackStudyArray[sc.Index]);
  int total =0;
  float RefStudyCurrentValue = 0.0;
  SCString DebugString;

  int& r_LastLookback = sc.GetPersistentInt(1);

  //ensure lookback is positive at all times
  if (lookback <= 0){
   lookback = 1;
   r_LastLookback = 1;
  }else if(r_LastLookback <= 0){
   lookback = 5;
   r_LastLookback = 5;
  }else{
   r_LastLookback = lookback;
  }

  DebugString.Format("lookback == : %d", lookback);
  sc.AddMessageToLog(DebugString, 0);

  Subgraph_HH[sc.Index] =sc.GetHighest(Study1Array, lookback);
  Subgraph_LL[sc.Index] =sc.GetLowest(Study1Array, lookback);

  DebugString.Format("highest == : %f", sc.GetHighest(Study1Array, lookback));
  sc.AddMessageToLog(DebugString, 0);
  DebugString.Format("lowest == : %f", sc.GetLowest(Study1Array, lookback));
  sc.AddMessageToLog(DebugString, 0);

}


I could try to live with the menu item work around...but everytime I press the "apply" button after changing a study attribute it ruins most all of my indicators (and what i thought I applied is masked by the garbage output of this indicator)...so I have to exit the study dialogue, find the menu recalc item, and click it. Very difficult to work that way.

Thanks again for your insights.
Date Time Of Last Edit: 2022-06-24 02:18:08