Skip to content

Commit

Permalink
WIP. Fixing Emscripten compilation errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
nseam committed Jan 14, 2023
1 parent 36993ce commit efa69da
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 9 deletions.
4 changes: 4 additions & 0 deletions Deal.enum.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
15 changes: 8 additions & 7 deletions Order.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,10 @@ class Order : public SymbolInfo {
int _num = oparams.Get<int>(ORDER_PARAM_COND_CLOSE_NUM);
for (int _ci = 0; _ci < _num; _ci++) {
ENUM_ORDER_CONDITION _cond = oparams.Get<ENUM_ORDER_CONDITION>(ORDER_PARAM_COND_CLOSE, _ci);
DataParamEntry _cond_args[1];
_cond_args[0] = oparams.Get<long>(ORDER_PARAM_COND_CLOSE_ARG_VALUE, _ci);
_result |= _result || Order::CheckCondition(_cond, _cond_args);
ARRAY(DataParamEntry, _cond_args);
DataParamEntry _item0 = oparams.Get<long>(ORDER_PARAM_COND_CLOSE_ARG_VALUE, _ci);
ArrayPush(_cond_args, _item0);
_result |= Order::CheckCondition(_cond, _cond_args);
}
}
return _result;
Expand Down Expand Up @@ -470,7 +471,7 @@ class Order : public SymbolInfo {
#endif
}
datetime GetOpenTime() {
if (odata.Get<datetime>(ORDER_PROP_TIME_OPENED) == 0) {
if (odata.Get<datetime>(ORDER_PROP_TIME_OPENED) == (datetime)0) {
OrderSelect();
odata.Set<datetime>(ORDER_PROP_TIME_OPENED, Order::OrderOpenTime());
}
Expand Down Expand Up @@ -503,7 +504,7 @@ class Order : public SymbolInfo {
return (datetime)_result;
#endif
}
datetime GetCloseTime() { return IsClosed() ? odata.Get<datetime>(ORDER_PROP_TIME_CLOSED) : 0; }
datetime GetCloseTime() { return IsClosed() ? odata.Get<datetime>(ORDER_PROP_TIME_CLOSED) : (datetime)0; }

/**
* Returns comment of the currently selected order/position.
Expand Down Expand Up @@ -695,7 +696,7 @@ class Order : public SymbolInfo {
case ORDER_TP:
return OrderTakeProfit();
}
return NULL;
return 0;
}

/**
Expand Down Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions Platform.extern.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
// Allows the preprocessor to include a header file when it is needed.
#pragma once

// Includes.
#include "Deal.enum.h"

template <typename... Args>
double iCustom(string symbol, int timeframe, string name, Args... args) {
Alert(__FUNCSIG__, " it not implemented!");
Expand All @@ -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
46 changes: 44 additions & 2 deletions Platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -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++.
Expand Down Expand Up @@ -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

/**
Expand Down

0 comments on commit efa69da

Please sign in to comment.