Login Page - Create Account

Support Board


Date/Time: Sun, 19 May 2024 11:05:49 +0000



Post From: sc.IsFullRecalculation

[2019-03-02 19:27:44]
User982736 - Posts: 46
I am trying to use code I found from the examples that call IsFullRecalculation function.

I found that if I call that code as they did, the 20 period moving average is not returning
the correct value. If I comment that call out the moving average is correct.

When is it appropriate to use this function and why does the moving average not calculate
correctly when using it?

  // Section 1 - Set the configuration variables and defaults
  if (sc.SetDefaults)
  {
    sc.GraphName = "Trade Test Daily PL";

    sc.AutoLoop = 1; //Automatic looping is enabled.
    
    return;
  }

  // Section 2 - Do data processing
  
  if (sc.IsFullRecalculation)
    return;

  sc.MovingAverage(sc.BaseDataIn[SC_LAST], sc.Subgraph[1], MOVAVGTYPE_EXPONENTIAL, 20);
  float MovingAverage = sc.Subgraph[1][sc.Index];
  SCString MessageString;

  MessageString.Format("EMA: %.2f", MovingAverage);
  sc.AddMessageToLog(MessageString, 0);