Check Lookback on a per-asset basis

Posted By: AndrewAMD

Check Lookback on a per-asset basis - 09/16/22 15:17

On many stock portfolio trading systems, when backtesting daily data, different stocks have different start dates. For example, MSFT started much earlier than META.

It would help to know if the lookback period has been satisfied on a per-asset basis. It can be like this:

LookBack = AssetLookback = 100;

Then loop through the assets and check for (!is(ASSETLOOKBACK) && !is(LOOKBACK) && !Init) before trading on any given asset.
Posted By: jcl

Re: Check Lookback on a per-asset basis - 09/19/22 13:52

You can use the AssetFirstBar variable from the new beta version. If AssetFirstBar+LookBack < Bar, the current asset is still inside its Lookback period.
Posted By: AndrewAMD

Re: Check Lookback on a per-asset basis - 09/19/22 13:56

That should work, thanks!
Posted By: AndrewAMD

Re: Check Lookback on a per-asset basis - 09/22/22 13:41

By the way, the manual's description of AssetFirstBar is incomplete:
Quote
AssetFirstBar
Number of the first valid bar of the selected asset. Can be different when asset histories start after the
https://zorro-project.com/manual/en/numbars.htm
© 2024 lite-C Forums