There may be simpler ways.
int time_length=(int)(OrderCloseTime()-OrderOpenTime()); int seconds=time_length%60; time_length-=seconds; int minutes_seconds=time_length%3600; int minutes=minutes_seconds/60; time_length-=minutes_seconds; int hours_seconds=time_length%86400; int hours=hours_seconds/3600; time_length-=hours_seconds; int days=time_length/86400; Print("Difference is ",days," Days ",hours," Hours ",minutes," Minutes ",seconds," Seconds");
Thanks, for days this seems to work:
TimeDay(OrderCloseTime() - OrderOpenTime());
Jose Luis Lominchar:
Thanks, for days this seems to work:
TimeDay(OrderCloseTime() - OrderOpenTime());
Not if it was open for more than 31 days
Keith Watford:
If for less than 31 days, it's not correct.
Not if it was open for more than 31 days
Keith Watford:
There may be simpler ways.
printf("Difference is %i Days %s", time_length/86400, TimeToString(time_length, TIME_MINUTES|TIME_SECONDS)); // OR MqlDateTime dt; TimeToStruct(time_length,dt); printf("Difference is %i Days %i Hours %i Minutes %i Seconds",time_length/86400,dt.hour,dt.min,dt.sec);
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi,
could somebody tell me how to print the diference in days/hours/... between OrderCloseTime() and OrderOpenTime()?
Thanks