Gamestudio Links
Zorro Links
Newest Posts
Binance Futures Plugin
by OptimusPrime. 11/27/20 17:03
DirectX : 3d Hardware Reset Failure
by Emre. 11/27/20 11:06
Sortino(vars Data, int TimePeriod): var
by danatrader. 11/26/20 20:45
Need code for Williams Sentiment Index
by danatrader. 11/26/20 20:42
Optimizing global & local parameters
by dBc. 11/25/20 15:16
Enter FOK orders simultaneously
by jcl. 11/25/20 10:55
looking how basic functions are made
by jcl. 11/25/20 10:47
AUM Magazine
Latest Screens
Paradox Vector
The Space Between
Pogostuck: Rage With Your Friends
Worst Case Z
Who's Online Now
4 registered members (AndrewAMD, 3run, Ayumi, danatrader), 479 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
MMK, raed, liquidbread, Dmitry_Shesterin, ddczp
18543 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Don't execute the run() function on the current incomplete bar? #481907
11/17/20 17:09
11/17/20 17:09
Joined: Nov 2017
Posts: 17
T
Tamas Offline OP
Newbie
Tamas  Offline OP
Newbie
T

Joined: Nov 2017
Posts: 17
Hi,

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.

Thanks!

Tamas

Re: Don't execute the run() function on the current incomplete bar? [Re: Tamas] #481908
11/17/20 17:56
11/17/20 17:56
Joined: Nov 2017
Posts: 17
T
Tamas Offline OP
Newbie
Tamas  Offline OP
Newbie
T

Joined: Nov 2017
Posts: 17
Here is the example, the BarPeriod is set to 5 mins to test the workshop5 script and StartDate set to 20201101, EndDate commented out.

As you can see after starting the script in Trade mode at 2020-11-17 at 17:48 (not shown on the screenshot), the last run() at bar 747 (which ends at 2020-11-17 17:50) was also run on the incomplete last bar.

At 17:50, the run() function was run again and it printed the same bar which is now complete.

So is there a way to avoid running the run() function on incomplete bars?

Thanks!
I hope I am not missing something here, but it is strange that when the script is started in Trade mode, the run() functions runs twice on the last bar, when it's incomplete and when it's complete.

Attached Files
Re: Don't execute the run() function on the current incomplete bar? [Re: Tamas] #481912
11/19/20 07:41
11/19/20 07:41
Joined: Jul 2000
Posts: 27,401
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,401
Frankfurt
This can happen when the lookback period ends with an incomplete bar. The bars are no duplicates, they have different prices and if you would suppress one of them, the series weren't 100% correct either. But you can use the NOSHIFT flag of the current beta version for this.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1