Announcement

Collapse
No announcement yet.

EFS for a SPREAD which involves both symbols

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

  • EFS for a SPREAD which involves both symbols

    Hi all,

    I'm trying to build a custom EFS for a spread (such as HD - LOW). How can I get the data of each stock which make up a spread and use it in a calculation?

    Any advice would be GREATLY appreciated.

    Thank you,
    Alex

    (I tried searching the forums for something similar with no success)

  • #2
    Re: EFS for a SPREAD which involves both symbols

    arbpairs
    You can base the calculation on an external symbol [ie a symbol that is different from the one being charted] by using the sym() function (for the description and syntax of this function see the link to article in the EFS KnowledgeBase)
    In your case you would simply need to pass the spread as a symbol. The following example will compute a simple 20 period moving average of your spread
    sma(20, sym("HD - LOW"))
    FYI all the studies included in the EFS2 Custom folder of Formulas are already enabled for use with external intervals and/or symbols so you can use those as examples on how to create your own
    Also run a search for the keyword spread* efs and you will find many more examples
    Alex


    Originally posted by arbpairs
    Hi all,

    I'm trying to build a custom EFS for a spread (such as HD - LOW). How can I get the data of each stock which make up a spread and use it in a calculation?

    Any advice would be GREATLY appreciated.

    Thank you,
    Alex

    (I tried searching the forums for something similar with no success)

    Comment


    • #3
      Re: Re: EFS for a SPREAD which involves both symbols

      Hi Alexis, thanks for your quick reply.

      Sorry, I didn't make myslef clear:

      If my current chart is set to a spread (HD - LOW), how can my EFS dynamically access each symbol involved?

      So without any hard-code, I want get sma(20, sym(symbol1)) and sma(20, sym(symbol2)) for any spread chart which I load. Is there a built-in function or a way to get the symbols of the given spread chart, and a ratio, if used?

      I went over EFS documentation, did some more searching but all of the examples I found are working with the final result of a spread.

      Comment


      • #4
        Re: Re: Re: EFS for a SPREAD which involves both symbols

        arbpairs
        There isn't a function that will directly return the individual symbols that constitute a spread.
        You will need to create your own routine to manipulate the string returned by the getSymbol() function which returns the symbol being charted. Depending on the type of symbols used in the spread and the type of spread this routine could become quite complex. In the screenshot enclosed below you can see a basic example of a routine based on the assumption of a simple spread that uses stock symbols only [ie no spaces in the symbols].
        For information on the String Object which you would use to manipulate the string see this article in the EFS KnowledgeBase. The String Object is a JavaSscript Object and you can find further information [complete with detailed examples] in the Core JavaScript Guide which is also available in the EFS KnowledgeBase
        Alex




        Originally posted by arbpairs
        Hi Alexis, thanks for your quick reply.

        Sorry, I didn't make myslef clear:

        If my current chart is set to a spread (HD - LOW), how can my EFS dynamically access each symbol involved?

        So without any hard-code, I want get sma(20, sym(symbol1)) and sma(20, sym(symbol2)) for any spread chart which I load. Is there a built-in function or a way to get the symbols of the given spread chart, and a ratio, if used?

        I went over EFS documentation, did some more searching but all of the examples I found are working with the final result of a spread.

        Comment


        • #5
          Re: Re: Re: Re: EFS for a SPREAD which involves both symbols

          This is what I was looking for, thank you!!

          Comment


          • #6
            Re: Re: Re: Re: Re: EFS for a SPREAD which involves both symbols

            arbpairs
            You are welcome
            Alex


            Originally posted by arbpairs
            This is what I was looking for, thank you!!

            Comment

            Working...
            X