Hi,
The .ffill() method only works if there are existing values in the interval you are fetching. The index_interval changes every time the script runs, since it defines the time window where new values should be calculated.
-
Backward indexing (when saving a new tag): the index_interval usually spans 30 days.
-
Forward indexing (when keeping a saved tag up to date): the index_interval is much shorter anywhere from a few minutes to a few hours.
If your limit tags (min and max) don’t have any data inside that index_interval, then .ffill() will return NaN, because there’s no previous value available in the requested range.
To solve this fetch a slightly larger time interval that extends before and after your calculation window. The size of this buffer should depend on how often your limit tags update.
Let me know if this solves your issue!
Kind regards
Frederik