Bars until end of data
Author: maninjapan
Creation Date: 6/5/2014 3:17 PM
profile picture

maninjapan

#1
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
profile picture

Eugene

#2
CODE:
Please log in to see this code.
profile picture

Cone

#3
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.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).