Announcement

Collapse
No announcement yet.

Rsi

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

  • Rsi

    Hi there,

    I want to calculate the RSI but I can't find how eSignal calculates it.

    I add a chart, a basic RSI study and then edit this study to

    Rsi(10,Close) 5 minutes

    I've looked at the different EFS for RSI but even when using those formulas (I recoded them using VB and I get the close prices from eSignal) the results are different than the ones in the eSignal Chart.

    From the efs I've read, It's quite straight forward : for 10 periods, get the average up change and down change and then apply this to the RSI formula but the results are different.

    To get the RSI from 15:05 (10 periods) , I have to calculate using the close prices from 14:20 to 15:05 or I have to recalculate from the opening at 9:30 ?

    RSI is showing from 8 AM ... does it uses the close prices from the past 10 DAYS or the close prices of yesterday (5 min) from 15:10 to 16:00 ?

    Another weird thing (for me !) is that If I right-click the chart, and go to tools/data export, the RSI showing in the last column is different from the ones I see on the chart except for those of the last hour (15:00 to 16:00) ??

    I'm sure the answer isn't too far !

    Does anyone knows what I'm missing ?

    I'm sorry for this eSignal newbie question ...

    Thanks for your help !

  • #2
    Re: Rsi

    Olyster
    You can find the logic used by the Basic Studies RSI in the RSIEnhanced.efs which is installed in the Library subfolder of Formulas
    Alex


    Originally posted by Olyster
    Hi there,

    I want to calculate the RSI but I can't find how eSignal calculates it.

    I add a chart, a basic RSI study and then edit this study to

    Rsi(10,Close) 5 minutes

    I've looked at the different EFS for RSI but even when using those formulas (I recoded them using VB and I get the close prices from eSignal) the results are different than the ones in the eSignal Chart.

    From the efs I've read, It's quite straight forward : for 10 periods, get the average up change and down change and then apply this to the RSI formula but the results are different.

    To get the RSI from 15:05 (10 periods) , I have to calculate using the close prices from 14:20 to 15:05 or I have to recalculate from the opening at 9:30 ?

    RSI is showing from 8 AM ... does it uses the close prices from the past 10 DAYS or the close prices of yesterday (5 min) from 15:10 to 16:00 ?

    Another weird thing (for me !) is that If I right-click the chart, and go to tools/data export, the RSI showing in the last column is different from the ones I see on the chart except for those of the last hour (15:00 to 16:00) ??

    I'm sure the answer isn't too far !

    Does anyone knows what I'm missing ?

    I'm sorry for this eSignal newbie question ...

    Thanks for your help !

    Comment


    • #3
      Thanks for your reply Alex. It's very appreciated.

      As you might know, I'm new to efses ...

      From what I understand, the function calcRSI() gets called several times.

      } else if(nCount == n) {
      nCount++;
      dAvgUp = dSumUp / n;
      dAvgDn = dSumDn / n;

      In the code I can see that when nCount reaches the periods parameter (n), the function should return a result.

      Since the nCount is incremented, the next call should go through :

      else {
      if(nBarState == BARSTATE_NEWBAR) {
      dLastAvgUp = dAvgUp;
      dLastAvgDn = dAvgDn;
      }
      dAvgUp = (dLastAvgUp*(n-1) + dUp)/ n;
      dAvgDn = (dLastAvgDn*(n-1) + dDn)/ n;

      Why is there another call after the function returns a result (nCount == n) and what getBarState() yields ?

      Since I'm gonna perform the calculation by myself, do I need to incorporate this last part (the else statement) ?

      Thanks again ...

      Comment


      • #4
        Olyster
        At BARSTATE_NEWBAR (ie on the first tick of a new bar) that call takes the last calculated values of dAvgUp and dAvgDn and assigns them to the variables dLastAvgUp and dLastAvgDn which represent the values of dAvgUp and dAvgDn at the prior bar and are required to calculate the average using Wilder's method. This occurs before new values for dAvgUp and dAvgDn are calculated for the current bar
        If - as you indicate - you are new to programming in efs you may want to review the JavaScript for EFS video series and the Core JavaScript Reference Guide. Those will provide you with a thorough introduction to programming in JavaScript which is at the foundation of EFS. Then go through the EFS KnowledgeBase and study the Help Guides and Tutorials which will provide you with the specifics of EFS.
        Also try running a search through this forum as you fill find that many examples and explanations are already available.
        Alex


        Originally posted by Olyster
        Thanks for your reply Alex. It's very appreciated.

        As you might know, I'm new to efses ...

        From what I understand, the function calcRSI() gets called several times.

        } else if(nCount == n) {
        nCount++;
        dAvgUp = dSumUp / n;
        dAvgDn = dSumDn / n;

        In the code I can see that when nCount reaches the periods parameter (n), the function should return a result.

        Since the nCount is incremented, the next call should go through :

        else {
        if(nBarState == BARSTATE_NEWBAR) {
        dLastAvgUp = dAvgUp;
        dLastAvgDn = dAvgDn;
        }
        dAvgUp = (dLastAvgUp*(n-1) + dUp)/ n;
        dAvgDn = (dLastAvgDn*(n-1) + dDn)/ n;

        Why is there another call after the function returns a result (nCount == n) and what getBarState() yields ?

        Since I'm gonna perform the calculation by myself, do I need to incorporate this last part (the else statement) ?

        Thanks again ...

        Comment


        • #5
          Thanks again for your reply ...

          I'm already familiar with C and javascript but not with efs. I think I'm close to get what I want with your help ...

          Suppose I want to calculate the RSI at 5 minutes interval.

          dAvgUp and dAvgDn aren't resetted to 0.0 between each 5 minutes intervals ?

          Do I need other data than the last 10 close prices (last 10 5 minutes close prices) ? Do I need every tick ?

          Since the if is :

          if(nCount < n) {
          dSumUp += dUp;
          dSumDn += dDn;
          nCount++;
          return;
          } else if(nCount == n) {
          nCount++;
          dAvgUp = dSumUp / n;
          dAvgDn = dSumDn / n;
          } else {
          if(nBarState == BARSTATE_NEWBAR) {
          dLastAvgUp = dAvgUp;
          dLastAvgDn = dAvgDn;
          }
          dAvgUp = (dLastAvgUp*(n-1) + dUp)/ n;
          dAvgDn = (dLastAvgDn*(n-1) + dDn)/ n;
          }

          at the first call, nCount should be < n and the code should go in this part. Are you saying that n isnt initialized at the first call ?

          Thanks ... in a few posts, I'll be on my way ...

          Comment


          • #6
            Olyster
            No dAvgUp and dAvgDn are global variables.
            n is a user defined parameter that is passed to the calcRSI function through the efsInternal() call
            Alex


            Originally posted by Olyster
            Thanks again for your reply ...

            I'm already familiar with C and javascript but not with efs. I think I'm close to get what I want with your help ...

            Suppose I want to calculate the RSI at 5 minutes interval.

            dAvgUp and dAvgDn aren't resetted to 0.0 between each 5 minutes intervals ?

            Do I need other data than the last 10 close prices (last 10 5 minutes close prices) ? Do I need every tick ?

            Since the if is :

            if(nCount < n) {
            dSumUp += dUp;
            dSumDn += dDn;
            nCount++;
            return;
            } else if(nCount == n) {
            nCount++;
            dAvgUp = dSumUp / n;
            dAvgDn = dSumDn / n;
            } else {
            if(nBarState == BARSTATE_NEWBAR) {
            dLastAvgUp = dAvgUp;
            dLastAvgDn = dAvgDn;
            }
            dAvgUp = (dLastAvgUp*(n-1) + dUp)/ n;
            dAvgDn = (dLastAvgDn*(n-1) + dDn)/ n;
            }

            at the first call, nCount should be < n and the code should go in this part. Are you saying that n isnt initialized at the first call ?

            Thanks ... in a few posts, I'll be on my way ...

            Comment


            • #7
              Since :

              var dSumUp = 0.0;
              var dSumDn = 0.0;
              var dAvgUp = 0.0;
              var dAvgDn = 0.0;
              var dLastAvgUp = 0.0;
              var dLastAvgDn = 0.0;
              var nCount = 0;

              These are all globals ?

              Do I need every ticks even if I want 5 minutes RSI(10,Close) ?

              when is efsInternal() called ? At every tick ?

              BARSTATE_NEWBAR = First Tick of a new bar
              BARSTATE_ALLBARS = ?

              Thanks for your time Alex ... as I told you I'm getting closer at each posts ...

              Comment


              • #8
                Olyster

                These are all globals ?
                Yes

                Do I need every ticks even if I want 5 minutes RSI(10,Close) ?
                That depends on how you want to calculate the average ie on every tick or on completed bars only.

                when is efsInternal() called ? At every tick ?
                It is initialized once and then its value is retrieved on each tick using the getValue() method

                BARSTATE_NEWBAR = First Tick of a new bar
                BARSTATE_ALLBARS = ?
                You can find all the information regarding these and other functions in the EFS KnowledgeBase. Also available in the KB are the tutorials that explain in detail the structure of an efs and how it works and that I would suggest that you review
                Alex


                Originally posted by Olyster
                Since :

                var dSumUp = 0.0;
                var dSumDn = 0.0;
                var dAvgUp = 0.0;
                var dAvgDn = 0.0;
                var dLastAvgUp = 0.0;
                var dLastAvgDn = 0.0;
                var nCount = 0;

                These are all globals ?

                Do I need every ticks even if I want 5 minutes RSI(10,Close) ?

                when is efsInternal() called ? At every tick ?

                BARSTATE_NEWBAR = First Tick of a new bar
                BARSTATE_ALLBARS = ?

                Thanks for your time Alex ... as I told you I'm getting closer at each posts ...

                Comment


                • #9
                  Thanks a lot for your reply.

                  I don't know why but I went to the kb yesterday night and querying getBarState didn't return any results ... but now it does ??

                  I went to watch the videos you pointed to me and it was very helpful ... I can now debug in real time RSIEnhanced.efs.

                  Again thanks for your time Alex ...

                  I have a last question ...

                  If I right-click the 5 minutes chart where I have RSI(10,Close) and go to tools/data export, I can see that the calculation starts on the june 24 th at 9:30.

                  If I right-click the 1 minutes chart with the same RSI(10,Close) and go to tools/data export, I can see that the calculation begins on June 26th at 13:11.

                  Why is that ?

                  Is there a minimum number of bars to begin the calculations ?

                  Thanks again ... I'm almost there !

                  Comment


                  • #10
                    Olyster
                    The script requires a certain number bars [used to prime the average] before it starts returning values to the chart. This is determined by the conditional statements in the calcRSI function that check for the value of nCount
                    Where the price data series actually begins [consequently where the values returned by the script will also begin] will depend on the settings in the Time Template assigned to the chart
                    Alex


                    Originally posted by Olyster
                    Thanks a lot for your reply.

                    I don't know why but I went to the kb yesterday night and querying getBarState didn't return any results ... but now it does ??

                    I went to watch the videos you pointed to me and it was very helpful ... I can now debug in real time RSIEnhanced.efs.

                    Again thanks for your time Alex ...

                    I have a last question ...

                    If I right-click the 5 minutes chart where I have RSI(10,Close) and go to tools/data export, I can see that the calculation starts on the june 24 th at 9:30.

                    If I right-click the 1 minutes chart with the same RSI(10,Close) and go to tools/data export, I can see that the calculation begins on June 26th at 13:11.

                    Why is that ?

                    Is there a minimum number of bars to begin the calculations ?

                    Thanks again ... I'm almost there !

                    Comment


                    • #11
                      Thanks Alex.

                      With your help, I have no problem calculating RSI.

                      Now I'd like to get historical data from code (VB)

                      I downloaded a few program example but I get "Not Entitled".

                      What product do I have to signup for ? I went to the account maintenance but I don't know which product I need to get historical data ...to finally calculate RSI automatically with code ...

                      Thanks again for your help ...

                      Comment


                      • #12
                        Olyster
                        You need to post that question in the Desktop API Development forum as that would be the appropriate place for that topic
                        Alex


                        Originally posted by Olyster
                        Thanks Alex.

                        With your help, I have no problem calculating RSI.

                        Now I'd like to get historical data from code (VB)

                        I downloaded a few program example but I get "Not Entitled".

                        What product do I have to signup for ? I went to the account maintenance but I don't know which product I need to get historical data ...to finally calculate RSI automatically with code ...

                        Thanks again for your help ...

                        Comment


                        • #13
                          Ok.

                          I thought I'd use a shortcut by asking you ...

                          Thanks again

                          Comment


                          • #14
                            Olyster
                            You are welcome
                            Alex


                            Originally posted by Olyster
                            Ok.

                            I thought I'd use a shortcut by asking you ...

                            Thanks again

                            Comment


                            • #15
                              RSI calculation (&quot;Priming&quot

                              Alexis,

                              Thanks for your help ... my project has evolved a lot since we talked ...

                              I'm still facing a problem calculating RSI though

                              -I open esignal
                              -open a chart with any symbol
                              -add formula/library/RSIenhenced 10 period
                              -click on 1 minute chart
                              right-click/data-export

                              I can see that the close prices used to prime the RSI calculation start at 9:30 the day before and include only close within the market hours

                              -change to 5 minutes chart
                              -right-click/data export

                              now the close prices used to prime the RSI calculation are the last 300 including those before 9:30 and after 16:00

                              Can you tell me how I could follow esignal to get the same results ?

                              Thanks a lot

                              Comment

                              Working...
                              X