Skip to content

Commit

Permalink
Fixes compilation errors in MT4 and MT5.
Browse files Browse the repository at this point in the history
  • Loading branch information
nseam committed Jun 27, 2024
1 parent 3228d70 commit 63f1ddb
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 35 deletions.
5 changes: 3 additions & 2 deletions Candle.struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,12 @@ struct CandleOCTOHLC : CandleOHLC<T> {
if (!ContainsTimeMs(_timestamp_ms)) {
Print("Error: Cannot update candle. Given time doesn't fit in candle's time-frame! Given time ", _timestamp_ms,
", but candle range is ", (long)start_time * 1000, " - ", (long)(start_time + length) * 1000, ".");
long _ms;
if (_timestamp_ms < (long)start_time * 1000) {
long _ms = (long)start_time * 1000 - _timestamp_ms;
_ms = (long)start_time * 1000 - _timestamp_ms;
Print("Looks like given time is ", _ms, " ms (", (double)_ms / 1000, " s) before the candle starts.");
} else {
long _ms = _timestamp_ms - (long)(start_time + length) * 1000;
_ms = _timestamp_ms - (long)(start_time + length) * 1000;
Print("Looks like given time is ", _ms, " ms (", (double)_ms / 1000, "s) after the candle ends.");
}
DebugBreak();
Expand Down
5 changes: 2 additions & 3 deletions Indicator/IndicatorCandle.provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,10 @@ class ItemsHistoryCandleProvider : public ItemsHistoryItemProvider<CandleOCTOHLC
* Retrieves given number of items starting from the given microseconds or index (inclusive). "_dir" identifies if we
* want previous or next items from selected starting point.
*/
void GetItems(ItemsHistory<CandleOCTOHLC<TV>, ItemsHistoryCandleProvider<TV>>* _history, long _from_time_ms,
bool GetItems(ItemsHistory<CandleOCTOHLC<TV>, ItemsHistoryCandleProvider<TV>>* _history, long _from_time_ms,
ENUM_ITEMS_HISTORY_DIRECTION _dir, int _num_items, ARRAY_REF(CandleOCTOHLC<TV>, _out_arr)) {
// Method is called if there is a missing item (candle) in the history. We need to regenerate it.
Print("Error: Retrieving items by this item provider is not implemented!");
DebugBreak();
return false;
}

/**
Expand Down
18 changes: 15 additions & 3 deletions Indicator/IndicatorRenko.provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
#define INDICATOR_RENKO_PROVIDER_H

#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

/**
Expand Down Expand Up @@ -68,12 +68,24 @@ class ItemsHistoryRenkoCandleProvider : public ItemsHistoryCandleProvider<TV> {
* Retrieves given number of items starting from the given microseconds or index (inclusive). "_dir" identifies if we
* want previous or next items from selected starting point.
*/
void GetItems(ItemsHistory<CandleOCTOHLC<TV>, ItemsHistoryRenkoCandleProvider<TV>>* _history, long _from_time_ms,
bool GetItems(ItemsHistory<CandleOCTOHLC<TV>, ItemsHistoryRenkoCandleProvider<TV>>* _history, long _from_time_ms,
ENUM_ITEMS_HISTORY_DIRECTION _dir, int _num_items, ARRAY_REF(CandleOCTOHLC<TV>, _out_arr)) {
// Method is called if there is a missing item (candle) in the history. We need to regenerate it.

Print("IndicatorRenko is not yet implemented!");
DebugBreak();
return false;
}

/**
* Retrieves items between given indices (both indices inclusive). Should return false if retrieving items by this
* method is not available.
*/
bool GetItems(ItemsHistory<CandleOCTOHLC<TV>, ItemsHistoryRenkoCandleProvider<TV>>* _history, int _start_index,
int _end_index, ARRAY_REF(CandleOCTOHLC<TV>, _out_arr)) {
Print("IndicatorRenko is not yet implemented!");
DebugBreak();
return false;
}
};

Expand Down
2 changes: 1 addition & 1 deletion Indicator/IndicatorTf.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class IndicatorTf : public IndicatorCandle<TFP, double, ItemsHistoryTfCandleProv
* Sets indicator's time-frame.
*/
void SetTf(ENUM_TIMEFRAMES _tf) { THIS_ATTR iparams.tf.SetTf(_tf); }

/**
* Returns current tick index (incremented every OnTick()).
*/
Expand Down
2 changes: 1 addition & 1 deletion Indicators/Account/Indi_AccountStats.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class Indi_AccountStats : public Indicator<Indi_AccountStats_Params> {
*/
virtual void OnDataSourceEntry(IndicatorDataEntry &entry,
ENUM_INDI_EMITTED_ENTRY_TYPE type = INDI_EMITTED_ENTRY_TYPE_PARENT) override {
Indicator<TS>::OnDataSourceEntry(entry, type);
Indicator<Indi_AccountStats_Params>::OnDataSourceEntry(entry, type);

if (type != INDI_EMITTED_ENTRY_TYPE_CANDLE) {
return;
Expand Down
2 changes: 1 addition & 1 deletion Indicators/Tick/Indi_TickMt.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ class Indi_TickMt : public IndicatorTick<Indi_TickMtParams, double, ItemsHistory
EmitEntry(_entry, INDI_EMITTED_ENTRY_TYPE_TICK);
// Appending tick into the history.
AppendEntry(_entry);

return _ask != WRONG_VALUE && _bid != WRONG_VALUE;
}
};
5 changes: 0 additions & 5 deletions Object.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
#ifndef OBJECT_MQH
#define OBJECT_MQH

#define nullptr NULL

// Includes.
#include "Object.enum.h"
#include "Object.extern.h"
Expand All @@ -37,14 +35,11 @@
* Class to deal with objects.
*/
class Object : public Dynamic {

protected:

void *obj;
long id;

public:

/**
* Class constructor.
*/
Expand Down
16 changes: 8 additions & 8 deletions Platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
*/

#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

// Includes.
#include "Deal.enum.h"
#include "Order.struct.h"
#include "Platform.define.h"
// Includes.
#include "Deal.enum.h"
#include "Order.struct.h"
#include "Platform.define.h"

/**
* Extern declarations for C++.
Expand Down Expand Up @@ -58,7 +58,7 @@ extern int Bars(CONST_REF_TO(string) _symbol, ENUM_TIMEFRAMES _tf);
#define PLATFORM_DEFAULT_INDICATOR_TICK Indi_TickMt
#define PLATFORM_DEFAULT_INDICATOR_TF Indi_TfMt
#else
#include "Indicators/Tick/Indi_TickProvider.h"
#include "Indicators/Tick/Indi_TickProvider.h"
#define PLATFORM_DEFAULT_INDICATOR_TICK Indi_TickRandom
#define PLATFORM_DEFAULT_INDICATOR_TF IndicatorTfDummy
#endif
Expand Down Expand Up @@ -871,4 +871,4 @@ datetime StructToTime(MqlDateTime &dt_struct) {
class PlatformAutoInitializer {
public:
PlatformAutoInitializer() { Platform::Init(); }
} _platform_auto_initializer;
} _platform_auto_initializer;
23 changes: 12 additions & 11 deletions Std.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
#define MAKE_REF_FROM_PTR(TYPE, NAME, PTR) TYPE* NAME = PTR
#define REF_DEREF .Ptr().
#define int64 long
#define nullptr NULL
#else
#define GET_PTR(obj) (*obj)
#define THIS_ATTR this->
Expand Down Expand Up @@ -122,18 +123,18 @@
*/
#define CONST_REF_TO(T) const T&

/**
/**
* Reference to the array.
*
* @usage
* ARRAY_REF(<type of the array items>, <name of the variable>)
*/
#define ARRAY_TYPE(T) _cpp_array<T>
#define ARRAY_REF(T, N) ARRAY_TYPE(T) & N
#define FIXED_ARRAY_REF(T, N, S) T(&N)[S]
* Reference to the array.
*
* @usage
* ARRAY_REF(<type of the array items>, <name of the variable>)
*/
#define ARRAY_TYPE(T) _cpp_array<T>
#define ARRAY_REF(T, N) ARRAY_TYPE(T) & N
#define FIXED_ARRAY_REF(T, N, S) T(&N)[S]

#define CONST_ARRAY_REF(T, N) const _cpp_array<T>& N
#define CONST_ARRAY_REF(T, N) const _cpp_array<T>& N
#define CONST_ARRAY_REF(T, N) const _cpp_array<T>& N

/**
Expand Down Expand Up @@ -568,4 +569,4 @@ struct AsSeriesReleaseEnsurer {
SET_BUFFER_AS_SERIES_RELEASE_ENSURER_END(7);
#define RELEASE_BUFFER8(A, B, C, D, E, F, G, H) \
RELEASE_BUFFER8_NO_ENSURE(A, B, C, D, E, F, G, H); \
SET_BUFFER_AS_SERIES_RELEASE_ENSURER_END(8);
SET_BUFFER_AS_SERIES_RELEASE_ENSURER_END(8);

0 comments on commit 63f1ddb

Please sign in to comment.