Libraries: Dealing with time (2) functions - page 3

 
amrali #: I also found the same error today (Saturday) when testing the library. #define  BoW_fixed(t) ((t)-((t)+345600)%604800)

Another way that may be easier to understand

#define DoWi(now) ENUM_DAY_OF_WEEK((now-D'1970.01.04')/86400 %7)
 
William Roeder #:

Another way that may be easier to understand

Thanks William ... Will try it out

 
William Roeder #:

Another way that may be easier to understand

Thanks William...

So, this one fits with your macro

#define DoWs(now) EnumToString(DoWi)
 

Hi @Carl Schreiber

thank you for the library.

Where did you take the library EnumStructure.mqh written in the first line?

 
MQL5 should launch a new version soon, until the current version has a simple return function to determine whether an asset is open or closed, or even a simple open and close time of the broker to be used in the operation, or even a metatrader is also missing. a simple and easy way to know the profitability of the active market or how much time is left for the opening or closing of the broker's asset movement or any other information, as well as the real bid and offer order book also needs to be implemented soon, since this also does not exist, nor any broker or metatrade, currently only large players know this information, which is why there is so much manipulation of the xauusd market and other safe haven assets.
 


Can be added to the library:

#define  BoW(t) ((t)-((t)+345600)%604800)                // Begin of Week 2017.08.03 11:30 => Sun, 2017.07.30 00:00 (fixed version)

#define  Prev(day,t) ((t)-((t)+(4-(day))*86400)%604800)  // Previous Weekday for a specific time. Prev(SUNDAY, D'2017.08.03 11:30') => Sun, 2017.07.30 00:00


BoW() is a special case of the more general Prev() macro, as BoW(t) = Prev(SUNDAY, t).

BoW(D'2017.08.03 11:30');             //  => Sun, 2017.07.30 00:00
Prev(SUNDAY, D'2017.08.03 11:30');    //  => Sun, 2017.07.30 00:00

Prev(FRIDAY, D'2017.08.03 11:30');    //  => Fri, 2017.07.28 00:00
 

Thanks to everyone and sorry I'm late, but I'm very busy at the moment - I'll integrate your improvements soon.

PS. I never saw Saturday as relevant. We should never stop learning. :)

 
Interesting project. Somehow also seem to have issues running this correctly on a Saturday, unsure how to resolve. Can anyone provide instructions for the proper fix and secondly, a simple piece of code I can use in my EA to extract GMT from TimeCurrent (or rather, TimeTradeServer). Looking for a way to obtain GMT during backtest. Thanks!
 
Flying Dutchman #:
Interesting project. Somehow also seem to have issues running this correctly on a Saturday, unsure how to resolve. Can anyone provide instructions for the proper fix and secondly, a simple piece of code I can use in my EA to extract GMT from TimeCurrent (or rather, TimeTradeServer). Looking for a way to obtain GMT during backtest. Thanks!

https://www.mql5.com/en/code/48291

TimeGMT library for the strategy tester
TimeGMT library for the strategy tester
  • www.mql5.com
Static class to fix the TimeGMT() function during testing in the strategy tester.
 
Flying Dutchman #:
Interesting project. Somehow also seem to have issues running this correctly on a Saturday, unsure how to resolve. Can anyone provide instructions for the proper fix and secondly, a simple piece of code I can use in my EA to extract GMT from TimeCurrent (or rather, TimeTradeServer). Looking for a way to obtain GMT during backtest. Thanks!

Can you provide an example where and how the issues appears - e.g. a script?

Reason: