Announcement

Collapse
No announcement yet.

Get Previous Close Without Reload??

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

  • Get Previous Close Without Reload??

    I have written some studies that are based on a symbols change in value from the previous day's close. Currently, the value is based on the close at the time the study is loaded, and each day it has to be reloaded after the open to get the correct value.

    The code in main that sets the variable of the Nasdaq is:

    var vCOMPQ = close("$COMPQ") - getValueAbsolute("close", -1, "$COMPQ,D");

    What do i need to change or add in order for the value to be automatically updated each day.

    Thanks,

    Dan

  • #2
    Hello Dan,

    What you need to do is synchronize the index value used in your getValueAbsolute() call using getPreviousTradingDay() and getFirstBarIndexOfDay(). The formula, getPrevOHLC1.efs, will handle this for you. Download this formula to your \eSignal\Formulas\OHLC folder and then use it with callFunction() like in the example below.

    PHP Code:
    function main() {
        var 
    vC callFunction("/OHLC/getPrevOHLC1.efs""main""Close""$COMPQ");
        if (
    vC == null) return;
        
        return 
    vC;

    The modification to your code example looks something like this.

    PHP Code:
    function main() {
        var 
    vC callFunction("/OHLC/getPrevOHLC1.efs""main""Close""$COMPQ");
        if (
    vC == null) return;
        
        var 
    vCOMPQ close("$COMPQ") - vC;
        return 
    vCOMPQ;

    Try this out and let me know if it works for you.
    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
      Jason,

      Thanks, it seemed to work fine today on
      4 different formula. I sent copies to a few
      friends to test at tomorrow's open.

      Thanks again, you made this quite easy
      for me.

      Dan

      Comment

      Working...
      X