Announcement

Collapse
No announcement yet.

Accessing historical indicator values

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

  • Accessing historical indicator values

    Can anyone let me know if/how it's possible to access indicator values for historical bars?

    For example, I'd like to use the BidAskAnalysis efs, and compare the values it returns for the current bar to the values from x bars ago.

    Thanks,

    SQ

  • #2
    Hello senyorqueso,

    Yes, this is possible. The first method I would recommend is efsExternal(). This will create a series based on the formula that is called. The historical values of a series can be accessed with .getValue(-x) where -x is the historical bar index to retrieve. See the APE_alpha.efs, in this thread for a code example on how to do this. You can find many other efsExternal() examples here in the forums using the search feature.

    Another alternative to explore would be the ref() function. See RefUsage.efs and RefUsage2.efs from our EFS Library for code examples.

    One thing to keep in mind when trying to access historical values from the BidAskAnalysis.efs study is that it will only build a history starting in real time as data is collected going forward. The formula will have to run for a certain about of time before the historical bar you try to reference can return a valid result. To validate that the return is not null, you can add an null check on the variable and simply exit the formula if it is null. You will see examples of null checks in the resource I've included here.
    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation

    Comment


    • #3
      Thanks Jason - just what I needed.

      I decided to do this with efs_external, but seem to have fallen at the first hurdle! My new efs which has the efsExternal call, doesn't find the efs file - I just get a "Formula File not found" error.

      I've done a search and am doing what you've recommended here - both my efs files are in Formulas/Downloads, and the efsExternal call looks like:

      efsExternal("/Downloads/LR_BidAsk.efs", params);

      I've also tried with \\ instead of /, but get the same result.

      Formulas is my formula root dir.

      Any idea why this is happening?

      Comment


      • #4
        Getting closer - seems to be to do with the underscore in mys efs name - If i copy the efs and rename it without the underscore the efsExternal finds the file.

        Comment

        Working...
        X