I tested a simple Zorro provided workshop script (workshop5) with the following added line in the run() function:
printf("\nBar %i of %i at %s",Bar,NumBars,strdate("%Y-%m-%d %H:%M",wdateBar(Bar)));
In Trade mode, it prints all the way to the last current bar, including the incomplete one, then it waits for that bar to complete:
The Zorro manual says in the Trade mode this:
"After the lookback period, Zorro will wait for the end of the current bar (unless StartDate is set to NOW), then execute the run function again."
This is indeed happening, the last current incomplete bar is run() again once it ends.
My problem is that I have a calculation in the run() function which creates a series and on the last bar the run() function is run twice, once when I start the script in Trade mode and when the bar is still incomplete and once more when the bar actually ends.
Is there a way to run the run() function only when the bar is complete? Running it twice screws up the series my script is creating by adding an additional value to it.