I am bumping into a problem that I just don't know how to fix and I am out of idea's at the moment... Any help appreciated.
What I am trying to do is calculate how many trading day's are left in a futures life before it expires.
I tried calculating it with "DaysInMonth" and "DayOfWeek" but that sometimes fails when there are public holidays.
I tried importing the expiration date into the AUX1 field but that failed because of floating point format.
What I think I can do so far is two things, hopefully someone can tell me that one of the two is the best solution or someone has some other way that might be better.
Create a CSV file with the current date and the expiration date. I can then read this file from my afl code and use the calculations.
I store all past and future expiration dates in my afl file and read through that. This will create a very long afl file but it might be the solution.
Does anyone have any idea's about this ? I have never done something like this and honestly, have no idea which route to take.
From Tomasz I get the impression that the numbers are allready stored correctly, just not showing correctly, but using the datenum value sounds like the solution to me if for some reason the other thread can not be used.
If I understand how AmiBroker works, I can write an afl that can handle the import of my csv file, in that afl I can convert the expiry date column to datenum and then take it from there. Not sure if the normal importer can handle the conversion to datenum....
For dates you have to use designated field that can hold actual date. Aux is not for that.
If you want to store contract expiration date you can for example re-use dividend date for that purpose (because contracts don't pay dividends) or split date.
Both (dividend date, split date) can be imported using ASCII importer, see:
and this:
You can then access that dates using GetFnData function
Have not read it all completely yet but this sounds like the way to go to import other dates ! import wizard did not show all the options that are apperantly available.