Hello,
You're welcome. I am glad the code helped.
And I apologize to Barry for not using gentler tone.
Sometimes we all have not the best days.
A positive outcome is that I just thought that it could be useful for ParamDate
to support format = 2 to produce datetime result so you don't need to convert string to datetime at all.
Best regards,
Tomasz Janeczko
amibroker.com
On 2016-04-27 03:42, tavenui@googlemail.com [amibroker] wrote:
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: Tomasz Janeczko <groups@amibroker.com>
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (4) |
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/
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