From 178e8c883e9bb29b4a7592d69fed6c32ea6dd9f9 Mon Sep 17 00:00:00 2001 From: Adrian Kierzkowski Date: Tue, 8 Jun 2021 21:46:23 +0200 Subject: [PATCH] Adding missing methods, making code MQL/C++ compatible. --- Bar.struct.h | 3 +- DictIteratorBase.mqh | 6 +++ Indicator.struct.h | 2 - Indicator.struct.signal.h | 8 ++-- Market.struct.h | 20 ++++----- Order.enum.h | 6 ++- Order.mqh | 10 ++--- Order.struct.h | 10 ++--- SerializerJson.mqh | 56 +++++++++++++------------- SymbolInfo.mqh | 85 ++++++++++++++++++++------------------- 10 files changed, 110 insertions(+), 96 deletions(-) diff --git a/Bar.struct.h b/Bar.struct.h index 15ba564ae..ff2c91949 100644 --- a/Bar.struct.h +++ b/Bar.struct.h @@ -56,7 +56,7 @@ struct BarOHLC _time = TimeCurrent(); } } - BarOHLC(float &_prices[], datetime _time = 0) : time(_time) { + BarOHLC(ARRAY_REF(float, _prices), datetime _time = 0) : time(_time) { _time = _time == 0 ? TimeCurrent() : _time; int _size = ArraySize(_prices); close = _prices[0]; @@ -187,6 +187,7 @@ struct BarOHLC float GetWickUpper() const { return high - GetMaxOC(); } float GetWickUpperInPct() const { return GetRange() > 0 ? 100 / GetRange() * GetWickUpper() : 0; } short GetType() const { return IsBull() ? 1 : (IsBear() ? -1 : 0); } + void GetValues(ARRAY_REF(float, _out)) { ArrayResize(_out, 4); int _index = ArraySize(_out) - 4; _out[_index++] = open; diff --git a/DictIteratorBase.mqh b/DictIteratorBase.mqh index d8175d93f..74a3cd9cc 100644 --- a/DictIteratorBase.mqh +++ b/DictIteratorBase.mqh @@ -27,6 +27,9 @@ #include "DictBase.mqh" +template +class DictBase; + template class DictIteratorBase { protected: @@ -106,6 +109,9 @@ class DictIteratorBase { } }; +template +class DictSlot; + template struct DictSlotsRef { DictSlot DictSlots[]; diff --git a/Indicator.struct.h b/Indicator.struct.h index fd91834ca..26f017e0a 100644 --- a/Indicator.struct.h +++ b/Indicator.struct.h @@ -35,12 +35,10 @@ class Indicator; struct ChartParams; // Includes. -#include "Chart.struct.h" #include "Chart.struct.tf.h" #include "Data.struct.h" #include "DateTime.struct.h" #include "Indicator.enum.h" -#include "Indicator.struct.signal.h" #include "SerializerNode.enum.h" /** diff --git a/Indicator.struct.signal.h b/Indicator.struct.signal.h index 240f1d575..f5b0f048b 100644 --- a/Indicator.struct.signal.h +++ b/Indicator.struct.signal.h @@ -37,6 +37,7 @@ struct IndicatorParams; // Includes. #include "Chart.struct.h" +#include "Indicator.struct.h" /* Structure for indicator signals. */ struct IndicatorSignal { @@ -55,14 +56,15 @@ struct IndicatorSignal { unsigned int signals; // Store signals (@see: ENUM_INDICATOR_SIGNAL). // Constructors. - void IndicatorSignal(int _signals = 0) : signals(_signals) {} - void IndicatorSignal(IndicatorDataEntry &_data[], IndicatorParams &_ip, ChartParams &_cp, int _m1 = 0, int _m2 = 0) + IndicatorSignal(int _signals = 0) : signals(_signals) {} + IndicatorSignal(ARRAY_REF(IndicatorDataEntry, _data), IndicatorParams &_ip, ChartParams &_cp, int _m1 = 0, int _m2 = 0) : signals(0) { CalcSignals(_data, _ip, _cp, _m1, _m2); } // Main methods. // Calculate signal values. - void CalcSignals(IndicatorDataEntry &_data[], IndicatorParams &_ip, ChartParams &_cp, int _m1 = 0, int _m2 = 0) { + void CalcSignals(ARRAY_REF(IndicatorDataEntry, _data), IndicatorParams &_ip, ChartParams &_cp, int _m1 = 0, + int _m2 = 0) { int _size = ArraySize(_data); // INDICATOR_SIGNAL_CROSSOVER bool _is_cross = false; diff --git a/Market.struct.h b/Market.struct.h index bd1cf1af0..cd6fe846f 100644 --- a/Market.struct.h +++ b/Market.struct.h @@ -46,8 +46,8 @@ struct MarketTimeForex : MqlDateTime { MARKET_TIME_FOREX_HOURS_PACIFIC = MARKET_TIME_FOREX_HOURS_SYDNEY | MARKET_TIME_FOREX_HOURS_WELLINGTON, }; // Constructors. - MarketTimeForex(datetime _time_gmt) { TimeToStruct(_time_gmt, this); } - MarketTimeForex(MqlDateTime &_dt_gmt) { this = _dt_gmt; } + MarketTimeForex(datetime _time_gmt) { TimeToStruct(_time_gmt, THIS_REF); } + MarketTimeForex(MqlDateTime &_dt_gmt) { THIS_REF = _dt_gmt; } // State methods. /* Getters */ bool CheckHours(unsigned int _hours_enums) { @@ -137,13 +137,13 @@ struct MarketTimeForex : MqlDateTime { case MARKET_TIME_FOREX_HOURS_WELLINGTON: return 6; case MARKET_TIME_FOREX_HOURS_AMERICA: - return fmax(GetCloseHour(MARKET_TIME_FOREX_HOURS_NEWYORK), GetCloseHour(MARKET_TIME_FOREX_HOURS_CHICAGO)); + return MathMax(GetCloseHour(MARKET_TIME_FOREX_HOURS_NEWYORK), GetCloseHour(MARKET_TIME_FOREX_HOURS_CHICAGO)); case MARKET_TIME_FOREX_HOURS_ASIA: - return fmax(GetCloseHour(MARKET_TIME_FOREX_HOURS_TOKYO), GetCloseHour(MARKET_TIME_FOREX_HOURS_HONGKONG)); + return MathMax(GetCloseHour(MARKET_TIME_FOREX_HOURS_TOKYO), GetCloseHour(MARKET_TIME_FOREX_HOURS_HONGKONG)); case MARKET_TIME_FOREX_HOURS_EUROPE: - return fmax(GetCloseHour(MARKET_TIME_FOREX_HOURS_LONDON), GetCloseHour(MARKET_TIME_FOREX_HOURS_FRANKFURT)); + return MathMax(GetCloseHour(MARKET_TIME_FOREX_HOURS_LONDON), GetCloseHour(MARKET_TIME_FOREX_HOURS_FRANKFURT)); case MARKET_TIME_FOREX_HOURS_PACIFIC: - return fmax(GetCloseHour(MARKET_TIME_FOREX_HOURS_SYDNEY), GetCloseHour(MARKET_TIME_FOREX_HOURS_WELLINGTON)); + return MathMax(GetCloseHour(MARKET_TIME_FOREX_HOURS_SYDNEY), GetCloseHour(MARKET_TIME_FOREX_HOURS_WELLINGTON)); default: return 0; } @@ -168,13 +168,13 @@ struct MarketTimeForex : MqlDateTime { case MARKET_TIME_FOREX_HOURS_WELLINGTON: return 22; case MARKET_TIME_FOREX_HOURS_AMERICA: - return fmin(GetOpenHour(MARKET_TIME_FOREX_HOURS_NEWYORK), GetOpenHour(MARKET_TIME_FOREX_HOURS_CHICAGO)); + return MathMin(GetOpenHour(MARKET_TIME_FOREX_HOURS_NEWYORK), GetOpenHour(MARKET_TIME_FOREX_HOURS_CHICAGO)); case MARKET_TIME_FOREX_HOURS_ASIA: - return fmin(GetOpenHour(MARKET_TIME_FOREX_HOURS_TOKYO), GetOpenHour(MARKET_TIME_FOREX_HOURS_HONGKONG)); + return MathMin(GetOpenHour(MARKET_TIME_FOREX_HOURS_TOKYO), GetOpenHour(MARKET_TIME_FOREX_HOURS_HONGKONG)); case MARKET_TIME_FOREX_HOURS_EUROPE: - return fmin(GetOpenHour(MARKET_TIME_FOREX_HOURS_LONDON), GetOpenHour(MARKET_TIME_FOREX_HOURS_FRANKFURT)); + return MathMin(GetOpenHour(MARKET_TIME_FOREX_HOURS_LONDON), GetOpenHour(MARKET_TIME_FOREX_HOURS_FRANKFURT)); case MARKET_TIME_FOREX_HOURS_PACIFIC: - return fmin(GetOpenHour(MARKET_TIME_FOREX_HOURS_SYDNEY), GetOpenHour(MARKET_TIME_FOREX_HOURS_WELLINGTON)); + return MathMin(GetOpenHour(MARKET_TIME_FOREX_HOURS_SYDNEY), GetOpenHour(MARKET_TIME_FOREX_HOURS_WELLINGTON)); default: return 0; } diff --git a/Order.enum.h b/Order.enum.h index 9809f393d..d4bc77e09 100644 --- a/Order.enum.h +++ b/Order.enum.h @@ -106,7 +106,9 @@ enum ENUM_ORDER_REASON { ORDER_REASON_TP, // The order was placed as a result of Take Profit activation. ORDER_REASON_WEB, // The order was placed from a web platform. }; -#else +#endif + +#ifndef __MQ4__ /** * Enumeration for order selection type. * @@ -229,6 +231,8 @@ enum ENUM_POSITION_PROPERTY_DOUBLE { POSITION_VOLUME, // Position volume (double). }; +#define POSITION_TICKET + /** * Returns integer type of the position property. * diff --git a/Order.mqh b/Order.mqh index 5c6450190..fdbe36e96 100644 --- a/Order.mqh +++ b/Order.mqh @@ -340,7 +340,7 @@ class Order : public SymbolInfo { // and only for the symbols with Market or Exchange execution. // In case of partial filling a market or limit order with remaining volume is not canceled but processed further. ENUM_ORDER_TYPE_FILLING _result = ORDER_FILLING_RETURN; - const long _filling_mode = SymbolInfo::GetFillingMode(_symbol); + const long _filling_mode = SymbolInfoStatic::GetFillingMode(_symbol); if ((_filling_mode & SYMBOL_FILLING_IOC) == SYMBOL_FILLING_IOC) { // Execute a deal with the volume maximally available in the market within that indicated in the order. // In case the order cannot be filled completely, the available volume of the order will be filled, and the @@ -369,8 +369,8 @@ class Order : public SymbolInfo { */ static ENUM_ORDER_TYPE_FILLING GetOrderFilling(const string _symbol, const long _type) { const ENUM_SYMBOL_TRADE_EXECUTION _exe_mode = - (ENUM_SYMBOL_TRADE_EXECUTION)SymbolInfo::SymbolInfoInteger(_symbol, SYMBOL_TRADE_EXEMODE); - const long _filling_mode = SymbolInfo::GetFillingMode(_symbol); + (ENUM_SYMBOL_TRADE_EXECUTION)SymbolInfoStatic::SymbolInfoInteger(_symbol, SYMBOL_TRADE_EXEMODE); + const long _filling_mode = SymbolInfoStatic::GetFillingMode(_symbol); return ((_filling_mode == 0 || (_type >= ORDER_FILLING_RETURN) || ((_filling_mode & (_type + 1)) != _type + 1)) ? (((_exe_mode == SYMBOL_TRADE_EXECUTION_EXCHANGE) || (_exe_mode == SYMBOL_TRADE_EXECUTION_INSTANT)) ? ORDER_FILLING_RETURN @@ -2638,7 +2638,7 @@ class Order : public SymbolInfo { * @return * Returns true when the condition is met. */ - bool CheckCondition(ENUM_ORDER_CONDITION _cond, DataParamEntry REF(_args)[]) { + bool CheckCondition(ENUM_ORDER_CONDITION _cond, ARRAY_REF(DataParamEntry, _args)) { switch (_cond) { case ORDER_COND_IN_LOSS: return GetProfit() < 0; @@ -2726,7 +2726,7 @@ class Order : public SymbolInfo { * @return * Returns true when the condition is met. */ - bool ExecuteAction(ENUM_ORDER_ACTION _action, DataParamEntry REF(_args)[]) { + bool ExecuteAction(ENUM_ORDER_ACTION _action, ARRAY_REF(DataParamEntry, _args)) { switch (_action) { case ORDER_ACTION_CLOSE: switch (oparams.dummy) { diff --git a/Order.struct.h b/Order.struct.h index f18adb2d0..e207cd872 100644 --- a/Order.struct.h +++ b/Order.struct.h @@ -60,7 +60,7 @@ struct OrderParams { color color_arrow; // Color of the opening arrow on the chart. unsigned short refresh_rate; // How often to refresh order values (in secs). ENUM_ORDER_CONDITION cond_close; // Close condition. - DataParamEntry cond_close_args[]; // Close condition argument. + ARRAY(DataParamEntry, cond_close_args); // Close condition argument. // Special struct methods. OrderParams() : dummy(false), color_arrow(clrNONE), refresh_rate(10), cond_close(ORDER_COND_NONE){}; OrderParams(bool _dummy) : dummy(_dummy), color_arrow(clrNONE), refresh_rate(10), cond_close(ORDER_COND_NONE){}; @@ -105,7 +105,7 @@ struct OrderParams { } SetUserError(ERR_INVALID_PARAMETER); } - void SetConditionClose(ENUM_ORDER_CONDITION _cond, DataParamEntry REF(_args)[]) { + void SetConditionClose(ENUM_ORDER_CONDITION _cond, ARRAY_REF(DataParamEntry, _args)) { cond_close = _cond; ArrayResize(cond_close_args, ArraySize(_args)); for (int i = 0; i < ArraySize(_args); i++) { @@ -441,7 +441,7 @@ struct OrderData { } SetUserError(ERR_INVALID_PARAMETER); } - void ProcessLastError() { last_error = fmax(last_error, Terminal::GetLastError()); } + void ProcessLastError() { last_error = MathMax(last_error, (unsigned int)Terminal::GetLastError()); } void ResetError() { ResetLastError(); last_error = ERR_NO_ERROR; @@ -784,7 +784,7 @@ struct OrderStatic { * Usage: SerializerConverter::FromObject(MqlTradeRequestProxy(_request)).ToString()); */ struct MqlTradeRequestProxy : MqlTradeRequest { - MqlTradeRequestProxy(MqlTradeRequest &r) { this = r; } + MqlTradeRequestProxy(MqlTradeRequest &r) { THIS_REF = r; } SerializerNodeType Serialize(Serializer &s) { s.PassEnum(THIS_REF, "action", action); @@ -814,7 +814,7 @@ struct MqlTradeRequestProxy : MqlTradeRequest { * Usage: SerializerConverter::FromObject(MqlTradeResultProxy(_request)).ToString()); */ struct MqlTradeResultProxy : MqlTradeResult { - MqlTradeResultProxy(MqlTradeResult &r) { this = r; } + MqlTradeResultProxy(MqlTradeResult &r) { THIS_REF = r; } SerializerNodeType Serialize(Serializer &s) { s.Pass(THIS_REF, "retcode", retcode); diff --git a/SerializerJson.mqh b/SerializerJson.mqh index 72378504d..6d7524140 100644 --- a/SerializerJson.mqh +++ b/SerializerJson.mqh @@ -64,27 +64,27 @@ class SerializerJson { repr += ident; - if (_node.GetKeyParam() != NULL && _node.GetKeyParam().AsString(false, false) != "") - repr += _node.GetKeyParam().AsString(false, true) + ":" + (trimWhitespaces ? "" : " "); + if (PTR_ATTRIB(_node, GetKeyParam()) != NULL && PTR_ATTRIB(PTR_ATTRIB(_node, GetKeyParam()), AsString(false, false)) != "") + repr += PTR_ATTRIB(PTR_ATTRIB(_node, GetKeyParam()), AsString(false, true)) + ":" + (trimWhitespaces ? "" : " "); - if (_node.GetValueParam() != NULL) repr += _node.GetValueParam().AsString(false, true); + if (PTR_ATTRIB(_node, GetValueParam()) != NULL) repr += PTR_ATTRIB(PTR_ATTRIB(_node, GetValueParam()), AsString(false, true)); - switch (_node.GetType()) { + switch (PTR_ATTRIB(_node, GetType())) { case SerializerNodeObject: - repr += "{" + (trimWhitespaces ? "" : "\n"); + repr += string("{") + (trimWhitespaces ? "" : "\n"); break; case SerializerNodeArray: - repr += "[" + (trimWhitespaces ? "" : "\n"); + repr += string("[") + (trimWhitespaces ? "" : "\n"); break; } - if (_node.HasChildren()) { - for (unsigned int j = 0; j < _node.NumChildren(); ++j) { - repr += _node.GetChild(j).ToString(trimWhitespaces, indentSize, indent + 1); + if (PTR_ATTRIB(_node, HasChildren())) { + for (unsigned int j = 0; j < PTR_ATTRIB(_node, NumChildren()); ++j) { + repr += PTR_ATTRIB(PTR_ATTRIB(_node, GetChild(j)), ToString(trimWhitespaces, indentSize, indent + 1)); } } - switch (_node.GetType()) { + switch (PTR_ATTRIB(_node, GetType())) { case SerializerNodeObject: repr += ident + "}"; break; @@ -93,7 +93,7 @@ class SerializerJson { break; } - if (!_node.IsLast()) repr += ","; + if (!PTR_ATTRIB(_node, IsLast())) repr += ","; // Appending newline only when inside the root node. if (indent != 0) repr += (trimWhitespaces ? "" : "\n"); @@ -169,7 +169,7 @@ class SerializerJson { if (ch == '"') { extracted = ExtractString(data, i + 1); - if (extracted == NULL) { + if (extracted == "") { return GracefulReturn("Unexpected end of file when parsing string", i, root, key); } if (expectingKey) { @@ -177,9 +177,9 @@ class SerializerJson { expectingKey = false; expectingSemicolon = true; } else if (expectingValue) { - current.AddChild(new SerializerNode( - current.GetType() == SerializerNodeObject ? SerializerNodeObjectProperty : SerializerNodeArrayItem, - current, key, SerializerNodeParam::FromString(extracted))); + PTR_ATTRIB(current, AddChild(new SerializerNode( + PTR_ATTRIB(current, GetType()) == SerializerNodeObject ? SerializerNodeObjectProperty : SerializerNodeArrayItem, + current, key, SerializerNodeParam::FromString(extracted)))); #ifdef __debug__ Print("SerializerJson: Value \"" + extracted + "\" for key " + @@ -212,7 +212,7 @@ class SerializerJson { if (!root) root = node; - if (expectingValue) current.AddChild(node); + if (expectingValue) PTR_ATTRIB(current, AddChild(node)); current = node; @@ -221,7 +221,7 @@ class SerializerJson { expectingKey = ch2 != '}'; key = NULL; } else if (ch == '}') { - if (expectingKey || expectingValue || current.GetType() != SerializerNodeObject) { + if (expectingKey || expectingValue || PTR_ATTRIB(current, GetType()) != SerializerNodeObject) { return GracefulReturn("Unexpected end of object", i, root, key); } @@ -231,7 +231,7 @@ class SerializerJson { : "")); #endif - current = current.GetParent(); + current = PTR_ATTRIB(current, GetParent()); expectingValue = false; } else if (ch == '[') { #ifdef __debug__ @@ -246,7 +246,7 @@ class SerializerJson { if (!root) root = node; - if (expectingValue) current.AddChild(node); + if (expectingValue) PTR_ATTRIB(current, AddChild(node)); current = node; expectingValue = ch2 != ']'; @@ -257,11 +257,11 @@ class SerializerJson { Print("SerializerJson: Leaving list for key " + (key != NULL ? ("\"" + key.ToString() + "\"") : "")); #endif - if (expectingKey || expectingValue || current.GetType() != SerializerNodeArray) { + if (expectingKey || expectingValue || PTR_ATTRIB(current, GetType()) != SerializerNodeArray) { return GracefulReturn("Unexpected end of array", i, root, key); } - current = current.GetParent(); + current = PTR_ATTRIB(current, GetParent()); expectingValue = false; } else if (ch >= '0' && ch <= '9') { if (!expectingValue) { @@ -279,9 +279,9 @@ class SerializerJson { (key != NULL ? ("\"" + key.ToString() + "\"") : "")); #endif - current.AddChild(new SerializerNode( - current.GetType() == SerializerNodeObject ? SerializerNodeObjectProperty : SerializerNodeArrayItem, current, - key, value)); + PTR_ATTRIB(current, AddChild(new SerializerNode( + PTR_ATTRIB(current, GetType()) == SerializerNodeObject ? SerializerNodeObjectProperty : SerializerNodeArrayItem, current, + key, value))); expectingValue = false; // Skipping value. @@ -302,9 +302,9 @@ class SerializerJson { // Skipping value. i += ch == 't' ? 3 : 4; - current.AddChild(new SerializerNode( - current.GetType() == SerializerNodeObject ? SerializerNodeObjectProperty : SerializerNodeArrayItem, current, - key, value)); + PTR_ATTRIB(current, AddChild(new SerializerNode( + PTR_ATTRIB(current, GetType()) == SerializerNodeObject ? SerializerNodeObjectProperty : SerializerNodeArrayItem, current, + key, value))); expectingValue = false; // We don't want to delete it twice. @@ -314,7 +314,7 @@ class SerializerJson { return GracefulReturn("Unexpected comma", i, root, key); } - if (current.GetType() == SerializerNodeObject) + if (PTR_ATTRIB(current, GetType()) == SerializerNodeObject) expectingKey = true; else expectingValue = true; diff --git a/SymbolInfo.mqh b/SymbolInfo.mqh index 37a89b42f..ca8efb9c9 100644 --- a/SymbolInfo.mqh +++ b/SymbolInfo.mqh @@ -67,10 +67,10 @@ class SymbolInfo : public Object { Select(); last_tick = GetTick(); // @todo: Test symbol with SymbolExists(_symbol) - sprops.pip_digits = GetPipDigits(_symbol); - sprops.pip_value = GetPipValue(_symbol); - sprops.pts_per_pip = GetPointsPerPip(_symbol); - sprops.vol_digits = GetVolumeDigits(_symbol); + sprops.pip_digits = SymbolInfoStatic::GetPipDigits(_symbol); + sprops.pip_value = SymbolInfoStatic::GetPipValue(_symbol); + sprops.pts_per_pip = SymbolInfoStatic::GetPointsPerPip(_symbol); + sprops.vol_digits = SymbolInfoStatic::GetVolumeDigits(_symbol); } ~SymbolInfo() {} @@ -107,7 +107,7 @@ class SymbolInfo : public Object { /** * Gets the last tick prices (without updating). */ - MqlTick GetLastTick() { return this.last_tick; } + MqlTick GetLastTick() { return last_tick; } /** * The latest known seller's price (ask price) for the current symbol. @@ -116,7 +116,7 @@ class SymbolInfo : public Object { * @see http://docs.mql4.com/predefined/ask */ double Ask() { - return this.GetTick().ask; + return GetTick().ask; // @todo? // Overriding Ask variable to become a function call. @@ -126,12 +126,12 @@ class SymbolInfo : public Object { /** * Updates and gets the latest ask price (best buy offer). */ - double GetAsk() { return this.GetAsk(symbol); } + double GetAsk() { return SymbolInfoStatic::GetAsk(symbol); } /** * Gets the last ask price (without updating). */ - double GetLastAsk() { return this.last_tick.ask; } + double GetLastAsk() { return last_tick.ask; } /** * The latest known buyer's price (offer price, bid price) of the current symbol. @@ -140,7 +140,7 @@ class SymbolInfo : public Object { * @see http://docs.mql4.com/predefined/bid */ double Bid() { - return this.GetTick().bid; + return GetTick().bid; // @todo? // Overriding Bid variable to become a function call. @@ -150,31 +150,31 @@ class SymbolInfo : public Object { /** * Updates and gets the latest bid price (best sell offer). */ - double GetBid() { return this.GetBid(symbol); } + double GetBid() { return SymbolInfoStatic::GetBid(symbol); } /** * Gets the last bid price (without updating). */ - double GetLastBid() { return this.last_tick.bid; } + double GetLastBid() { return last_tick.bid; } /** * Get the last volume for the current last price. * * @see: https://www.mql5.com/en/docs/constants/environment_state/marketinfoconstants */ - ulong GetVolume() { return this.GetTick(this.symbol).volume; } + ulong GetVolume() { return SymbolInfoStatic::GetTick(symbol).volume; } /** * Gets the last volume for the current price (without updating). */ - ulong GetLastVolume() { return this.last_tick.volume; } + ulong GetLastVolume() { return last_tick.volume; } /** * Get summary volume of current session deals. * * @see: https://www.mql5.com/en/docs/constants/environment_state/marketinfoconstants */ - double GetSessionVolume() { return SymbolInfo::GetSessionVolume(symbol); } + double GetSessionVolume() { return SymbolInfoStatic::GetSessionVolume(symbol); } /** * Time of the last quote @@ -183,7 +183,7 @@ class SymbolInfo : public Object { * - https://docs.mql4.com/constants/environment_state/marketinfoconstants * - https://www.mql5.com/en/docs/constants/environment_state/marketinfoconstants#enum_symbol_info_double */ - datetime GetQuoteTime() { return GetQuoteTime(symbol); } + datetime GetQuoteTime() { return SymbolInfoStatic::GetQuoteTime(symbol); } /** * Get current open price depending on the operation type. @@ -193,7 +193,7 @@ class SymbolInfo : public Object { * @return * Current open price. */ - double GetOpenOffer(ENUM_ORDER_TYPE _cmd) { return GetOpenOffer(symbol, _cmd); } + double GetOpenOffer(ENUM_ORDER_TYPE _cmd) { return SymbolInfoStatic::GetOpenOffer(symbol, _cmd); } /** * Get current close price depending on the operation type. @@ -203,7 +203,7 @@ class SymbolInfo : public Object { * @return * Current close price. */ - double GetCloseOffer(ENUM_ORDER_TYPE _cmd) { return GetCloseOffer(symbol, _cmd); } + double GetCloseOffer(ENUM_ORDER_TYPE _cmd) { return SymbolInfoStatic::GetCloseOffer(symbol, _cmd); } /** * Get pip precision. @@ -230,14 +230,14 @@ class SymbolInfo : public Object { * A change of 1 in the least significant digit of the price. * You may also use Point predefined variable for the current symbol. */ - double GetPointSize() { return SymbolInfo::GetPointSize(symbol); } + double GetPointSize() { return SymbolInfoStatic::GetPointSize(symbol); } /** * Return a pip size. * * In most cases, a pip is equal to 1/100 (.01%) of the quote currency. */ - float GetPipSize() { return (float)GetPipSize(symbol); } + float GetPipSize() { return (float)SymbolInfoStatic::GetPipSize(symbol); } /** * Get current spread in points. @@ -259,7 +259,7 @@ class SymbolInfo : public Object { /** * Get current spread in percent. */ - double GetSpreadInPct() { return GetSpreadInPct(symbol); } + double GetSpreadInPct() { return SymbolInfoStatic::GetSpreadInPct(symbol); } /** * Get a tick size in the price value. @@ -268,7 +268,7 @@ class SymbolInfo : public Object { * which could be several points. * In currencies it is equivalent to point size, in metals they are not. */ - float GetTickSize() { return (float)GetTickSize(symbol); } + float GetTickSize() { return (float)SymbolInfoStatic::GetTickSize(symbol); } /** * Get a tick size in points. @@ -276,7 +276,7 @@ class SymbolInfo : public Object { * It is a minimal price change in points. * In currencies it is equivalent to point size, in metals they are not. */ - double GetTradeTickSize() { return GetTradeTickSize(symbol); } + double GetTradeTickSize() { return SymbolInfoStatic::GetTradeTickSize(symbol); } /** * Get a tick value in the deposit currency. @@ -284,7 +284,7 @@ class SymbolInfo : public Object { * @return * Returns the number of base currency units for one pip of movement. */ - double GetTickValue() { return GetTickValue(symbol); } + double GetTickValue() { return SymbolInfoStatic::GetTickValue(symbol); } /** * Get a calculated tick price for a profitable position. @@ -292,7 +292,7 @@ class SymbolInfo : public Object { * @return * Returns the number of base currency units for one pip of movement. */ - double GetTickValueProfit() { return GetTickValueProfit(symbol); } + double GetTickValueProfit() { return SymbolInfoStatic::GetTickValueProfit(symbol); } /** * Get a calculated tick price for a losing position. @@ -300,7 +300,7 @@ class SymbolInfo : public Object { * @return * Returns the number of base currency units for one pip of movement. */ - double GetTickValueLoss() { return GetTickValueLoss(symbol); } + double GetTickValueLoss() { return SymbolInfoStatic::GetTickValueLoss(symbol); } /** * Get count of digits after decimal point for the symbol price. @@ -308,7 +308,7 @@ class SymbolInfo : public Object { * For the current symbol, it is stored in the predefined variable Digits. * */ - uint GetDigits() { return GetDigits(symbol); } + uint GetDigits() { return SymbolInfoStatic::GetDigits(symbol); } /** * Get current spread in points. @@ -320,12 +320,12 @@ class SymbolInfo : public Object { * @return * Return symbol trade spread level in points. */ - uint GetSpread() { return GetSpread(symbol); } + uint GetSpread() { return SymbolInfoStatic::GetSpread(symbol); } /** * Get real spread based on the ask and bid price (in points). */ - unsigned int GetRealSpread() { return GetRealSpread(symbol); } + unsigned int GetRealSpread() { return SymbolInfoStatic::GetRealSpread(symbol); } /** * Minimal indention in points from the current close price to place Stop orders. @@ -347,14 +347,15 @@ class SymbolInfo : public Object { * * @see: https://book.mql4.com/appendix/limits */ - long GetTradeStopsLevel() { return SymbolInfo::SymbolInfoInteger(symbol, SYMBOL_TRADE_STOPS_LEVEL); } + long GetTradeStopsLevel() { return SymbolInfoStatic::SymbolInfoInteger(symbol, SYMBOL_TRADE_STOPS_LEVEL); } /** * Get a contract lot size in the base currency. */ double GetTradeContractSize() { - return SymbolInfo::SymbolInfoDouble(symbol, - SYMBOL_TRADE_CONTRACT_SIZE); // Same as: MarketInfo(symbol, MODE_LOTSIZE); + return SymbolInfoStatic::SymbolInfoDouble( + symbol, + SYMBOL_TRADE_CONTRACT_SIZE); // Same as: MarketInfo(symbol, MODE_LOTSIZE); } /** @@ -365,19 +366,19 @@ class SymbolInfo : public Object { /** * Minimum permitted amount of a lot/volume for a deal. */ - double GetVolumeMin() { return GetVolumeMin(symbol); } + double GetVolumeMin() { return SymbolInfoStatic::GetVolumeMin(symbol); } /** * Maximum permitted amount of a lot/volume for a deal. */ - double GetVolumeMax() { return GetVolumeMax(symbol); } + double GetVolumeMax() { return SymbolInfoStatic::GetVolumeMax(symbol); } /** * Get a lot/volume step for a deal. * * Minimal volume change step for deal execution */ - double GetVolumeStep() { return GetVolumeStep(symbol); } + double GetVolumeStep() { return SymbolInfoStatic::GetVolumeStep(symbol); } /** * Order freeze level in points. @@ -391,7 +392,7 @@ class SymbolInfo : public Object { * * @see: https://book.mql4.com/appendix/limits */ - uint GetFreezeLevel() { return GetFreezeLevel(symbol); } + uint GetFreezeLevel() { return SymbolInfoStatic::GetFreezeLevel(symbol); } /** * Gets flags of allowed order filling modes. @@ -402,7 +403,7 @@ class SymbolInfo : public Object { * - https://www.mql5.com/en/docs/constants/environment_state/marketinfoconstants#symbol_filling_mode * - https://docs.mql4.com/constants/environment_state/marketinfoconstants */ - ENUM_ORDER_TYPE_FILLING GetFillingMode() { return GetFillingMode(symbol); } + ENUM_ORDER_TYPE_FILLING GetFillingMode() { return SymbolInfoStatic::GetFillingMode(symbol); } /** * Buy order swap value @@ -411,7 +412,7 @@ class SymbolInfo : public Object { * - https://docs.mql4.com/constants/environment_state/marketinfoconstants * - https://www.mql5.com/en/docs/constants/environment_state/marketinfoconstants */ - double GetSwapLong() { return GetSwapLong(symbol); } + double GetSwapLong() { return SymbolInfoStatic::GetSwapLong(symbol); } /** * Sell order swap value @@ -420,7 +421,7 @@ class SymbolInfo : public Object { * - https://docs.mql4.com/constants/environment_state/marketinfoconstants * - https://www.mql5.com/en/docs/constants/environment_state/marketinfoconstants */ - double GetSwapShort() { return GetSwapShort(symbol); } + double GetSwapShort() { return SymbolInfoStatic::GetSwapShort(symbol); } /** * Swap calculation model. @@ -429,7 +430,7 @@ class SymbolInfo : public Object { * - https://docs.mql4.com/constants/environment_state/marketinfoconstants * - https://www.mql5.com/en/docs/constants/environment_state/marketinfoconstants */ - ENUM_SYMBOL_SWAP_MODE GetSwapMode() { return GetSwapMode(symbol); } + ENUM_SYMBOL_SWAP_MODE GetSwapMode() { return SymbolInfoStatic::GetSwapMode(symbol); } /** * Returns initial margin (a security deposit) requirements for opening an order. @@ -438,7 +439,7 @@ class SymbolInfo : public Object { * - https://docs.mql4.com/constants/environment_state/marketinfoconstants * - https://www.mql5.com/en/docs/constants/environment_state/marketinfoconstants#enum_symbol_info_double */ - double GetMarginInit(ENUM_ORDER_TYPE _cmd = ORDER_TYPE_BUY) { return GetMarginInit(symbol, _cmd); } + double GetMarginInit(ENUM_ORDER_TYPE _cmd = ORDER_TYPE_BUY) { return SymbolInfoStatic::GetMarginInit(symbol, _cmd); } /** * Return the maintenance margin to maintain open orders. @@ -447,7 +448,9 @@ class SymbolInfo : public Object { * - https://docs.mql4.com/constants/environment_state/marketinfoconstants * - https://www.mql5.com/en/docs/constants/environment_state/marketinfoconstants#enum_symbol_info_double */ - double GetMarginMaintenance(ENUM_ORDER_TYPE _cmd = ORDER_TYPE_BUY) { return GetMarginMaintenance(symbol, _cmd); } + double GetMarginMaintenance(ENUM_ORDER_TYPE _cmd = ORDER_TYPE_BUY) { + return SymbolInfoStatic::GetMarginMaintenance(symbol, _cmd); + } /** * Gets symbol entry.