Announcement

Collapse
No announcement yet.

Confused about Day()

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

  • Confused about Day()

    Say I have a 5 minute interval.
    Is ---
    Day(-1) the previous 5 minute bar?
    Day(-1) the previous tick?
    Day(-1) the previous day?

    Thanks.

  • #2
    it should report the "day" of the previous bar.

    when you use getDay(), the value you pass to it determines which bar you want to reference. So, passing a -1 tells it to retrieve the day value of the previous bar.
    Brad Matheny
    eSignal Solution Provider since 2000

    Comment


    • #3
      So, if I have interval set to "Tick", Day(-1) will be the previous Tick?
      If I have interval set to "30 Min", Day(-1) will be the previous 30 Min bar?
      If I have interval set to "Day", Day(-1) will then be the actual previous trading day?

      Do I understand this correctly?

      BTW, this forum seams to be having problems with IE 8. Replies often don't go in.

      Comment


      • #4
        thats funny, the email said day(-21) but the text here says -1, so you are correct based on what is here

        So, if I have interval set to "Tick", Day(-1) will be the previous Tick?
        If I have interval set to "30 Min", Day(-1) will be the previous 30 Min bar?
        If I have interval set to "Day", Day(-1) will then be the actual previous trading day? now.

        Comment


        • #5
          dLoomis,

          I made a typo of -21 and then editied it to fix it to -1

          Thanks for the confirmation. Day as used in efs then is really Interval.

          Comment


          • #6
            I think you are still a little confused... Day(-1) will return the Day of the previous bar, so at 930, the open, Day(-1) is yesterday, at 931 on a 1 minute bar, day(-1), the day of the previous bar is today.

            Comment


            • #7
              Still confused.

              On 1 min intervals, if the bar for 9:37 is building and I want the value of the close of the bar at 9:36, how do I get it. Will Day(-1) point to the bar at 9:36?

              The core issue is Day(x) pointing to the actual previous day regardless of the interval or is it pointing to the interval that was completed prior to the one that is building?

              Comment


              • #8
                jgr
                day(-1) will return the value of the day [ie the date] of the prior bar based on the chart's interval. For the description and syntax of the day() function see this article in the EFS KnowledgeBase
                If you want to retrieve the Close at the prior bar then you need to use close(-1). For the description and syntax of the close() function see this article in the EFS KnowledgeBase
                Alex


                Originally posted by jgr
                Still confused.

                On 1 min intervals, if the bar for 9:37 is building and I want the value of the close of the bar at 9:36, how do I get it. Will Day(-1) point to the bar at 9:36?

                The core issue is Day(x) pointing to the actual previous day regardless of the interval or is it pointing to the interval that was completed prior to the one that is building?

                Comment


                • #9
                  OK, Then here is what I did to the Elder Bear Power to get it to display the same results as in TOS and like that in his book. Basically, I commented out the check of the current bar against the bar at Day(-1). This did not make sense to me. I don't know why that was in there.

                  Similar to his Bull Power. Note there are Bear Power and Bull Power efs available that are different from his.

                  /*********************************
                  Modified by JGR 6/18/09: Corrected the calculation so it agrees with that in TOS.

                  Provided By:
                  eSignal (Copyright c eSignal), a division of Interactive Data
                  Corporation. 2008. All rights reserved. This sample eSignal
                  Formula Script (EFS) is for educational purposes only and may be
                  modified and saved under a new file name. eSignal is not responsible
                  for the functionality once modified. eSignal reserves the right
                  to modify and overwrite this EFS file with each new release.


                  Description:
                  Elder Ray (Bear Power)

                  Version: 1.0 12/03/2008

                  Formula Parameters: Default:
                  Length 13
                  Price Close

                  Notes:
                  Developed by Dr Alexander Elder, the Elder-ray indicator measures buying
                  and selling pressure in the market. The Elder-ray is often used as part
                  of the Triple Screen trading system but may also be used on its own.
                  Dr Elder uses a 13-day exponential moving average (EMA) to indicate the
                  market consensus of value. Bear Power measures the ability of sellers to
                  drive prices below the consensus of value. Bear Power reflects the ability
                  of sellers to drive prices below the average consensus of value.
                  Bull Power is calculated by subtracting the 13-day EMA from the day's High.
                  Bear power subtracts the 13-day EMA from the day's Low.

                  **********************************/

                  var fpArray = new Array();
                  var bInit = false;

                  function preMain() {
                  setPriceStudy(false);
                  setStudyTitle("ER Bear Power Mod");
                  setCursorLabelName("ER Bear Power");
                  setPlotType(PLOTTYPE_HISTOGRAM);
                  addBand(0, PS_SOLID, 1, Color.black);
                  setDefaultBarThickness(1,0);

                  var x=0;
                  fpArray[x] = new FunctionParameter("Length", FunctionParameter.NUMBER);
                  with(fpArray[x++]){
                  setLowerLimit(1);
                  setDefault(13);
                  }

                  fpArray[x] = new FunctionParameter("Price", FunctionParameter.STRING);
                  with(fpArray[x++]){
                  addOption("open");
                  addOption("high");
                  addOption("low");
                  addOption("close");
                  addOption("hl2");
                  addOption("hlc3");
                  addOption("ohlc4");
                  setDefault("close");
                  }
                  }
                  var DayLow = null;
                  // var DayLow_1 = null;
                  var xPrice = null;
                  var xMA = null;

                  function main(Price, Length) {
                  var nState = getBarState();

                  if (nState == BARSTATE_ALLBARS) {
                  if (Price == null) Price = "close";
                  if (Length == null) Length = 13;
                  }

                  if ( bInit == false ) {
                  xPrice = eval(Price)();
                  xMA = ema(Length, xPrice);
                  bInit = true;
                  }

                  /** if(getBarState()==BARSTATE_NEWBAR) DayLow_1 = DayLow;

                  if (day(0) != day(-1)) {
                  DayLow = low(0);
                  }else{
                  DayLow = Math.max(low(0), DayLow_1)
                  } **/

                  DayLow = low(0);
                  return DayLow - xMA.getValue(0);
                  }

                  Comment

                  Working...
                  X