Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
basik85278
by basik85278. 04/28/24 08:56
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 730 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Handle LookBack exceeded #485991
05/25/22 13:01
05/25/22 13:01
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online OP
Serious User
AndrewAMD  Online OP
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
Can there be a new feature for handling lookback exceeded?

For example, Script sets LookBack to 100. But in fact, 200 was required. So during cleanup(), the script will launch the same Zorro script (different instance), this time with Lookback = 200.

This can be useful for when all kinds of TA functions are mixed and matched, and it is difficult to calculate maximum lookback.

Re: Handle LookBack exceeded [Re: AndrewAMD] #485995
05/25/22 19:51
05/25/22 19:51
Joined: Apr 2008
Posts: 586
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 586
Austria
Isnt the needed lookback displayed in the error message?

Re: Handle LookBack exceeded [Re: Petra] #485996
05/25/22 20:01
05/25/22 20:01
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online OP
Serious User
AndrewAMD  Online OP
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
Yes, but then I’d have to punch it in manually.

But imagine that I’m running a batch script where I input many variables at the command line. If a lookback error occurs, I can launch a sub-process that automatically corrects the issue with a sufficient memory allocation.

Re: Handle LookBack exceeded [Re: AndrewAMD] #486001
05/26/22 07:53
05/26/22 07:53
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
We could implement a variable that contains the minimum lookback after the initial run, and a method to restart by script. You can then set Lookback like this:

LookBack = max(100,LookBackMinimum);

Re: Handle LookBack exceeded [Re: AndrewAMD] #486015
05/28/22 15:43
05/28/22 15:43
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online OP
Serious User
AndrewAMD  Online OP
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
Already done? Nice.

Quick question: If quit "+" is called, can the length of series calls change, or do I need to terminate the script to change the length?

Re: Handle LookBack exceeded [Re: AndrewAMD] #486016
05/28/22 20:08
05/28/22 20:08
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online OP
Serious User
AndrewAMD  Online OP
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
So it looks like series length is determined during INITRUN but not allocated until FIRSTRUN:
https://zorro-project.com/manual/en/series.htm
Quote
Since the LookBack value is normally only known after the INITRUN, series are allocated in the FIRSTRUN. During the INITRUN they are set to a temporary pointer and filled with the initial value. This temporary content is overwritten by the series allocation in the FIRSTRUN.
Plus my tests seem to confirm that quit "+" allows me to change series length without issue. This is nice!

One more thing: there's a bug in this sample code from the manual:
https://zorro-project.com/manual/en/lookback.htm
Code
// restart script when lookback period is exceededvoid run(){
  LookBack = max(30,LookBackNeeded);  ...
  SMA(seriesC(),50); // need more than 30 bars!
  if(!Init && LookBack < LookBackNeeded)
    return quit("+Restart with new LookBack");  ...}
quit(+) gets skipped because this can only be detected in Init. So more like this:
Code
if(Init && LookBack < LookBackNeeded)

Re: Handle LookBack exceeded [Re: AndrewAMD] #486019
05/30/22 20:22
05/30/22 20:22
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online OP
Serious User
AndrewAMD  Online OP
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
It's worth noting that invoking indicator functions to calculate lookback can still be problematic, even when restarting the script with quit(+).

Namely, if a vars of insufficient length is supplied to an indicator function, even in Init, this can cause many bad memory writes and strange errors. The workaround here is to supply a large dummy buffer during init only.

Re: Handle LookBack exceeded [Re: AndrewAMD] #486022
05/31/22 13:41
05/31/22 13:41
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
With which indicator does this happen? The indicators from the ta-lib cannot read past the lookback period.

Re: Handle LookBack exceeded [Re: AndrewAMD] #486024
05/31/22 13:50
05/31/22 13:50
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online OP
Serious User
AndrewAMD  Online OP
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
That would require testing to determine, but I’d assume the ones from indicators.c.

Re: Handle LookBack exceeded [Re: AndrewAMD] #486025
05/31/22 14:04
05/31/22 14:04
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Hmm. We could limit them also to the lookback period, but many are also used with general data arrays. This would then not work anymore. A large dummy buffer is maybe indeed the best solution, only question is how large it should be.

Page 1 of 2 1 2

Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1