Announcement

Collapse
No announcement yet.

my Array works but...

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

  • my Array works but...

    Hello,

    I've defined two variables, one is calculated and plots fine as a non-price study. The other is supposed to be an ema of the series and it also plots but it is not scaled correctly.

    How can I correct this?

    Also, I've got bbs and ema script in the preMAin()

    Thanks!

    // this part is in the pre main.
    var vVSI = null;
    var vEma = null;

    }

    function main() {
    //returns the series for VSI
    vVSI = (ema(6) - lowerBB(20,2)) - (upperBB(20,2) - ema(6));
    vEma = ema(6, vVSI);
    return new Array (vVSI, vEma);

    }
    Last edited by arsond; 10-07-2009, 02:09 PM.

  • #2
    Re: my Array works but...

    Hi arsond,

    try something like this

    PHP Code:
    {
    // this part is in the pre main.

    }
    //~ global variables must be declared outside any functions
    var vVSI null;
    var 
    vEma null;
    var 
    bInit=false;

    function 
    main() {
        if(!
    bInit){
            
    vVSI efsInternal("myVSI"); //~ returns the series for VSI
            
    vEma ema(6vVSI);
            
    bInit=true;
        }
        return new Array (
    vVSIvEma);
    }

    function 
    myVSI(){
        var 
    myEMA6=ema(6); // ~ saves it from being calculated twice
        
    return ((myEMA6 lowerBB(20,2)) - (upperBB(20,2) - myEMA6));

    Take a look at the efs2 links below and in the EFS Knowledgebase. Hope this helps.

    Steve


    Originally posted by arsond
    Hello,

    I've defined two variables, one is calculated and plots fine as a non-price study. The other is supposed to be an ema of the series and it also plots but it is not scaled correctly.

    How can I correct this?

    Also, I've got bbs and ema script in the preMAin()

    Thanks!

    // this part is in the pre main.
    var vVSI = null;
    var vEma = null;

    }

    function main() {
    //returns the series for VSI
    vVSI = (ema(6) - lowerBB(20,2)) - (upperBB(20,2) - ema(6));
    vEma = ema(6, vVSI);
    return new Array (vVSI, vEma);

    }

    Comment


    • #3
      Forgive the intrusion but I think "getSeries" needs to be added for it to plot by replacing:
      PHP Code:
              vVSI efsInternal("myVSI"); //~ returns the series for VSI
      vEma ema(6vVSI); 
      with
      PHP Code:
              vVSI getSeries(efsInternal("myVSI")); //~ returns the series for VSI
      vEma getSeries(ema(6vVSI)); 
      wayne

      Comment


      • #4
        thanks!

        Thanks gentlemen! I implimented parts from both and it works. I'm still learning the efs syntax and this feedback was very helpful.

        Thanks again!

        Carson

        Comment

        Working...
        X