Now here's one I haven't been able to solve.
I wish to input a user defined date through the Edit Studies (this will be an options expiry date).
Then grab the date of the current bar.
Then subtract the two and plot the difference, giving the number of days to expiry.
It only has to work on a daily chart.
I found the following approach in the archives....
date1 = yyyymmdd ==>> create a number in this format
then perform the following multiplication in two steps
step1=(4 digit year)*100 + month;
step2=step1*100+day;
Now this works as long as the two dates are in the same month.
When the dates are in different months, the resulting difference is way off, as the date numbers are not really correct. When you change to a new month, the number is off by approximately 70.
Is there a way to do what I described above?
Below is a test efs that shows the problem.
I wish to input a user defined date through the Edit Studies (this will be an options expiry date).
Then grab the date of the current bar.
Then subtract the two and plot the difference, giving the number of days to expiry.
It only has to work on a daily chart.
I found the following approach in the archives....
date1 = yyyymmdd ==>> create a number in this format
then perform the following multiplication in two steps
step1=(4 digit year)*100 + month;
step2=step1*100+day;
Now this works as long as the two dates are in the same month.
When the dates are in different months, the resulting difference is way off, as the date numbers are not really correct. When you change to a new month, the number is off by approximately 70.
Is there a way to do what I described above?
Below is a test efs that shows the problem.
Comment