time older than by days

 

i am confused how to calculate if "OTime=2022.05.20 22:00" is older than 3 days by TimeCurrent()

i tried 


((TimeCurrent()-OTime)-(2*86400))+TimeCurrent()

or

(TimeCurrent()-OTime)+(TimeCurrent()-(2*86400))

forgot about my calculations its totally fail i just want to use 'if  expression' date(OTime) is older/greater than 3  days  by TimeCurrent()

 
One solution:

(TimeCurrent () - OTime) > (86400 * 3)


Sorry for missing the code button again. I am on mobile.
 
Dominik Christian Egert #:
One solution:
(TimeCurrent () - OTime) > (86400 * 3)

Don't hard code numbers. Write self-documenting code. You should be able to read the code out loud and have it makes sense.

mohd alqallaf: i am confused how to calculate if "OTime" is older than 3 days
oTime < TimeCurrent() - 3 * PeriodSeconds(PERIOD_D1) // oTime is older than 3 days ago.
The question is ambiguous. Do you mean 3 days or 3 trading days.
iBarShift(_Symbol, PERIOD_D1, oTime) > 3 // oTime is older than 3 trading days ago.
 
thanks for the help
 
Hey also look at CDateTime in Include/Tools/...
There is a brilliant solution where the current Time is resolved into MqlDatetime struct, where every time unit is displayed in int numbers and you have an Increment/Detrement method for every unit(say hours/days).

But, the MqlDateTime is all public which means you can show every seconds value at every point in time.
Reason: