Announcement

Collapse
No announcement yet.

Series Object Returning Null Value

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

  • Series Object Returning Null Value

    Below is a snippet of the code I am using. The MTV series object is returning values as expected. However the LR and LBDivine values are both returning null values. Any ideas as to why? They are using functions that are built in to eSignal.

    Code:
    function main(LookBack) 
    {      
        if (MTV==null)
            MTV=efsInternal("MTValue",LookBack);
        if (LR==null)
            LR=middleLinearReg(10,1,MTV);
        if (LBDivine==null)
            LBDivine=lowerBB(18,1.8,LR);
        
        debugPrintln("MTV = " + MTV.getValue(0));
        debugPrintln("LR = " + LR.getValue(0));
        debugPrintln("LBDivine = " + LBDivine.getValue(0));
        
        Divine=LR.getValue(0)-LBDivine.getValue(0);
        return Divine;
    }

  • #2
    PHP Code:
    debugClear();

    var 
    MTV=null;//declare study series variables as global
    var LR=null;
    var 
    LBDivine=null;

    function 
    main(LookBack
    {     
        if(
    MTV===null
            
    MTV efsInternal("MTValue",LookBack);
        if(
    LR===null
            
    LR middleLinearReg(10,1,MTV);
        if(
    LBDivine===null
            
    LBDivine lowerBB(9,1.8,LR);//lowerBB() "nLength" parameter must be less than the middleLinearReg() nLength parameter, I don't know why
        //if(LBDivine===null) LBDivine = lowerBB(10,1.8,LR);//returns null
        //if(LBDivine===null) LBDivine = lowerBB(18,1.8,LR);//returns null

        
    if(MTV.getValue(0)==null) return;
        if(
    LR.getValue(0) == null) return;
        if(
    LBDivine.getValue(0)==null) return;
        
    debugPrintln("MTV = " MTV.getValue(0));
        
    debugPrintln("LR = " LR.getValue(0));
        
    debugPrintln("LBDivine = " LBDivine.getValue(0));
        
        
    Divine=LR.getValue(0)-LBDivine.getValue(0);
        return 
    Divine;
    }
    function 
    MTValue(x){//test function since non was supplied
        
    return offsetSeries(ema(9),x);

    Comment


    • #3
      pro_trader
      The reason L8Divine is returning null is simply because the Linear Regression study only returns values over the defined length and the Bollinger Band (the basis of which is nothing other than a simple moving average) requires a number of data points equal to its length +1 before it can return any values.
      You can very easily verify this using just the built-in studies. In a chart apply a built-in Linear Regression for example of length 10 and then apply to that a 20 period Bollinger Band study. You will see that the Bollinger Band will not return any values until its length is less than that of the Linear Regression by at least 1 (FWIW this is no different than a moving average requiring a number of bars equal to its length +1 before it can be fully primed and return a value)
      As to LR returning null that may be due to any number of reasons which are not apparent from your code since it is incomplete.
      As suggested in the guidelines of this forum you should provide the complete code necessary to replicate an issue so that others do not have to guess while trying to assist you
      Alex


      Originally posted by pro_trader View Post
      Below is a snippet of the code I am using. The MTV series object is returning values as expected. However the LR and LBDivine values are both returning null values. Any ideas as to why? They are using functions that are built in to eSignal.

      Code:
      function main(LookBack) 
      {      
          if (MTV==null)
              MTV=efsInternal("MTValue",LookBack);
          if (LR==null)
              LR=middleLinearReg(10,1,MTV);
          if (LBDivine==null)
              LBDivine=lowerBB(18,1.8,LR);
          
          debugPrintln("MTV = " + MTV.getValue(0));
          debugPrintln("LR = " + LR.getValue(0));
          debugPrintln("LBDivine = " + LBDivine.getValue(0));
          
          Divine=LR.getValue(0)-LBDivine.getValue(0);
          return Divine;
      }

      Comment

      Working...
      X