I am testing a strategy on historical futures data and would like to add an indicator /DataSeries that would tell me how many bars there are until the end of the data (ie contract expiration).
any help would be appreciated
Thanks
Size:
Color:
CODE:
Please log in to see this code.
Size:
Color:
If you know the date of the contract expiration, you can use TradingDaysBetweenDates() from Community.Components like this to determine the number of trading days in the future are left until the contract expires.
CODE:
Please log in to see this code.
However, this function is meant for U.S. stocks, so Sundays are not considered trading days. You can modify this function as required:
CODE:
Please log in to see this code.
Size:
Color: