Announcement

Collapse
No announcement yet.

getFirstBarIndexOfDay()

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

  • getFirstBarIndexOfDay()

    I am trying to get the first bar index for any given date. In the following example, getFirstBarIndexOfDay(newDateObject) results in "null". Please help. Thanks.

    function preMain() {
    setPriceStudy(true);
    }

    var BarCntr = 0;
    function main() {


    if (getBarState() == BARSTATE_NEWBAR) {
    BarCntr +=1;
    var newDateObject = new Date(2003, 02, 1);
    debugPrint("Bar=" + getCurrentBarIndex() + " v=" + getFirstBarIndexOfDay(newDateObject) + "\n");
    if (getCurrentBarIndex() == getFirstBarIndexOfDay(newDateObject)) {

    }
    }
    }

  • #2
    I got it.
    It's because date was referencing March.
    (Date() starts month from 0), so Jan is 0, Feb 1 etc)

    Thank you dloomis

    Comment

    Working...
    X