From 78847e63ba1843d4326f863be776d0d9fc471403 Mon Sep 17 00:00:00 2001 From: Ding Li Date: Sun, 7 Apr 2019 11:03:04 +0800 Subject: [PATCH] Improve MT4/MT5 compatibility: AccountFreeMarginMode is not defined in MT5, and second parameter of FileReadDouble is not necessary --- Trade/Account.mqh | 2 ++ Utils/File.mqh | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Trade/Account.mqh b/Trade/Account.mqh index 72120ce..e6e6fd5 100644 --- a/Trade/Account.mqh +++ b/Trade/Account.mqh @@ -54,7 +54,9 @@ public: static double getEquity() {return AccountInfoDouble(ACCOUNT_EQUITY);} static double getMargin() {return AccountInfoDouble(ACCOUNT_MARGIN);} static double getFreeMargin() {return AccountInfoDouble(ACCOUNT_MARGIN_FREE);} +#ifdef __MQL4__ static int getFreeMarginCalcMode() {return AccountFreeMarginMode();} +#endif static double getMarginLevel() {return AccountInfoDouble(ACCOUNT_MARGIN_LEVEL);} static double getMarginCallLevel() {return AccountInfoDouble(ACCOUNT_MARGIN_SO_CALL);} static double getMarginStopoutLevel() {return AccountInfoDouble(ACCOUNT_MARGIN_SO_SO);} diff --git a/Utils/File.mqh b/Utils/File.mqh index f1ed5d7..133f776 100644 --- a/Utils/File.mqh +++ b/Utils/File.mqh @@ -87,7 +87,7 @@ public: BinaryFile(string name,int flags):File(name,flags|FILE_BIN){} void reopen(string name,int flags) {reopen(name,flags|FILE_BIN);} - double readDouble(int size=DOUBLE_VALUE) const {return FileReadDouble(m_handle,size);} + double readDouble() const {return FileReadDouble(m_handle);} float readFloat() const {return FileReadFloat(m_handle);} long readLong() const {return FileReadLong(m_handle);} int readInteger(int size=INT_VALUE) const {return FileReadInteger(m_handle,size);} @@ -96,7 +96,7 @@ public: template uint readStruct(T &value,int size=-1) const {return FileReadStruct(m_handle,value,size);} - uint writeDouble(double value,int size=DOUBLE_VALUE) {return FileWriteDouble(m_handle,value,size);} + uint writeDouble(double value) {return FileWriteDouble(m_handle,value);} uint writeFloat(float value) {return FileWriteFloat(m_handle,value);} uint writeInteger(int value,int size=INT_VALUE) {return FileWriteInteger(m_handle,value,size);} uint writeLong(long value) {return FileWriteLong(m_handle,value);}