Gamestudio Links
Zorro Links
Newest Posts
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 08/21/19 14:59
Alarm whenever logged out from Broker
by chsmac85. 08/21/19 14:36
What are you working on?
by 3run. 08/21/19 13:28
file_write var array ?
by laz. 08/20/19 17:18
Updating Assets<Brokername
>.csv

by Sabre. 08/20/19 15:40
AUM Magazine
Latest Screens
The Space Between
Pogostuck: Rage With Your Friends
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Who's Online Now
8 registered members (RealSerious3D, 3run, AndrewAMD, Southqvist, kankan, 3 invisible), 640 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
GorgonzolaBYTE, Southqvist, tawin, Raedwulf, Sabre
18270 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
LookBack mysteries #477094
05/16/19 11:29
05/16/19 11:29
Joined: Dec 2014
Posts: 133
Germany
sdh309795gaas Offline OP
Member
sdh309795gaas  Offline OP
Member

Joined: Dec 2014
Posts: 133
Germany
I'm having a headache for some time with Zorros LookBack variable and I finally would like to totally understand this. My current project is using a complex indicator, that's why I included an indicator function in my demo code. The most extreme TimeFrames in my Project are M15 and D1. So this is my demo code:

Code:
void indicator()
{
 vars internal = series(price());

 //int Cycle = DominantPeriod(internal,20);

 int n;
	
 for(n = LookBack - 2; n < LookBack; n++)
 {
   if(is(LOOKBACK)==0) printf("n%s Internal at index %d: %.5f, TimeFrame = %d", Asset, n, internal[n], TimeFrame);
 }
}

function run()
{
 StartDate = 20160101;
 EndDate = 20160107;
 BarPeriod = 15;

 LookBack = 200;
	
 int n;

 while(asset(loop("EUR/USD", "USD/JPY")))
 {
  TimeFrame = 1440 / BarPeriod; //D1
	
  vars Price_D1 = series(price());
  vars Trend_D1 = series(LowPass(Price_D1,200));
		
  for(n = LookBack - 2; n < LookBack; n++)
  {
   if(is(LOOKBACK)==0) printf("n%s External at index %d: %.5f, TimeFrame = %d", Asset, n, Price_D1[n], TimeFrame);
  }

  indicator();
		
  TimeFrame = 15 / BarPeriod; //M15
		
  vars Price_M15 = series(price());
  vars Trend_M15 = series(LowPass(Price_D1,200));
		
  for(n = (LookBack - 2); n < LookBack; n++)
		{
  if(is(LOOKBACK)==0) printf("n%s External at index %d: %.5f, 
  TimeFrame = %d", Asset, n, Price_M15[n], TimeFrame);
  }

  indicator();
 }
}



Mystery #1
My LowPass (Line 30 and 42) is using a period of only 200. Why does (my) Zorro demand LookBack = 288?? Why exactly 88 bars more?

Mystery #2
Please set LookBack = 288 now.
Why do I get identical prices with TimeFrame = 96 (D1)? I'd expect these prices to differ just like the M15 prices do.

Isn't the lookback mechanism clever enough to see that my highest timeframe is D1, go back 288 Days and then start filling all the series with 200 elements (overwriting the M15 series if necessary)?

Mystery#3
Please uncomment line 5 now (Cycle). Why is the needed LookBack period suddenly exploding to 9600 bars when the period value is just 20, much lower than the period of the LowPass filter???

Re: LookBack mysteries [Re: sdh309795gaas] #477104
05/16/19 14:12
05/16/19 14:12
Joined: Sep 2003
Posts: 854
Spirit Offline

Moderator
Spirit  Offline

Moderator

Joined: Sep 2003
Posts: 854
I can at least solve the mystery 3 because I know that DominantPeriod needs 100 bars lookback period. Multiplied with your timeframe, you get 9600 bars.

Re: LookBack mysteries [Re: Spirit] #477112
05/16/19 15:52
05/16/19 15:52
Joined: Dec 2014
Posts: 133
Germany
sdh309795gaas Offline OP
Member
sdh309795gaas  Offline OP
Member

Joined: Dec 2014
Posts: 133
Germany
oh, 96*100... I didn't see this relation but I still don't understand the reason behind this.

I also read this in the manual:

"Filter functions are normally cumulative and require a long-enough LookBack period before the filter data is stable. As a rule of thumb, allow about 200 bars lookback period for detecting dominant cycle/phase..."

By setting lookback = 200 I'd expect to have 200 bars in all series. If DominantPeriod needs only 100 bars as you stated, shouldn't it be fine with 200?

Re: LookBack mysteries [Re: sdh309795gaas] #477113
05/16/19 21:13
05/16/19 21:13
Joined: Sep 2003
Posts: 854
Spirit Offline

Moderator
Spirit  Offline

Moderator

Joined: Sep 2003
Posts: 854
Sure when you want the dominant period in bars and not in 96 bar units.

Re: LookBack mysteries [Re: Spirit] #477114
05/17/19 04:28
05/17/19 04:28
Joined: Dec 2014
Posts: 133
Germany
sdh309795gaas Offline OP
Member
sdh309795gaas  Offline OP
Member

Joined: Dec 2014
Posts: 133
Germany
Hm... this is how I think my code works (obviously it isn't, but why?):

1) TimeFrame is set in run()

2) TimeFrame gets passed on to indicator()

3) indicator() creates local series with 200 M15 or 200 D1 bars, depending on TimeFrame

4) DominantPeriod uses the last 100 M15 or 100 D1 bars. By the way, if 100 bars is needed, what's the value the manual is talking about then: "valid range = 10..60"

Re: LookBack mysteries [Re: sdh309795gaas] #477687
07/21/19 18:26
07/21/19 18:26
Joined: Jul 2019
Posts: 1
no
W
WillSalas Offline
Guest
WillSalas  Offline
Guest
W

Joined: Jul 2019
Posts: 1
no
Hello, thats my first post.

i try to compile you code, but there are al lot of things that give me an error.
And btw...i found a copy/paste fault.

You write two times: "= series(LowPass(Price_D1,200));"

I'm not clear with the variable "LOOKBACK" and "LookBack" in the Indictator, because you don't init it somethere.

Nice regards
Will

Re: LookBack mysteries [Re: sdh309795gaas] #477688
07/21/19 18:35
07/21/19 18:35
Joined: Feb 2017
Posts: 739
Chicago
AndrewAMD Online
User
AndrewAMD  Online
User

Joined: Feb 2017
Posts: 739
Chicago
When your Lite-C script does not include headers, it automatically loads the default.c header. This loads all kinds of definitions and global variables, most of which are defined in the manual.

I suggest you work your way through the strategy tutorial, found here:
https://zorro-project.com/manual/en/tutorial_var.htm

The LookBack global variable is described here:
https://zorro-project.com/manual/en/lookback.htm

The LOOKBACK flag is described here:
https://zorro-project.com/manual/en/mode.htm

The manual is your friend! laugh


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