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
}
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
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.
Comment