Announcement

Collapse
No announcement yet.

postMain() ?????

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

  • postMain() ?????

    Is there such a thing as a postMain() function, which will execute once only, after the last bar has been pocessed?
    Thanks
    George
    Last edited by wombat953; 08-08-2003, 07:34 AM.

  • #2
    Hi,

    There is a postMain() but my understanding is that it is run when a formula is removed or reloaded...

    The concept of a "last bar" is interesting when thinking about RT mode. In theory, there will never really be a last bar, but I suspect you mean the newest bar on the chart. If this is the case, you can use getCurrentBarIndex() and look to a index of 0...which means you are processing the newest bar on the chart.


    var nIndex = getCurrentBarIndex();
    if (nIndex == 0){ // At the latest bar
    do stuff
    }

    Hope this helps,

    Garth
    Garth

    Comment


    • #3
      Thanks Garth - I was wondering what the simplest way to close a file was. If main() is executed once for each bar, then I ceratinly wouldn't want to place it there if I am reading a file, so I turned to thinking about a preMain().
      George

      Comment


      • #4
        Yep, good thought. postMain() is the way to go. I have seen some studies that open and close the file on each tick, but that hardly seem the correct thing to do.

        G
        Garth

        Comment

        Working...
        X