11 registered members (kvm, AndrewAMD, Ayumi, tomaslolo, 3run, Quad, saulius, 20BN, 3 invisible),
627
guests, and 6
spiders. 
Key:
Admin,
Global Mod,
Mod



LookBack mysteries
#477094
05/16/19 11:29
05/16/19 11:29

Joined: Dec 2014
Posts: 133 Germany
sdh309795gaas
OP
Member

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: 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???



