Working on a script that filters through a large list of assets, some of which are much younger than the backtest length. The history can be as short as a year but since I'm working with daily bars, I can't cut the backtest length short to just one year.
I have plotted one such histories and have noticed that it propagates the earliest value in the history all the way to the earliest day of the backtest. This means I probably can't check if price() returns something valid, because it does no matter what.
I have found AssetFrame in the manual which states: "Asset specific time frame, automatically set by AssetZone or AssetMarket. 0 when the current asset had no price quotes in the current bar or when its market is closed".
I haven't tested if that works for my intended purposes, it seems to be designed for some other purpose. Is there a recommended way to check if an asset already has a history at the current bar? I also need to consider that each asset will need some lookback period to calculate indicators and such. I could run an int array that counts up each encountered bar of an asset, and then only start considering assets once the counter is greater than the lookback. But maybe there's some built-in solution to this problem?
Last edited by MegaTanker; 08/28/21 17:38.