[amibroker] Number of Days Between Two Dates

 

I am trying to find the number of calendar days between two dates, Current Date of Last Bar and a Future Expiry Date.

I have left the code as it is so that;
People can see what I have tried
People can see how I really don't understand DateTime and it's various formats.

Much appreciate your help as always.

SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );

Expiry_Date = ParamDate("Expiry_Date","28/4/2016",1);
x = Now( 5 ) ;

printf( "Now: %g", x );
printf("\n");

Calculation_Date = ParamDate("CD", "24/12/2016", 0);

Days_To_Go =  DateTimeDiff(  Now(5), Calculation_Date )/60/60/24;

printf("\nDays_To_Go %g" , Days_To_Go);

//printf("\nExpiry Date %g" , Expiry_Date);
printf("\n");
printf("\n");

dt1 = DateTimeToStr( x , 0 );
dt2 = LastValue(DateTime());

//printf("\ndt1 ", dt1);
printf("\ndt2 %g", dt2);

Days_To_Expiry = DateTimeDiff(x, dt2);

printf("\nDays to Expiry %g", Days_To_Expiry);

Regards

Paul


__._,_.___

Posted by: tavenui@googlemail.com
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (1)

Upgrade your account with the latest Yahoo Mail app
Get organized with the fast and easy-to-use Yahoo Mail app. Upgrade today!

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/


.

__,_._,___


EmoticonEmoticon