From efa69daba8e2b380993b2d5f603f7f9c3920195f Mon Sep 17 00:00:00 2001 From: Adrian Kierzkowski Date: Sat, 14 Jan 2023 13:47:56 +0100 Subject: [PATCH] WIP. Fixing Emscripten compilation errors. --- Deal.enum.h | 4 ++++ Order.mqh | 15 ++++++++------- Platform.extern.h | 21 +++++++++++++++++++++ Platform.h | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 77 insertions(+), 9 deletions(-) diff --git a/Deal.enum.h b/Deal.enum.h index ceef21a7f..41c3ca747 100644 --- a/Deal.enum.h +++ b/Deal.enum.h @@ -26,6 +26,10 @@ */ #ifndef __MQL__ + +// Allows the preprocessor to include a header file when it is needed. +#pragma once + enum ENUM_DEAL_TYPE { DEAL_TYPE_BUY, DEAL_TYPE_SELL, diff --git a/Order.mqh b/Order.mqh index b0092bee5..b7508eace 100644 --- a/Order.mqh +++ b/Order.mqh @@ -305,9 +305,10 @@ class Order : public SymbolInfo { int _num = oparams.Get(ORDER_PARAM_COND_CLOSE_NUM); for (int _ci = 0; _ci < _num; _ci++) { ENUM_ORDER_CONDITION _cond = oparams.Get(ORDER_PARAM_COND_CLOSE, _ci); - DataParamEntry _cond_args[1]; - _cond_args[0] = oparams.Get(ORDER_PARAM_COND_CLOSE_ARG_VALUE, _ci); - _result |= _result || Order::CheckCondition(_cond, _cond_args); + ARRAY(DataParamEntry, _cond_args); + DataParamEntry _item0 = oparams.Get(ORDER_PARAM_COND_CLOSE_ARG_VALUE, _ci); + ArrayPush(_cond_args, _item0); + _result |= Order::CheckCondition(_cond, _cond_args); } } return _result; @@ -470,7 +471,7 @@ class Order : public SymbolInfo { #endif } datetime GetOpenTime() { - if (odata.Get(ORDER_PROP_TIME_OPENED) == 0) { + if (odata.Get(ORDER_PROP_TIME_OPENED) == (datetime)0) { OrderSelect(); odata.Set(ORDER_PROP_TIME_OPENED, Order::OrderOpenTime()); } @@ -503,7 +504,7 @@ class Order : public SymbolInfo { return (datetime)_result; #endif } - datetime GetCloseTime() { return IsClosed() ? odata.Get(ORDER_PROP_TIME_CLOSED) : 0; } + datetime GetCloseTime() { return IsClosed() ? odata.Get(ORDER_PROP_TIME_CLOSED) : (datetime)0; } /** * Returns comment of the currently selected order/position. @@ -695,7 +696,7 @@ class Order : public SymbolInfo { case ORDER_TP: return OrderTakeProfit(); } - return NULL; + return 0; } /** @@ -1003,7 +1004,7 @@ class Order : public SymbolInfo { * * @see: https://docs.mql4.com/trading/orderdelete */ - static bool OrderDelete(unsigned long _ticket, color _color = NULL) { + static bool OrderDelete(unsigned long _ticket, color _color = color()) { #ifdef __MQL4__ return ::OrderDelete((int)_ticket, _color); #else diff --git a/Platform.extern.h b/Platform.extern.h index 0c2ea98d6..81cd3a12a 100644 --- a/Platform.extern.h +++ b/Platform.extern.h @@ -24,6 +24,9 @@ // Allows the preprocessor to include a header file when it is needed. #pragma once +// Includes. +#include "Deal.enum.h" + template double iCustom(string symbol, int timeframe, string name, Args... args) { Alert(__FUNCSIG__, " it not implemented!"); @@ -45,4 +48,22 @@ extern int BarsCalculated(int indicator_handle); */ extern int CopyBuffer(int indicator_handle, int buffer_num, int start_pos, int count, ARRAY_REF(double, buffer)); +extern unsigned long PositionGetTicket(int _index); + +extern long PositionGetInteger(ENUM_POSITION_PROPERTY_INTEGER property_id); + +extern double PositionGetDouble(ENUM_POSITION_PROPERTY_DOUBLE property_id); + +extern string PositionGetString(ENUM_POSITION_PROPERTY_STRING property_id); + +extern int HistoryDealsTotal(); + +extern unsigned long HistoryDealGetTicket(int index); + +extern long HistoryDealGetInteger(unsigned long ticket_number, ENUM_DEAL_PROPERTY_INTEGER property_id); + +extern double HistoryDealGetDouble(unsigned long ticket_number, ENUM_DEAL_PROPERTY_DOUBLE property_id); + +extern string HistoryDealGetString(unsigned long ticket_number, ENUM_DEAL_PROPERTY_STRING property_id); + #endif diff --git a/Platform.h b/Platform.h index f8d3a0a44..16e026f55 100644 --- a/Platform.h +++ b/Platform.h @@ -23,9 +23,9 @@ #ifndef __MQL__ // Allows the preprocessor to include a header file when it is needed. #pragma once -#endif -#ifndef __MQL__ +// Includes. +#include "Deal.enum.h" /** * Extern declarations for C++. @@ -383,6 +383,48 @@ int CopyBuffer(int indicator_handle, int buffer_num, int start_pos, int count, A Print("Not yet implemented: ", __FUNCTION__, " returns 0."); } +unsigned long PositionGetTicket(int _index) { Print("Not yet implemented: ", __FUNCTION__, " returns 0."); } + +long PositionGetInteger(ENUM_POSITION_PROPERTY_INTEGER property_id) { + Print("Not yet implemented: ", __FUNCTION__, " returns 0."); + return 0; +} + +double PositionGetDouble(ENUM_POSITION_PROPERTY_DOUBLE property_id) { + Print("Not yet implemented: ", __FUNCTION__, " returns 0."); + return 0; +} + +string PositionGetString(ENUM_POSITION_PROPERTY_STRING property_id) { + Print("Not yet implemented: ", __FUNCTION__, " returns empty string."); + return ""; +} + +int HistoryDealsTotal() { + Print("Not yet implemented: ", __FUNCTION__, " returns 0."); + return 0; +} + +unsigned long HistoryDealGetTicket(int index) { + Print("Not yet implemented: ", __FUNCTION__, " returns 0."); + return 0; +} + +long HistoryDealGetInteger(unsigned long ticket_number, ENUM_DEAL_PROPERTY_INTEGER property_id) { + Print("Not yet implemented: ", __FUNCTION__, " returns 0."); + return 0; +} + +double HistoryDealGetDouble(unsigned long ticket_number, ENUM_DEAL_PROPERTY_DOUBLE property_id) { + Print("Not yet implemented: ", __FUNCTION__, " returns 0."); + return 0; +} + +string HistoryDealGetString(unsigned long ticket_number, ENUM_DEAL_PROPERTY_STRING property_id) { + Print("Not yet implemented: ", __FUNCTION__, " returns empty string."); + return 0; +} + #endif /**