Announcement

Collapse
No announcement yet.

Different Values For Previous Daily Close

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

  • Different Values For Previous Daily Close

    Hi,

    I am having an issue with getting different values for the previous daily close. It seems to be centered around the input Use Settlement as Close on daily interval from the Edit Chart window.

    Upon the first tick of a new day:

    if(getBarStateInterval("D") == BARSTATE_NEWBAR){

    I calculate the previous daily close with:
    getSeries(close(sym(getSymbol() + ",D"))).getValue(-1);
    or
    close( -1, inv("D") );

    For NQ I got 10842.75 as the previous daily close (Daily close for Nov 9) . I reloaded my study and got the same value.
    I then restarted eSignal and without changing anything I got 10830.75 as the previous daily close. So my code is identical but I am receiving two different values depending on if eSignal is restarted or not.

    See attachments for edit chart window:

    I have always had Use Settlement as Close on daily interval and Include Settlement in intraday and tick intervals as checked.

    After I restarted eSignal, I changed Use Settlement as Close on daily interval to OFF by setting the Interval to D, checking the input OFF, then switching the Interval back to 5. Upon doing that I was getting the previous daily close as 10842.75, which was the first number I was getting before I restarted eSignal.

    Overnight & Reload & Use Settlement as Close on daily interval
    = ON
    • 10842.75
    eSignal Restart & Use Settlement as Close on daily interval = ON
    • 10830.75
    eSignal Restart & Use Settlement as Close on daily interval = OFF
    • 10842.75

    I believe if a study is left on overnight, then in the morning when it calculates the previous daily close, it does so with Use Settlement as Close on daily interval as OFF, even when the input is ON.

    Here is a log of my study showcasing the issue. As you can see, the daily low and high are the same, however running the script overnight and reloading the script without restarting eSignal produces 10842.75 while restarting eSignal in the morning produces 10830.75.

    Overnight & Reload
    Daily Close V2: 10842.75
    Daily Close V1: 10842.75
    Daily Low: 10822.25
    Daily High: 11164.25

    eSignal Restart
    Daily Close V2: 10830.75
    Daily Close V1: 10830.75
    Daily Low: 10822.25
    Daily High: 11164.25

    I am using a 5 min time interval and a custom session from 7:45 to 18:00
    Last edited by ewdeg98; 11-11-2022, 01:30 PM.

  • #2
    Hi ewdeg98,

    I have a 5-minute ES chart with both of these checked: "Use Settlement as Close on daily interval and Include Settlement in intraday and tick intervals". I added the following code to a program that I have on that chart, and I was able to print off the last 15 settlement prices of ES:

    var xSettlement = null; // Global var

    if(getBarState() == BARSTATE_ALLBARS) xSettlement = getSeries(close(inv("D"))); // I created a series object out of xSettlement

    if(isLastBarOnChart()) for(var i = 0; i >= -14; i--) debugPrintln(xSettlement.getValue(i));

    The above works with just close(inv("D")) and not using getSeries, but I think it's recommended to use getSeries when you're using different intervals.

    I hope this helps!
    LetUsLearn

    Comment


    • #3
      Hi LetUsLearn,

      I'm able to get the previous daily close as you mentioned no problem. Both methods I use

      getSeries(close(sym(getSymbol() + ",D"))).getValue(-1);

      or

      close( -1, inv("D") );

      return the same as your as of now.

      But I will try your method of getSeries(close(inv("D")));

      However, I think the issue is outside of the calculation method.

      When I run the script overnight my previous daily close calculation returns value A. When I reload the study I also get value A. When I close and reopen eSignal I get value B.
      Why am I getting two different values when I change nothing in my code or eSignal settings. The only thing I do is close and reopen eSignal. That leads me to believe there is a bug somewhere inside eSignal regarding the previous daily close value.

      Comment

      Working...
      X