series issue?

Posted By: DdlV

series issue? - 08/21/13 02:55

Hi. Please run this code for EUR/USD:

Code:
function run() {
	set(LOGFILE);
	StartDate	= 20130101;
	EndDate		= 20130131;
	vars	Price = series(price());
	vars	Trend	= series(LowPass(Price,1000));
	printf("\nBar,Price0-5=%i,%10.f4,%10.4f,%10.4f,%10.4f,%10.4f,%10.4f",Bar,Price[0],Price[1],Price[2],Price[3],Price[4],Price[5]);
	printf("\nBar,Trend0-5=%i,%10.f4,%10.4f,%10.4f,%10.4f,%10.4f,%10.4f",Bar,Trend[0],Trend[1],Trend[2],Trend[3],Trend[4],Trend[5]);
}



Is the [0] = Current Bar value for both Price and Trend supposed to be 14? That doesn't seem to be what the manual says, and it doesn't carry over to the [1] value of the next bar...

If this is correct, please help me understand.

Thanks.
Posted By: jcl

Re: series issue? - 08/21/13 09:40

I'm fowarding this as a little puzzle to the Zorro users. Who can help DdlV and explain why both price and trend are 14 and don't carry over?

Solution tomorrow.

Hint: you need not run the script.
Posted By: Chaosfreak

Re: series issue? - 08/21/13 09:49

Hi DdIV,

Looks like a typo in the format string for the second argument. You wrote "%10.f4" but it has to be "%10.4f". It's always 14 because "0.f" is just replaced with nothing by printf and 14 remains, or am I wrong (Didn't run the code :))?
Posted By: DdlV

Re: series issue? - 08/21/13 12:11

Thanks jcl, Chaosfreak! *moreeggonface* Yes, it was that hard-to-notice typo. I think the exact explanation is that %10.f4 splits as %10.f for the value format and "4" remains as text. The %10.f formats the 1.xxxx value as "1", which plus the "4" gives the "14".

Back to typing/proofreading/dyslexic/whatever school... frown

Thanks.
Posted By: Chaosfreak

Re: series issue? - 08/21/13 12:56

Yes, that's the correct explanation. This printf stuff always confusing me crazy
© 2024 lite-C Forums