Closed kenorb closed 8 years ago
Something like [1] ? It provides some glue for MQL5's missing functions, I did test it with a simple script and it works just fine and moth MQL{4,5} found no syntax errors.
@LemonBoy Sorry for a late reply. Yes, however I expect those methods wrapped in the class, so I could call the methods consistently from the other file without having worrying about #ifdef
outside of the class or in which version the main MQL file is compiled. In other words I just want to call DateTime::Day()
(or by class instance) from both MQL4/MQL5 file and I expect the same result.
For example the code structure should be:
class DateTime {
int Day() {
#ifdef __MQL5__
MqlDateTime dt;
TimeCurrent(dt);
return(dt.day);
#else
return Day();
#endif
}
// ... more methods
}
where the methods are replication of MQL4 functions and at the same time they're compatible with MQL5 as well. In DateTime
class just use only the function related to date time (so the rest non-relevant part can be removed). This is just initial idea, once the format would be consistent, I'll later provide more classes to write, related to specific functions.
So, something like this [1] ?
That's correct. I think making indentation for #ifdef
would look better if it's aligned with the code (the code would be more readable). Check for other missing date related functions as well. If there is any blocker function that can't be ported easily, add @todo
for MQL5 so you may ignore.
TimeTradeServer
has been added in MQL5 and has no equivalent for MQL4, I'll shift the # tokens once I submit a PR. The other options I didn't bring into the class are the ones that are available for both the versions and making a wrapper sounds quite pointless, no ?
If TimeTradeServer
not there in MQL4, you can still define the method, then return the value for MQL5 but NULL for MQL4 with some code comment (todo), probably this won't be used anyway.
Looks fine. I'll test it later on. Thanks.
Convert existing code (
DateTime.mqh
) into class which implements all listed Date and Time methods using the same name as in MT4 documentation (some of them are already there). These methods should work for both MQL4 (MT4) and MQL5 (MT5) platforms. Remove anything else which is not related to Date and Time.E.g.
Hour()
method should returnHour()
value in MT4, butMqlDateTime
in MT5.Language: MQL 4&5
To compile for each version, you need to install both platforms (MT4 & MT5) and compile using MetaEditor.