Announcement

Collapse
No announcement yet.

RSI of a Moving Average

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

  • RSI of a Moving Average

    I need help in designing an indicator which plots the RSI of a Moving Average. The default values for the moving average should be (10 Period, EMA), and the length of the RSI should be 5. Any help would be greatly appreciated.

    Thanks

  • #2
    monti1a
    You may want to try to do that using the Formula Wizard's study on study feature.
    For a brief explanation on how to create studies on studies using the Formula Wizard see this thread
    Alex

    Comment


    • #3
      Alexis-

      I actually tried the formula wizard but it doesn't return any plot.

      The code that was created is as follows:

      Any help would be greatly appreciated.


      //{{EFSWizard_Description
      //
      // This formula was generated by the Alert Wizard
      //
      //}}EFSWizard_Description 7532


      //{{EFSWizard_Declarations

      var vEMA10 = new MAStudy(10, 0, "Close", MAStudy.EXPONENTIAL);
      var vRSI14_of_vEMA10 = new RSIStudy(14, vEMA10);
      var vLastAlert = -1;

      //}}EFSWizard_Declarations 15249


      function preMain() {
      /**
      * This function is called only once, before any of the bars are loaded.
      * Place any study or EFS configuration commands here.
      */
      //{{EFSWizard_PreMain
      setPriceStudy(false);
      setStudyTitle("Moving Avg Rsi");
      setCursorLabelName("MArsi", 0);
      setDefaultBarStyle(PS_SOLID, 0);
      setDefaultBarFgColor(Color.red, 0);
      setDefaultBarThickness(2, 0);
      setPlotType(PLOTTYPE_LINE, 0);
      //}}EFSWizard_PreMain 28821

      }

      function main() {
      /**
      * The main() function is called once per bar on all previous bars, once per
      * each incoming completed bar, and if you don't have 'setComputeOnClose(true)'
      * in your preMain(), it is also called on every tick.
      */

      //{{EFSWizard_Expressions
      //{{EFSWizard_Expression_1
      //}}EFSWizard_Expression_1 0

      //}}EFSWizard_Expressions 9063


      //{{EFSWizard_Return
      return (vRSI14_of_vEMA10);
      //}}EFSWizard_Return 1661

      }

      function postMain() {
      /**
      * The postMain() function is called only once, when the EFS is no longer used for
      * the current symbol (ie, symbol change, chart closing, or application shutdown).
      */
      }

      //{{EFSWizard_Actions
      //{{EFSWizard_Action_1
      function onAction1() {
      vLastAlert = 1;
      }
      //}}EFSWizard_Action_1 5589

      //}}EFSWizard_Actions 15622

      Comment


      • #4
        monti1a
        The errors were in the definition of the RSI study and in the return statement. The enclosed revision fixes both.
        Alex

        PHP Code:
        //{{EFSWizard_Description
        //
        // This formula was generated by the Alert Wizard
        //
        //}}EFSWizard_Description 7532


        //{{EFSWizard_Declarations

        var vEMA10 = new MAStudy(100"Close"MAStudy.EXPONENTIAL);
        var 
        vRSI14_of_vEMA10 = new RSIStudy(14vEMA10MAStudy.MA);
        var 
        vLastAlert = -1;

        //}}EFSWizard_Declarations 17493


        function preMain() {
        /**
        * This function is called only once, before any of the bars are loaded.
        * Place any study or EFS configuration commands here.
        */
        //{{EFSWizard_PreMain
            
        setPriceStudy(false);
            
        setStudyTitle("Moving Avg Rsi");
            
        setCursorLabelName("MArsi"0);
            
        setDefaultBarStyle(PS_SOLID0);
            
        setDefaultBarFgColor(Color.red0);
            
        setDefaultBarThickness(20);
            
        setPlotType(PLOTTYPE_LINE0);
        //}}EFSWizard_PreMain 29123

        }

        function 
        main() {
        /**
        * The main() function is called once per bar on all previous bars, once per
        * each incoming completed bar, and if you don't have 'setComputeOnClose(true)'
        * in your preMain(), it is also called on every tick.
        */

        //{{EFSWizard_Expressions
            //{{EFSWizard_Expression_1
            //}}EFSWizard_Expression_1 0
            
        //}}EFSWizard_Expressions 9063


        //{{EFSWizard_Return
            
        return vRSI14_of_vEMA10.getValue(RSIStudy.RSI);
        //}}EFSWizard_Return 6068

        }

        function 
        postMain() {
        /**
        * The postMain() function is called only once, when the EFS is no longer used for
        * the current symbol (ie, symbol change, chart closing, or application shutdown).
        */
        }

        //{{EFSWizard_Actions
            //{{EFSWizard_Action_1
            
        function onAction1() {
                
        vLastAlert 1;
            }
            
        //}}EFSWizard_Action_1 5589
            
        //}}EFSWizard_Actions 15622 

        Comment


        • #5
          I greatly appreciate the help Alexis. Thanks a bunch. I have one final problem. I'm trying to add two bands (25 & 75), and I have tried everything however, they will not plot at all. The code that I am using is:

          addBand(25, PS_SOLID, 1, Color.black);
          addBand(75, PS_SOLID, 1, Color.black);

          I simply added this code into the preMain section just as the EFS guide suggested, however, they will not plot.

          Help from you or anyone else would be greatly appreciated

          Comment


          • #6
            Try

            addBand(25, PS_SOLID, 1, Color.black, 99);
            addBand(75, PS_SOLID, 1, Color.black, 98);

            The tag identifier is required for multiple bands.

            Comment


            • #7
              monti1a
              The enclosed revision will plot the bands
              Alex

              Edit after post: Note that if you insert the addBand() command in main() you will need a tag identifier as suggested by David Loomis

              PHP Code:
              //{{EFSWizard_Description
              //
              // This formula was generated by the Alert Wizard
              //
              //}}EFSWizard_Description 7532


              //{{EFSWizard_Declarations

              var vEMA10 = new MAStudy(100"Close"MAStudy.EXPONENTIAL);
              var 
              vRSI14_of_vEMA10 = new RSIStudy(14vEMA10MAStudy.MA);
              var 
              vLastAlert = -1;

              //}}EFSWizard_Declarations 17493


              function preMain() {
              /**
              * This function is called only once, before any of the bars are loaded.
              * Place any study or EFS configuration commands here.
              */
              //{{EFSWizard_PreMain
                  
              setPriceStudy(false);
                  
              setStudyTitle("Moving Avg Rsi");
                  
              setCursorLabelName("MArsi"0);
                  
              setDefaultBarStyle(PS_SOLID0);
                  
              setDefaultBarFgColor(Color.red0);
                  
              setDefaultBarThickness(20);
                  
              setPlotType(PLOTTYPE_LINE0);
                  
              addBand(25,PS_SOLID,1,Color.black);
                  
              addBand(75,PS_SOLID,1,Color.black);
              //}}EFSWizard_PreMain 29123

              }

              function 
              main() {
              /**
              * The main() function is called once per bar on all previous bars, once per
              * each incoming completed bar, and if you don't have 'setComputeOnClose(true)'
              * in your preMain(), it is also called on every tick.
              */

              //{{EFSWizard_Expressions
                  //{{EFSWizard_Expression_1
                  //}}EFSWizard_Expression_1 0
                  
              //}}EFSWizard_Expressions 9063


              //{{EFSWizard_Return
                  
              return vRSI14_of_vEMA10.getValue(RSIStudy.RSI);
              //}}EFSWizard_Return 6068

              }

              function 
              postMain() {
              /**
              * The postMain() function is called only once, when the EFS is no longer used for
              * the current symbol (ie, symbol change, chart closing, or application shutdown).
              */
              }

              //{{EFSWizard_Actions
                  //{{EFSWizard_Action_1
                  
              function onAction1() {
                      
              vLastAlert 1;
                  }
                  
              //}}EFSWizard_Action_1 5589
                  
              //}}EFSWizard_Actions 15622 

              Comment


              • #8
                Thanks to all - Alexis and David for your input. You both have been very helpful.

                To other esignal users, I have found the RSI of Moving Average Indicator to be a very powerful tool for identifying when prices have become overextended and as a result, a very strong snapback usually ensues.

                Comment

                Working...
                X