Announcement

Collapse
No announcement yet.

Prior Indicator Values

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

  • Prior Indicator Values

    I'm trying to determine if a momentum indicators values are rsing or falling for three consecutive bars.
    First, I wrote my own custom StochRSI, and it plots OK.
    Next, iwanted to see if I could reference and plot it from another script.
    This code works fine, it plots my custom StochRSI:
    var Var1;
    Var1 = call("/Test/StochRSI.efs");
    if(Var1 == null) return;
    return Var1;

    What I 'd like to do is reference the prior four values - I want to determine if the indicator is rising or falling. I tried this code and while it passes syntax, in applying it to a chart I get a formula error (shown below code). I'm stuck - how can I determine if a
    momentum indicator is steadily rising or falling?

    var Study1 = null;
    function main() {
    var Var1;
    var Var2;
    var Var3;
    var Var4;

    if(Study1 == null) Study1 = call("/Test/StochRSI.efs");

    Var1 = Study1.getValue(0);
    Var2 = Study1.getValue(-1);
    Var3 = Study1.getValue(-2);
    Var4 = Study1.getValue(-3);

    TypeError: Study1 has no properties

    Yuri
    Good Trading,
    Yuri Shramenko

  • #2
    Yuri
    You cannot use the getValue() method on Study1 because it is not a series.
    If you are returning Study1 you can use the ref() function to access its prior values (see the link for the required syntax) otherwise you will need to create an array to store the historical values. For information on arrays see this article in the EFS KnowledgeBase
    Alex

    Comment

    Working...
    X