Announcement

Collapse
No announcement yet.

Calculating MA on custom series

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

  • Calculating MA on custom series

    I created my own indicator and would like to also plot its moving average. I know this can done with the built-in indicators but what about a custom-made indicator? Is there a way to pass a custom series to an MA function?

    If I have to create my own MA function what data structure options for the price series are available in Javascript? I know about arrays and I believe there is a simple collection class. Is there anything like a stack so I can pop the most recent price onto the stack and everything shifts down?

  • #2
    buhrmaster
    You can use the efsInternal() or efsExternal() functions to call a separate function or efs which will create the series that you can then use as the source for the builtin moving average functions (ie sma(), ema(), etc).
    See this thread for examples on how to use these functions and also this for examples on how to create custom variables to use as source for builtin studies
    Alex

    Comment


    • #3
      Alex,

      The examples you gave appear to use built-in functions. In my case I am comparing the daily logged returns of a stock to the S&P to create a custom relative strength index. This is not the same as Wilder RSI. I am not using any built-in indicators. Say I store these values in some kind of structure, can I pass that structure to an MA function and get an MA value?

      Comment


      • #4
        Alex,

        Just looked more closely as EFSInternal. It appears this will work I set up my RSI function separately in the same file. Is that correct?

        Comment


        • #5
          buhrmaster
          That is correct. In the threads I mentioned you should find some examples of custom variables being passed to buitlin studies.
          Also run a search for efsInternal* (and separately for efsExternal*) and you will find other examples I have provided including [I think] one that calculates the average of a ratio of two symbols.
          Alex

          Comment

          Working...
          X