Announcement

Collapse
No announcement yet.

RSI Moving Average

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

  • RSI Moving Average

    I need some help. Anyone know how to create a moving average within an RSI study?

    Any assistance is greatly appreciated.

  • #2
    developer,

    Please check this link that should give you an idea of what you want.

    Comment


    • #3
      Thanks Steve.

      Comment


      • #4
        You are most welcome.

        Comment


        • #5
          Steve,

          I was actually looking to be able to calculate the moving average of the RSI itself. For example, I have a 12 hour RSI study in a chart. I would like to have the 6 period moving average of that 12 hour RSI plotted in the same space as the 12 hour RSI itself.

          Any thoughts on how that can be done?

          Comment


          • #6
            developer,

            to paraphrase the link I referenced...

            For example to calculate a 6 period SMA of a 12 period RSI you would write sma(6, rsi(12)).

            So, taking the basic RSI from your Formulas\EFS2 Basic folder:

            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.                      
            **********************************************************/

            function preMain() {

                
            setPriceStudy(false);
                
            setStudyTitle("RSI");
                
            setCursorLabelName("RSI"0);
                
            setDefaultBarFgColor(Color.blue0);
                
            setPlotType(PLOTTYPE_LINE,0);
                
            setDefaultBarThickness(1,0);
                
            setStudyMin(0);
                
            setStudyMax(100);
                
            addBand(70,PS_SOLID,1,Color.black,"Upper");
                
            addBand(30,PS_SOLID,1,Color.black,"Lower");
            }

            function 
            main() {

                return 
            rsi(14); 

            apply the modification...




            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.                      
            **********************************************************/
            // modified to take a 6 period SMA of a 12 period RSI 11/29/2006

            function preMain() {

                
            setPriceStudy(false);
                
            setStudyTitle("SMA of RSI");
                
            setCursorLabelName("RSI"0);
                
            setDefaultBarFgColor(Color.blue0);
                
            setPlotType(PLOTTYPE_LINE,0);
                
            setDefaultBarThickness(1,0);
                
            setCursorLabelName("SMA of RSI"1);
                
            setDefaultBarFgColor(Color.red1);
                
            setPlotType(PLOTTYPE_LINE,1);
                
            setDefaultBarThickness(1,1);
                
            setStudyMin(0);
                
            setStudyMax(100);
                
            addBand(70,PS_SOLID,1,Color.black,"Upper");
                
            addBand(30,PS_SOLID,1,Color.black,"Lower");
            }

            function 
            main() {

                return new Array(
            rsi(12),sma(6rsi(12))); 

            Pretty straightforward, my recommendation is that you start going through the efs tutorials available through the Product Training dropdown. Hope this is helpful.

            Here is a screenshot of the modified efs

            Comment


            • #7
              I've written the efs below of a RSI with Signal line (moving average). I'm not sure the "source" is correct as it doesn't affect the returned value. Could someone run their eye over it for me - a quick check. Thanks.

              PHP Code:
              function preMain() {

                  
              setPriceStudy(false);
                  
              setStudyTitle("RSI w. Signal");
                  
              setCursorLabelName("RSI"0);
                  
              setDefaultBarFgColor(Color.navy0);
                  
              setPlotType(PLOTTYPE_LINE,0);
                  
              setDefaultBarThickness(1,0);
                  
              setCursorLabelName("Signal"1);
                  
              setDefaultBarFgColor(Color.red1);
                  
              setPlotType(PLOTTYPE_LINE,1);
                  
              setDefaultBarThickness(1,1);
                  
              //setStudyMin(0);
                  //setStudyMax(100);
                  
              setComputeOnClose();
                  
              addBand(70,PS_SOLID,1,Color.grey,"Upper");
                  
              addBand(30,PS_SOLID,1,Color.grey,"Lower");
                  
                  var 
              fp1 = new FunctionParameter("nRSI"FunctionParameter.NUMBER);
                  
              fp1.setName("RSI length");
                  
              fp1.setLowerLimit(1);        
                  
              fp1.setDefault(13);
                  
                  var 
              fp2 = new FunctionParameter("Source"FunctionParameter.STRING);
                  
              fp2.setName("RSISource");
                  
              fp2.addOption("Close");
                  
              fp2.addOption("High");
                  
              fp2.addOption("Low");
                  
              fp2.addOption("Open");
                  
              fp2.addOption("HL/2");
                  
              fp2.addOption("HLC/3");
                  
              fp2.addOption("OHLC/4");
                  
              fp2.setDefault("HLC/3");
                  
                  var 
              fp3 = new FunctionParameter("nMA"FunctionParameter.NUMBER);
                  
              fp3.setName("Signal length");
                  
              fp3.setLowerLimit(1);        
                  
              fp3.setDefault(8);
              }

              function 
              main(nRSISourcenMA) {

                  return new Array(
              rsi(nRSISource), sma((nMA), rsi(nRSISource))); 

              Comment


              • #8
                Hi James,

                Your trying to write an advanced efs2 study starting with a basic study. As a result, the structure of main and the efs2 commands will not work correctly. Try starting with a custom efs2 study.

                Check out the C:\Program Files\eSignal\Formulas\EFS 2 Custom folder for examples how to process / evaluate string representations of source. The differences will help explain what you are doing wrong quicker and much better than I can in a forum post.

                There are also some excellent KnowledgeBase and efs2 links below my signature that will help get you up to speed.

                Hope this helps.
                Originally posted by James 88
                I've written the efs below of a RSI with Signal line (moving average). I'm not sure the "source" is correct as it doesn't affect the returned value. Could someone run their eye over it for me - a quick check. Thanks.

                Comment


                • #9
                  Hi Steve

                  This seems to work. Any comments appreciated? Is the last line (new Array) ok?

                  Kind Regards, James

                  PHP Code:
                  var fpArray = new Array();

                  function 
                  preMain() {

                      
                  setPriceStudy(false);
                      
                  setStudyTitle("RSI with Signal");
                      
                  setCursorLabelName("RSI"0);
                      
                  setDefaultBarFgColor(Color.navy0);
                      
                  setPlotType(PLOTTYPE_LINE,0);
                      
                  setDefaultBarThickness(1,0);
                      
                  setCursorLabelName("Signal"1);
                      
                  setDefaultBarFgColor(Color.red1);
                      
                  setPlotType(PLOTTYPE_LINE,1);
                      
                  setDefaultBarThickness(1,1);
                      
                  //setStudyMin(0);
                      //setStudyMax(100);
                      
                  setComputeOnClose();
                      
                  askForInput();
                              
                      var 
                  x=0;
                      
                  fpArray[x] = new FunctionParameter("nLength"FunctionParameter.NUMBER);
                      
                  with(fpArray[x++]){
                          
                  setName("RSI")
                          
                  setLowerLimit(1);        
                          
                  setDefault(13);
                      }
                      
                  fpArray[x] = new FunctionParameter("nSignal"FunctionParameter.NUMBER);
                      
                  with(fpArray[x++]){
                          
                  setName("Signal")
                          
                  setLowerLimit(1);        
                          
                  setDefault(8);
                      }
                      
                  fpArray[x] = new FunctionParameter("Source"FunctionParameter.STRING);
                      
                  with(fpArray[x++]){
                          
                  setName("Source")
                          
                  addOption("open"); 
                          
                  addOption("high");
                          
                  addOption("low");
                          
                  addOption("close");
                          
                  addOption("hl2");
                          
                  addOption("hlc3");
                          
                  addOption("ohlc4"); 
                          
                  setDefault("close"); 
                      }
                      
                  /**fpArray[x] = new FunctionParameter("Symbol", FunctionParameter.STRING);
                      with(fpArray[x++]){
                          setName("Symbol");
                          setDefault();
                      }**/
                      /**fpArray[x] = new FunctionParameter("Interval", FunctionParameter.STRING);
                      with(fpArray[x++]){
                          setName("Interval");
                          setDefault();
                      }**/
                      
                  fpArray[x] = new FunctionParameter("Upper"FunctionParameter.NUMBER);
                      
                  with(fpArray[x++]){
                          
                  setName("Upper")
                          
                  setDefault(70); 
                      }
                      
                  fpArray[x] = new FunctionParameter("Lower"FunctionParameter.NUMBER);
                      
                  with(fpArray[x++]){
                          
                  setName("Lower")
                          
                  setDefault(30); 
                      }
                      
                  fpArray[x] = new FunctionParameter("Params"FunctionParameter.BOOLEAN);
                      
                  with(fpArray[x++]){
                          
                  setName("Show Parameters");
                          
                  setDefault(false);
                      }
                  }

                  var 
                  bInit false;
                  var 
                  xRSI null;

                  function 
                  main(nLengthSourcenSignalUpperLowerParams) {

                      if(
                  bInit == false){
                          
                  //if(Symbol == null) Symbol = getSymbol();
                          //if(Interval == null) Interval = getInterval();
                          //var vSymbol = Symbol+","+Interval;
                          
                  xRSI rsi(nLength); 
                          
                  addBand(Upper,PS_SOLID,1,Color.grey,"Upper");
                          
                  addBand(Lower,PS_SOLID,1,Color.grey,"Lower");
                          
                  setShowTitleParameters(eval(Params));
                          
                  bInit true;
                      }

                      return new Array(
                  getSeries(xRSI), sma(nSignalgetSeries(xRSI)));

                  Comment

                  Working...
                  X