Hi Barry and Tomasz,
Thanks for your efforts and thoughts.
Thanks Tomasz for giving a worked example. This has enabled me to complete what I wanted to, and have shared the code for other users.
I am still trying to get my head around the whole Date/Time issue! :)
Regards
Paul
_SECTION_BEGIN("Days to Expiry Calculations");
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() );
printf("Today's Date:\t\t");Todays_Date = Now(1);
//Hard Coded Dates
startdt = StrToDateTime("2016-04-27");
enddt = StrToDateTime( "2016-12-01");
DifferenceInDays1 = floor( DateTimeDiff( enddt, startdt )/(24*60*60) );
printf("Hard Coded Dates: \t%g", DifferenceInDays1 );
printf("\n\n");
startdtnow = StrToDateTime(Now());
//Expiry Date to Now
printf("Expiry Date:\t\t");Expiry_Date = ParamDate("Expiry Date","01/12/2016",1);
Expiry_Date_Date_Time = StrToDateTime( Expiry_Date );
DifferenceInDays2 = floor( DateTimeDiff( Expiry_Date_Date_Time, startdtnow )/(24*60*60));
printf("Days to Expiry(Now): \t%g", DifferenceInDays2 );
printf("\n");
//Expiry Date to Selected Date
printf("\nSelected Date:\t\t");
Selected_Date = Date();
Selected_DateStr = StrToDateTime(Date());
DifferenceInDays3 = floor( DateTimeDiff( Expiry_Date_Date_Time, Selected_DateStr )/(24*60*60));
printf("Days to Expiry(Selected) \t%g", DifferenceInDays3 );
_SECTION_END();
Posted by: tavenui@googlemail.com
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (3) |
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