Announcement

Collapse
No announcement yet.

Fault with EFS2 custom Linear Regression

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

  • Fault with EFS2 custom Linear Regression

    the below images speak for themselves , Formula Parameter Length is set at 25 but i get the same problem with all settings,






  • #2
    This stems from the chart not being able to go back and recalculate those older values (as by nature the Linear Regression older values change, and are not set in stone). Apparently the EFS1 Linear Regression study suffers from the same problem unless it's reloaded on each new bar.

    The most current value will be correct, it's just the display of the plot is all wacky.

    Let me see what I can do for Beta/2 or Beta/3.

    Comment


    • #3
      Possible fix for efs2 Linear Regression

      DionLoy
      the linear regression older values seem good so i thought as a possible fix to get the chart to plot the lines correctly to use the drawLineRelative function instead of the return getSeries , have a look at the below code and see what you think i added a filter xMidLR1 for only the base linear regression line as all the lines will change at the same time, in theory anyway.
      also i had to change the FunctionParameter "Length" setLowerLimit from 0 to 3 and the setDefault from 0 to 100 to get lines on loading of the efs.




      PHP Code:
      /*********************************************************
      By Alexis C. Montenegro for eSignal © December 2004       
      Use and/or modify this code freely. If you redistribute it
      please include this and/or any other comment blocks and a 
      description of any changes you make.                      
      **********************************************************/

      var fpArray = new Array();

      function 
      preMain() {

          
      setPriceStudy(true);
          
      setStudyTitle("LinReg");
          
      setCursorLabelName("LRUpr"0);
          
      setCursorLabelName("LRBas"1);
          
      setCursorLabelName("LRLwr",2);
          
      setDefaultBarFgColor(Color.blue0);
          
      setDefaultBarFgColor(Color.red1);
          
      setDefaultBarFgColor(Color.blue2);
          
      setPlotType(PLOTTYPE_LINE0);
          
      setPlotType(PLOTTYPE_LINE1);
          
      setPlotType(PLOTTYPE_LINE2);
          
      setDefaultBarThickness(20);
          
      setDefaultBarThickness(21);
          
      setDefaultBarThickness(22);
          
      askForInput();
          
          var 
      x=0;
          
      fpArray[x] = new FunctionParameter("Length"FunctionParameter.NUMBER);
          
      with(fpArray[x++]){
              
      setLowerLimit(3); //  changed from  0 to 3 for wonky line fix        
              
      setDefault(100);  //  changed from  0 to 100 for wonky line fix
          
      }
          
      fpArray[x] = new FunctionParameter("StdDev"FunctionParameter.NUMBER);
          
      with(fpArray[x++]){
              
      setLowerLimit(0);        
              
      setDefault(1);
          }
          
      fpArray[x] = new FunctionParameter("Source"FunctionParameter.STRING);
          
      with(fpArray[x++]){
              
      addOption("open"); 
              
      addOption("high");
              
      addOption("low");
              
      addOption("close");
              
      addOption("hl2");
              
      addOption("hlc3");
              
      addOption("ohlc4"); 
              
      setDefault("close"); 
          }
          
      fpArray[x] = new FunctionParameter("Params"FunctionParameter.BOOLEAN);
          
      with(fpArray[x++]){
              
      setName("Show Parameters");
              
      setDefault(false);
          }
      }

      var 
      bInit false;
      var 
      xUpLR null;
      var 
      xMidLR null;
      var 
      xLoLR null;

      var 
      xMidLR1 null;    // added for wonky line fix

      function main(Length,StdDev,Source,Params) {

          if(
      bInit == false){
              
      xUpLR upperLinearReg(LengthStdDev,eval(Source)());
              
      xMidLR middleLinearReg(LengthStdDev,eval(Source)());
              
      xLoLR lowerLinearReg(LengthStdDev,eval(Source)());
              
      setShowTitleParameters(eval(Params));
              
      bInit true;
          }

      if(
      getCurrentBarIndex()==0){    
          if( 
      xMidLR.getValue(0) != xMidLR1){   // the following added for wonky line fix
          
      clearLines();
          
      drawLineRelative(-(Length-1), xUpLR.getValue(-(Length-1)), 0xUpLR.getValue(0), PS_SOLID1Color.blue,1);
          
      drawLineRelative(-(Length-1), xMidLR.getValue(-(Length-1)), 0xMidLR.getValue(0), PS_SOLID1Color.red,2);
          
      drawLineRelative(-(Length-1), xLoLR.getValue(-(Length-1)), 0xLoLR.getValue(0), PS_SOLID1Color.blue,3);
          
      xMidLR1 =  xMidLR.getValue(0);
          }
       }  
          return ;
          
      //   removed return new Array for wonky line fix.
          //return new Array (getSeries(xUpLR),getSeries(xMidLR),getSeries(xLoLR));  





      Last edited by shogun; 03-16-2005, 10:57 AM.

      Comment


      • #4
        shogun
        FWIW the reason I set the the default length to 0 - which means "all data" - is to replicate the default setting of the Linear Regression in Basic Studies
        Alex

        Comment


        • #5
          Alexis
          the only reason i changed the default Length fro 0 to 100 was i was getting a vertical line on loading of the efs as the first and third parameters of drawLineRelative where both the same,
          i think the fault lies with the way getSeries() is retrieving the past data when there is more than one data input,but we are getting into territory which is way beyond my abilities.

          i am finding efs2 much easier to understand as there is far less coding needed to achive the same results than with efs1.

          Comment


          • #6
            i have just edited the below code to add the following to fix a bug which arose when using the edit studies.

            the following has been added.

            PHP Code:
            if(getCurrentBarIndex()==0){


            Comment


            • #7
              Would someone pls post a complete good version of the efs?? thx.

              Comment

              Working...
              X