Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EMCC compatibility fixes. #779

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Exchange/Account/Account.struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
*/

#ifndef __MQL__
// Allows the preprocessor to include a header file when it is needed.
#pragma once
// Allows the preprocessor to include a header file when it is needed.
#pragma once
#endif

// Forward class declaration.
Expand Down Expand Up @@ -123,7 +123,7 @@ struct AccountParams {
// Default constructor.
AccountParams(int _login = 0, string _name = "Current", string _currency = "USD", string _company = "Unknown",
string _server = "Unknown")
: company(_company), currency(_currency), login(_login), name(_name), server(_server) {}
: login(_login), company(_company), currency(_currency), name(_name), server(_server) {}
// Constructor based on JSON string.
AccountParams(string _entry) { SerializerConverter::FromString<SerializerJson>(_entry).ToStruct(THIS_REF); }
// Copy constructor.
Expand Down
6 changes: 3 additions & 3 deletions Exchange/Account/AccountMt.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class AccountMt : public AccountBase {
* Returns margin value of the current account.
*/
static double AccountMargin() { return AccountInfoDouble(ACCOUNT_MARGIN); }
float GetMarginUsed() const {
float GetMarginUsed() const override {
// @todo: Adds caching.
// return UpdateStats(ACC_MARGIN_USED, AccountMargin());
return (float)AccountMt::AccountMargin();
Expand Down Expand Up @@ -616,7 +616,7 @@ class AccountMt : public AccountBase {
/**
* Returns text info about the account.
*/
string const ToString() {
string const ToString() override {
return StringFormat(
"Type: %s, Server/Company/Name: %s/%s/%s, Currency: %s, Balance: %g, Credit: %g, Equity: %g, Profit: %g, "
"Margin Used/Free/Avail: %g(%.1f%%)/%g/%g, Orders limit: %g: Leverage: 1:%d, StopOut Level: %d (Mode: %d)",
Expand All @@ -639,7 +639,7 @@ class AccountMt : public AccountBase {
/**
* Returns serialized representation of the object instance.
*/
SerializerNodeType Serialize(Serializer &_s) {
SerializerNodeType Serialize(Serializer &_s) override {
AccountEntry _entry = GetEntry();
_s.PassStruct(THIS_REF, "account-entry", _entry, SERIALIZER_FIELD_FLAG_DYNAMIC);
return SerializerNodeObject;
Expand Down
8 changes: 4 additions & 4 deletions Exchange/Exchange.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class Exchange : public Taskable<DataParamEntry> {
/**
* Checks a condition.
*/
bool Check(const TaskConditionEntry &_entry) {
bool Check(const TaskConditionEntry &_entry) override {
bool _result = true;
switch (_entry.GetId()) {
default:
Expand All @@ -142,7 +142,7 @@ class Exchange : public Taskable<DataParamEntry> {
/**
* Gets a data param entry.
*/
DataParamEntry Get(const TaskGetterEntry &_entry) {
DataParamEntry Get(const TaskGetterEntry &_entry) override {
DataParamEntry _result;
switch (_entry.GetId()) {
default:
Expand All @@ -154,7 +154,7 @@ class Exchange : public Taskable<DataParamEntry> {
/**
* Runs an action.
*/
bool Run(const TaskActionEntry &_entry) {
bool Run(const TaskActionEntry &_entry) override {
bool _result = true;
switch (_entry.GetId()) {
case EXCHANGE_ACTION_ADD_ACCOUNT:
Expand All @@ -176,7 +176,7 @@ class Exchange : public Taskable<DataParamEntry> {
/**
* Sets an entry value.
*/
bool Set(const TaskSetterEntry &_entry, const DataParamEntry &_entry_value) {
bool Set(const TaskSetterEntry &_entry, const DataParamEntry &_entry_value) override {
bool _result = true;
switch (_entry.GetId()) {
default:
Expand Down
16 changes: 10 additions & 6 deletions Exchange/Exchange.struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
*/

#ifndef __MQL__
// Allows the preprocessor to include a header file when it is needed.
#pragma once
// Allows the preprocessor to include a header file when it is needed.
#pragma once
#endif

// Includes.
Expand Down Expand Up @@ -55,28 +55,32 @@ struct ExchangeParams {
// Getters.
template <typename T>
T Get(ENUM_EXCHANGE_PARAM _param) {
T _out;
switch (_param) {
case EXCHANGE_PARAM_ID:
return (T)id;
case EXCHANGE_PARAM_NAME:
// return (T)name; // @todo
ConvertBasic::Convert(name, _out);
return _out;
default:
Alert("Unsupported param: ", EnumToString(_param));
break;
}
SetUserError(ERR_INVALID_PARAMETER);
return WRONG_VALUE;
}
// Setters.
template <typename T>
void Set(ENUM_TRADE_PARAM _param, T _value) {
void Set(ENUM_EXCHANGE_PARAM _param, T _value) {
switch (_param) {
case EXCHANGE_PARAM_ID:
ConvertBasic::Convert(_value, id);
return;
break;
case EXCHANGE_PARAM_NAME:
ConvertBasic::Convert(_value, name);
return;
break;
default:
Alert("Unsupported param: ", EnumToString(_param));
break;
}
SetUserError(ERR_INVALID_PARAMETER);
Expand Down
6 changes: 3 additions & 3 deletions Indicator/Indicator.struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ struct IndicatorParams {
/* Special methods */
// Constructor.
IndicatorParams(ENUM_INDICATOR_TYPE _itype = INDI_NONE, ENUM_TIMEFRAMES _tf = PERIOD_CURRENT, string _name = "")
: bps(0),
custom_indi_name(""),
: custom_indi_name(""),
name(_name),
shift(0),
bps(0),
// max_modes(_max_modes),
// max_buffers(10),
// idstype(_idstype),
Expand All @@ -84,7 +84,7 @@ struct IndicatorParams {
itype(_itype) {
Init();
};
IndicatorParams(string _name) : bps(0), custom_indi_name(""), name(_name), shift(0) { Init(); };
IndicatorParams(string _name) : custom_indi_name(""), name(_name), shift(0), bps(0) { Init(); };
/* Getters */
template <typename T>
T Get(STRUCT_ENUM(IndicatorParams, ENUM_INDI_PARAMS_PROP) _prop) const {
Expand Down
19 changes: 9 additions & 10 deletions Indicator/IndicatorData.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ struct ExternInstantiateIndicatorBufferValueStorageDouble {
};

// Includes.
#include "../Platform/Chart/Bar.struct.h"
#include "../Exchange/SymbolInfo/SymbolInfo.struct.h"
#include "../Platform/Chart/Bar.struct.h"
#include "../Platform/Chart/Chart.struct.tf.h"
#include "../Storage/Cache/IndiBufferCache.h"
#include "../Storage/Flags.struct.h"
Expand Down Expand Up @@ -220,7 +220,7 @@ class IndicatorData : public IndicatorBase {
/**
* Get full name of the indicator (with "over ..." part).
*/
string GetFullName() {
string GetFullName() override {
int _max_modes = Get<int>(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_MAX_MODES));
string _mode;

Expand Down Expand Up @@ -408,13 +408,13 @@ class IndicatorData : public IndicatorBase {
*/
template <typename T>
double GetMax(int start_bar = 0, int count = WHOLE_ARRAY) {
double max = NULL;
double max = -DBL_MAX;
int last_bar = count == WHOLE_ARRAY ? (int)(GetBarShift(GetLastBarTime())) : (start_bar + count - 1);
int _max_modes = Get<int>(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_MAX_MODES));

for (int shift = start_bar; shift <= last_bar; ++shift) {
double value = GetEntry(shift).GetMax<T>(_max_modes);
if (max == NULL || value > max) {
if (max == -DBL_MAX || value > max) {
max = value;
}
}
Expand Down Expand Up @@ -1323,7 +1323,7 @@ class IndicatorData : public IndicatorBase {
/**
* Returns the indicator's entry value.
*/
virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) = 0;
virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) override = 0;

/**
* Returns the shift of the maximum value over a specific number of periods depending on type.
Expand Down Expand Up @@ -1386,7 +1386,7 @@ class IndicatorData : public IndicatorBase {
/**
* Get name of the indicator.
*/
virtual string GetName() { return EnumToString(GetType()); }
virtual string GetName() override { return EnumToString(GetType()); }

/**
* Gets open price for a given, optional shift.
Expand All @@ -1404,7 +1404,7 @@ class IndicatorData : public IndicatorBase {
/**
* Gets OHLC price values.
*/
virtual BarOHLC GetOHLC(int _rel_shift = 0) {
virtual BarOHLC GetOHLC(int _rel_shift = 0) override {
if (GetCandle() == THIS_PTR) {
Alert(GetFullName(), " candle indicator must override ", __FUNCTION__, "()!");
DebugBreak();
Expand Down Expand Up @@ -1608,7 +1608,6 @@ class IndicatorData : public IndicatorBase {
}

/**
/**
* Traverses source indicators' hierarchy and tries to find Ask, Bid, Spread,
* Volume and Tick Volume-featured indicator. IndicatorTick satisfies such
* requirements.
Expand Down Expand Up @@ -2158,12 +2157,12 @@ class IndicatorData : public IndicatorBase {
/**
* Converts relative shift into absolute one.
*/
virtual int ToAbsShift(int _rel_shift) = 0;
virtual int ToAbsShift(int _rel_shift) override = 0;

/**
* Converts absolute shift into relative one.
*/
virtual int ToRelShift(int _abs_shift) = 0;
virtual int ToRelShift(int _abs_shift) override = 0;

/**
* Loads and validates built-in indicators whose can be used as data source.
Expand Down
8 changes: 3 additions & 5 deletions Math/Math.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
*/

#ifndef __MQL__
// Allows the preprocessor to include a header file when it is needed.
#pragma once
// Allows the preprocessor to include a header file when it is needed.
#pragma once
#endif

// Includes.
Expand Down Expand Up @@ -264,7 +264,7 @@ class Math {
int data_count = ArraySize(probability);
if (data_count == 0) return false;

int error_code = 0, i;
int i;
ArrayResize(result, data_count);

//--- case sigma==0
Expand Down Expand Up @@ -402,8 +402,6 @@ class Math {
return true;
}

int err_code = 0;

for (i = 0; i < data_count; i++) {
result[i] = RandomNonZero();
}
Expand Down
12 changes: 0 additions & 12 deletions Math/Matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -2538,13 +2538,9 @@ class Matrix {

void FromString(string text) {
ARRAY(MatrixDimension<X>*, _dimensions), *_root_dimension = NULL;
int _dimensions_length[MATRIX_DIMENSIONS] = {0, 0, 0, 0, 0};
int i, _number_start_pos;
bool _had_values;
X _number;
bool _expecting_value_or_child = true;
bool _expecting_comma = false;
bool _expecting_end = false;

for (i = 0; i < StringLen(text); ++i) {
unsigned short _char = StringGetCharacter(text, i), c;
Expand All @@ -2556,8 +2552,6 @@ class Matrix {
return;
}

_had_values = false;

if (ArraySize(_dimensions) != 0) {
_dimensions[ArraySize(_dimensions) - 1].type = MATRIX_DIMENSION_TYPE_CONTAINERS;
}
Expand All @@ -2574,13 +2568,11 @@ class Matrix {
}

_expecting_value_or_child = true;
_expecting_end = true;
break;

case ']':
ArrayResize(_dimensions, ArraySize(_dimensions) - 1, MATRIX_DIMENSIONS);
_expecting_value_or_child = true;
_expecting_comma = false;
break;

case '0':
Expand Down Expand Up @@ -2609,15 +2601,11 @@ class Matrix {
i -= 2;
_dimensions[ArraySize(_dimensions) - 1].type = MATRIX_DIMENSION_TYPE_VALUES;
_dimensions[ArraySize(_dimensions) - 1].AddValue(_number);
_expecting_end = true;
_expecting_value_or_child = true;
_expecting_comma = false;
break;

case ',':
_expecting_value_or_child = true;
_expecting_comma = false;
_expecting_end = false;
break;
case ' ':
case '\t':
Expand Down
16 changes: 7 additions & 9 deletions Platform/Order.h
Original file line number Diff line number Diff line change
Expand Up @@ -1774,8 +1774,6 @@ class Order : public SymbolInfo {
* Update specific double value of the current order.
*/
bool RefreshDummy(ENUM_ORDER_PROPERTY_DOUBLE _prop_id) {
bool _result = false;
double _value = WRONG_VALUE;
ResetLastError();
switch (_prop_id) {
case ORDER_PRICE_CURRENT:
Expand Down Expand Up @@ -2850,14 +2848,14 @@ class Order : public SymbolInfo {
bool ExecuteAction(ENUM_ORDER_ACTION _action, ARRAY_REF(DataParamEntry, _args)) {
switch (_action) {
case ORDER_ACTION_CLOSE:
switch (oparams.dummy) {
case false:
return ArraySize(_args) > 0 ? OrderClose((ENUM_ORDER_REASON_CLOSE)_args[0].integer_value)
: OrderClose(ORDER_REASON_CLOSED_BY_ACTION);
case true:
return ArraySize(_args) > 0 ? OrderCloseDummy((ENUM_ORDER_REASON_CLOSE)_args[0].integer_value)
: OrderCloseDummy(ORDER_REASON_CLOSED_BY_ACTION);
if (oparams.dummy) {
return ArraySize(_args) > 0 ? OrderCloseDummy((ENUM_ORDER_REASON_CLOSE)_args[0].integer_value)
: OrderCloseDummy(ORDER_REASON_CLOSED_BY_ACTION);
} else {
return ArraySize(_args) > 0 ? OrderClose((ENUM_ORDER_REASON_CLOSE)_args[0].integer_value)
: OrderClose(ORDER_REASON_CLOSED_BY_ACTION);
}
break;
case ORDER_ACTION_OPEN:
return !oparams.dummy ? OrderSend() >= 0 : OrderSendDummy() >= 0;
case ORDER_ACTION_COND_CLOSE_ADD:
Expand Down
Loading
Loading