how is setComputeOnClose() different from using
if (getBarState() != BARSTATE_NEWBAR) return; ?
main() doesn't seem to execute until the 1st tick of the next bar anyway, unless i'm doing something wrong? it makes sense because how would efs know that the last tick has occured for a bar until it gets to the new bar?
I'm trying to write info to a file at the end-of-day. How can I accomplish that if the new bar doesn't occur until morning?
There isn't much difference between the two - except that waiting for the NEWBAR means your efs will be called on each tick only to return after doing the check. WIth ComputeOnCLose() the EFS isn't called until the bar closes.
If it isn't critical for the data to be written exactly at the close, you could always just load the formula sometime after the close, and it will capture the data at the time of close, without having to worry about NEWBARS or ComputeOnClose().
If for some reason you need this printed in near realtim you could just check the time using rawtime and once the closing time is there, wait until no more ticks come in for a few minutes and then write the last value to your file.
Comment