Announcement

Collapse
No announcement yet.

How to not load all at once

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

  • How to not load all at once

    I want to print out to the Formula output window every hour when the hourly bar opens. This I can do.

    var newDateObject = new Date();

    if (nBarState == BARSTATE_NEWBAR) {
    debugPrintln(newDateObject.getHours()
    }

    However, when it first load, its goes through all the bars and prints out 20 times (roughly, possibly more or less). I don't want it to do all that. I want it to just print out the current hour when it first loads, and then each time a new bar runs, print out the time again.

    I am running this on an hourly chart.


    Thanks,

  • #2
    Re: How to not load all at once

    matt3m
    You could do that by changing your condition to
    if (nBarState == BARSTATE_NEWBAR && getCurrentBarIndex() == 0) {
    This way it will only execute on the current bar
    Alex


    Originally posted by matt3m
    I want to print out to the Formula output window every hour when the hourly bar opens. This I can do.

    var newDateObject = new Date();

    if (nBarState == BARSTATE_NEWBAR) {
    debugPrintln(newDateObject.getHours()
    }

    However, when it first load, its goes through all the bars and prints out 20 times (roughly, possibly more or less). I don't want it to do all that. I want it to just print out the current hour when it first loads, and then each time a new bar runs, print out the time again.

    I am running this on an hourly chart.


    Thanks,

    Comment


    • #3
      Re: Re: How to not load all at once

      This is slightly better, but not exactly what I want. Now this only will printout for future bars and not at all when it load. However I also want the current bar to print as soon as it is loaded.

      I appreciate the reply.

      Originally posted by Alexis C. Montenegro
      matt3m
      You could do that by changing your condition to
      if (nBarState == BARSTATE_NEWBAR && getCurrentBarIndex() == 0) {
      This way it will only execute on the current bar
      Alex

      Comment


      • #4
        Re: Re: Re: How to not load all at once

        I'm sorry. This works exactly. Thanks very much Alex.

        Originally posted by matt3m
        This is slightly better, but not exactly what I want. Now this only will printout for future bars and not at all when it load. However I also want the current bar to print as soon as it is loaded.

        I appreciate the reply.

        Comment


        • #5
          Re: Re: Re: Re: How to not load all at once

          matt3m
          You are welcome
          Alex


          Originally posted by matt3m
          I'm sorry. This works exactly. Thanks very much Alex.

          Comment

          Working...
          X