Announcement

Collapse
No announcement yet.

How do I create the SMA of the ratio of 2 series?

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How do I create the SMA of the ratio of 2 series?

    <sigh>

    I am trying to create a moving average of the ratio of two market indices. How to I do that?

    I want to do something like in main():

    if (bInit == false) {
    vSeries1 = sym("$ADVQ");
    vSeries2 = sym("$DECLQ");
    vSeries3 = vSeries1/vSeries2;
    vSeries4 = sma(20, vSeries3);
    bInit = true;
    }

    return vSeries4.getValue(0);

    BUT this doesn't seem to work.

  • #2
    DXRScott
    Once you process a series the result is no longer a series but a value. In your example vSeries3 is not a series hence it cannot be used as a source for the sma() function.
    You need to process the series externally either in a separate function within the same efs or in an external efs and call the result of the process using efsInternal() or efsExternal(). See the respective links for the required syntax.
    You can also find further information on these two functions (complete with detailed examples) in this thread.
    For a practical example on how to create a separate function to create a ratio between two series see the example Chris Kryza posted in this thread.
    In your case the simplest solution is to use the dsDivSeries() function available in the dsFunctions.efsLib function library. You can find the latest revision of the dsFunctions.efsLib and its documentation here
    Alex

    Comment


    • #3
      Originally posted by Alexis C. Montenegro
      In your case the simplest solution is to use the dsDivSeries() function available in the dsFunctions.efsLib function library. You can find the latest revision of the dsFunctions.efsLib and its documentation here
      Alex
      Thanks for such a complete response Alexis!!

      I was able to get it to work using efsInternal. One question if I may. I tried to use the dsDivSeries library you mention. I downloaded both the lib file and the chm file. I'm unable to look at the functions in the library, and when I open the help file, I can see the titles of the functions, but when I click on each one I get a Windows link not found message.

      I must be doing something basic wrong. I get the same situation with other help files too. Any suggestions?? Tnx in advance.

      Comment


      • #4
        SERS
        You are most welcome.
        With regards to the error you get when opening the Help file I know there has been someone else who had the same problem (see this thread) although I am not sure if it was ever resolved.
        Irrespective here is a snapshot of the Help for the dsDivSeries()
        Alex

        Comment


        • #5
          How to Open chm files in XP SP2

          Alexis, in case it helps others, I found out the source of the .chm open problem:

          Computers using Windows XP Service Pack 2 or Windows Server 2003 Service Pack 1 will place a block on compiled help files (*.chm) that are downloaded from the Internet. The block will interfere with the operation of the help file and an ‘Action canceled’ or ‘The page cannot be displayed’ error will be displayed in the topic pane. The problem is caused by security features introduced in the service packs designed to reduce vulnerabilities in HTML help.

          Workaround:

          After downloading the document, open it from the location where it was saved and a security warning will appear. In order to view the help documents properly, the checkmark must be cleared from the ‘Always ask before opening this file’ check box. The files will then open properly from the PC. Alternatively, right-click on the file you want to open, click Properties, and then click Unblock.

          Comment


          • #6
            SERS
            You may want to also post it as a new thread (using the same title of your post) so that others may be able to find it by searching for chm in the titles of the threads.
            Alex

            Comment

            Working...
            X