Announcement

Collapse
No announcement yet.

Stochastics

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

  • Stochastics

    Hello

    Can anyone confirm if the moving averages within stochastics can be modified to exponential rather than the default simple.

    Thanks

  • #2
    Re: Stochastics

    dekko
    The builtin Stochastic functions do not offer that option however you can easily modify the StochasticK and StochasticD scripts [which are in the Library folder of Formulas] that calculate the Stochastic indicator without using the builtin functions and set them to use exponential instead of simple moving averages
    Alex


    Originally posted by dekko
    Hello

    Can anyone confirm if the moving averages within stochastics can be modified to exponential rather than the default simple.

    Thanks

    Comment


    • #3
      Hi Alexis

      Thanks for the quick reply.

      How do I do this exactly out of interest? Are you able to provide steps?

      Thanks

      Comment


      • #4
        dekko
        Using the EFS Editor open the formulas I indicated in my prior message and replace sma [in line 48 of the StochasticK.efs and in line 34 of the StochasticD.efs] with ema
        Then save each formula
        Alex


        Originally posted by dekko
        Hi Alexis

        Thanks for the quick reply.

        How do I do this exactly out of interest? Are you able to provide steps?

        Thanks

        Comment


        • #5
          Cheers once again Alexis

          Ive done this and it now show stochs D & K as 2 separate stochs indicators. Is there anyway to consolidate these into 1 indicator just liek the standard stochs?

          Thanks

          Comment


          • #6
            dekko
            The simplest solution that does not require any coding and that you can easily implement with a couple of mouse clicks through Edit Studies is to overlay one study over the other and set both studies to use the same scale
            Alternatively edit the StochasticD.efs to return both the %K and %D plots by replacing the return statement in line 36 with
            return new Array (xStochK.getValue(0), xStochD.getValue(0));
            You will then need to add the necessary statements in the preMain() function to assign a name to the Cursor label, color the plot etc. If you are unfamiliar on how to do this then I would suggest that you review the Beginner Tutorials 1-4 which are in the Help Guides and Tutorials-> Beginner Tutorials folder of the EFS KnowledgeBase
            Alex


            Originally posted by dekko
            Cheers once again Alexis

            Ive done this and it now show stochs D & K as 2 separate stochs indicators. Is there anyway to consolidate these into 1 indicator just liek the standard stochs?

            Thanks

            Comment


            • #7
              Try this. I quite like the %D as an expontential ma. I'm only an efs beginner, so it may have errors, thatsaid seems ok. nb. I've set defaults to 20(3)10.

              PHP Code:
              var fpArray = new Array();

              function 
              preMain() {

                  
              setPriceStudy(false);
                  
              setStudyTitle("Stochastic e");
                  
              setCursorLabelName("%K",0);
                  
              setCursorLabelName("%D e",1);
                  
              setDefaultBarFgColor(Color.blue0);
                  
              setDefaultBarFgColor(Color.red1);
                  
              setPlotType(PLOTTYPE_LINE,0);
                  
              setPlotType(PLOTTYPE_LINE,1);
                  
              setDefaultBarThickness(1,0);
                  
              setDefaultBarThickness(1,1);
                  
              askForInput();
                      
                  var 
              x=0;
                  
              fpArray[x] = new FunctionParameter("KLength"FunctionParameter.NUMBER);
                  
              with(fpArray[x++]){
                      
              setName("%K");
                      
              setLowerLimit(1);        
                      
              setDefault(20);
                  }
                  
              fpArray[x] = new FunctionParameter("KSmoothing"FunctionParameter.NUMBER);
                  
              with(fpArray[x++]){
                      
              setName("%KSmooth");
                      
              setLowerLimit(1);        
                      
              setDefault(3);
                  }
                  
              fpArray[x] = new FunctionParameter("DLength"FunctionParameter.NUMBER);
                  
              with(fpArray[x++]){
                      
              setName("%D");
                      
              setLowerLimit(1);        
                      
              setDefault(10);
                  }
                  
              fpArray[x] = new FunctionParameter("Symbol"FunctionParameter.STRING);
                  
              with(fpArray[x++]){
                      
              setDefault();
                  }
                  
              fpArray[x] = new FunctionParameter("Interval"FunctionParameter.STRING);
                  
              with(fpArray[x++]){
                      
              setDefault();
                  }
                  
              fpArray[x] = new FunctionParameter("Upper"FunctionParameter.NUMBER);
                  
              with(fpArray[x++]){
                      
              setLowerLimit(0);
                      
              setDefault(80); 
                  }
                  
              fpArray[x] = new FunctionParameter("Lower"FunctionParameter.NUMBER);
                  
              with(fpArray[x++]){
                      
              setLowerLimit(0);
                      
              setDefault(20); 
                  }
                  
              fpArray[x] = new FunctionParameter("Params"FunctionParameter.BOOLEAN);
                  
              with(fpArray[x++]){
                      
              setName("Show Parameters");
                      
              setDefault(false);
                  }
              }

              var 
              bInit false;
              var 
              xStochK null;
              var 
              xStochD null;

              function 
              main(KLength,KSmoothing,DLength,Symbol,Interval,Upper,Lower,Params) {

                  if(
              bInit == false){
                      if(
              Symbol == nullSymbol getSymbol();
                      if(
              Interval == nullInterval getInterval();
                      var 
              vSymbol Symbol+","+Interval;
                      
              xStochK stochK(KLength,KSmoothing,DLength,sym(vSymbol));
                      
              xStochD ema(DLengthxStochK);
                      
              addBandUpperPS_SOLID1Color.grey,"Upper");
                      
              addBandLowerPS_SOLID1Color.grey,"Lower");
                      
              setShowTitleParameters(eval(Params));
                      
              bInit true;
                  }

                  return new Array (
              getSeries(xStochK),getSeries(xStochD));

              Comment

              Working...
              X