Understanding Zorro: restrictions of the order of commands

Posted By: NorbertSz

Understanding Zorro: restrictions of the order of commands - 04/28/22 08:36

Hello,

Because of some incomprehensible behavior I narrow down the error to the following.

Code
function run(){
	asset("EURUSD");
	StartDate = NOW;
	printf("\nhello preload (%s)", Asset);
	if (!is(LOOKBACK)){
		printf("\nhello trading");
	}
}


The Zorro log writes a lot "hello preload (EURUSD)", but never go to "hello trading".

However in this case I see the "hello trading" message.
Code
function run(){
	StartDate = NOW;
	asset("EURUSD");
	printf("\nhello preload (%s)", Asset);
	if (!is(LOOKBACK)){
		printf("\nhello trading");
	}
}


It's totally illogical for me, and I'm trying to understand why is it possible. No error messages, Zorro can select the Asset (I see the "hello preload (EURUSD)" message), but just do not finishing the lookback period. Could someone explain this phenomenon?

Is there a guideline for dummies of other restrictions / rules about which statement should follow others?
Like this: "do not select the asset before setting up the startdate".

Also I think it would be great if Zorro could generate an error message if the order of statements is incorrect.

Thank you!
(Zorro S 2.44)
Posted By: jcl

Re: Understanding Zorro: restrictions of the order of commands - 04/28/22 08:42

The order of commands matters in any programming language. In which way it matters is normally obvious, but not always. In such a case I'm afraid there's no way around reading the description in the manual. Especially the remarks in fat red letters.

https://zorro-project.com/manual/en/asset.htm

Zorro finds many such bugs, but not all. Although your start date setting makes here no sense, it could be correct under other circumstances, and therefore does not thrown an error.
© 2024 lite-C Forums