running an asset loop in tock

Posted By: Grant

running an asset loop in tock - 04/20/22 18:49

As a general remark about the use of tick() / tock() functions, the manual states:

Quote
Trading with different assets in a tick function can cause backtest snooping bias. When historical price ticks for assets A and B have the same time stamps, the tick function will first run with asset A, then with asset B. In the first run, asset A has the current price, but asset B still the previous price. This can be used to snoop the next B price especially when it strongly depends on the A price. To prevent this effect, use the tock function for trading multiple assets when required, and set TockTime to the tick resolution of the used historical data, or to TickTime in live trading.


However, I'm not allowed to run an asset loop in tock(). This results in an error:

Quote
Error 041: series/loops defined outside run!


It's not a big deal for me to work around this, but can this limitation be removed or is there a particular reason for this?

Thank you.
Posted By: jcl

Re: running an asset loop in tock - 04/21/22 08:02

That's no limitation, but just a code error. Zorro detected that you called series() or loop() in a wrong way or at a wrong place. You can run as many asset loops in tock() as you want, but the special loop() function is used for component optimizing, and that makes no sense inside tock().

https://zorro-project.com/manual/en/loop.htm
Posted By: Grant

Re: running an asset loop in tock - 04/21/22 15:04

Thank you for the clarification, JCL.

Being a creature of habits, I've always used an asset loop for asset calls, but I see that a 'for(used_assets)' works nicely in tock().
© 2024 lite-C Forums