Announcement

Collapse
No announcement yet.

Calc 20 day 1 min ave - one time per day.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Calc 20 day 1 min ave - one time per day.

    I want to calculate the 20 day average of 1 minute values. This only needs to be done once per day. I don't need to have the system updating that on every bar.

    Will this do that?

    if (bInit == false) {
    xAdj = sma(2500,vSymbol);
    xAdjvalue - xAdj.getValue(0);
    bInit = true;
    }

    When I use xAdjvalue I don't want it to recalculte the 2500 bar long average - just use the value already caluculated.

    Would this also do that?

    xAdjvalue = sma(2500,vSymbol,0);

    Thanks, jgr

  • #2
    Well, you are already setting an average up in your init function... Why don't you simply call the getValue() of that average when you need it in your efs.

    I would think it would be more difficult and use more data/cpu resources to discard and reinitialize the average every time you need it. It's probably better to simply let it run in the background and then GET the value you need when you need it.

    Does this make sense?

    B
    Brad Matheny
    eSignal Solution Provider since 2000

    Comment


    • #3
      PHP Code:
      if(getDay() != getDay(-1)) sma(2500)
      return 

      or if you dont want the value returned on every bar, then you could give this a try
      PHP Code:
      if(getDay() != getDay(-1)) return sma(2500
      or if you want it done at a specific time, this would retrieve a new value at 2:15pm
      PHP Code:
      if(getHour() == 14 && getMinute() == 15sma(2500)
      return 

      Last edited by kalzenith; 09-29-2009, 03:00 PM.

      Comment

      Working...
      X