Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (Quad, AndrewAMD, Imhotep, TipmyPip, Edgar_Herrera), 809 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 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 Screenshot 2020-11-17 at 17.50.37.png
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,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
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