Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/v3.006-dev-fixme' into v3.006-dev
Browse files Browse the repository at this point in the history
* origin/v3.006-dev-fixme: (26 commits)
  More of C++/MT4/MT5 error fixes.
  Looks like C++/MT4/MT5 errors are fixed.
  Looks like C++/MT4 errors are fixed. Need some additional fixed for MT5.
  C++ and MQL fixes. Cleaned up Std.h regarding array/reference macros. Added Visual Studio file exclusions into .gitignore.
  C++ tests now compiles.
  WIP. Fixing C++ errors. One step further.
  WIP. Fixing C++ errors. Closer to the end.
  WIP. Fixing C++ errors. Closer to the end.
  WIP. Fixing C++ errors. Stuck on ValueStorage's macros.
  Adds PriceRange/tests/Makefile
  Moves global functions at the end for C++ compatibility
  A little step forward in fixing C++ compile errors.
  Another step in fixing C++ compile errors.
  Adds more tests for indicators
  Makefile: Improves syntax
  Adds more tests for indicators
  Adds CPP tests for EA, Log, Refs, Strategy and Trade
  Database: Code improvements and reformat
  Makefile: Fail when make subprocess also fail
  Indicators: Code reformats
  ...
  • Loading branch information
kenorb committed Jul 20, 2023
2 parents 6e2b81f + a1a484c commit 98c546f
Show file tree
Hide file tree
Showing 343 changed files with 6,624 additions and 2,411 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test-indicators-pricerange.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ jobs:
test:
- Indi_Bands.test
- Indi_Envelopes.test
- Indi_Pivot.test
- Indi_SAR.test
steps:
- uses: actions/download-artifact@v3
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/test-indicators.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ jobs:
- Indi_Momentum.test
- Indi_OBV.test
- Indi_OsMA.test
- Indi_Pivot.test
- Indi_PriceChannel.test
- Indi_PriceFeeder.test
- Indi_PriceVolumeTrend.test
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ docs/api/build
.DS_Store

docs/build
.vs
x64
*.sln
*.vcx*
12 changes: 12 additions & 0 deletions Bar.struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@ struct BarOHLC
low = fmin(low, _prices[i]);
}
}
BarOHLC(CONST_FIXED_ARRAY_REF(double, _prices, 4), datetime _time = 0) : time(_time) {
_time = _time == (datetime)0 ? TimeCurrent() : _time;
int _size = 4;
close = _prices[0];
open = _prices[_size - 1];
high = fmax(close, open);
low = fmin(close, open);
for (int i = 0; i < _size; i++) {
high = fmax(high, _prices[i]);
low = fmin(low, _prices[i]);
}
}
// Struct methods.
// Getters
bool GetPivots(ENUM_PP_TYPE _type, double &_pp, double &_r1, double &_r2, double &_r3, double &_r4, double &_s1,
Expand Down
20 changes: 10 additions & 10 deletions Candle.struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,14 +231,14 @@ struct CandleOCTOHLC : CandleOHLC<T> {
int length;

// Open and close timestamps of ticks that were part of this candle.
long open_timestamp_ms, close_timestamp_ms;
int64 open_timestamp_ms, close_timestamp_ms;

// Number of ticks which formed the candle. Also known as volume.
int volume;

// Struct constructor.
CandleOCTOHLC(T _open = 0, T _high = 0, T _low = 0, T _close = 0, int _start_time = -1, int _length = 0,
long _open_timestamp_ms = -1, long _close_timestamp_ms = -1, int _volume = 0)
int64 _open_timestamp_ms = -1, int64 _close_timestamp_ms = -1, int _volume = 0)
: CandleOHLC<T>(_open, _high, _low, _close),
is_complete(true),
start_time(_start_time),
Expand All @@ -264,7 +264,7 @@ struct CandleOCTOHLC : CandleOHLC<T> {
/**
* Initializes candle with a given start time, lenght in seconds, first tick's timestamp and its price.
*/
void Init(int _start_time, int _length, long _timestamp_ms = -1, T _price = 0) {
void Init(int _start_time, int _length, int64 _timestamp_ms = -1, T _price = 0) {
is_complete = false;
start_time = _start_time;
length = _length;
Expand All @@ -277,7 +277,7 @@ struct CandleOCTOHLC : CandleOHLC<T> {
/**
* Updates OHLC values taking into consideration tick's timestamp.
*/
void Update(long _timestamp_ms, T _price) {
void Update(int64 _timestamp_ms, T _price) {
if (!ContainsTimeMs(_timestamp_ms)) {
Print("Error: Cannot update candle. Given time doesn't fit in candle's time-frame!");
DebugBreak();
Expand Down Expand Up @@ -308,12 +308,12 @@ struct CandleOCTOHLC : CandleOHLC<T> {
/**
* Method used by ItemsHistory.
*/
long GetTimeMs() { return (long)start_time * 1000; }
int64 GetTimeMs() { return (int64)start_time * 1000; }

/**
* Method used by ItemsHistory.
*/
long GetLengthMs() { return (long)length * 1000; }
int64 GetLengthMs() { return (int64)length * 1000; }

/**
* Returns candle's start time.
Expand All @@ -323,18 +323,18 @@ struct CandleOCTOHLC : CandleOHLC<T> {
/**
* Returns timestamp of open price.
*/
long GetOpenTimestamp() { return open_timestamp_ms / 1000; }
int64 GetOpenTimestamp() { return open_timestamp_ms / 1000; }

/**
* Returns timestamp of close price.
*/
long GetCloseTimestamp() { return close_timestamp_ms / 1000; }
int64 GetCloseTimestamp() { return close_timestamp_ms / 1000; }

/**
* Whether given time fits in the candle.
*/
bool ContainsTimeMs(long _time_ms) {
return _time_ms >= (long)start_time * 1000 && _time_ms < (long)(start_time + length) * 1000;
bool ContainsTimeMs(int64 _time_ms) {
return _time_ms >= (int64)start_time * 1000 && _time_ms < (int64)(start_time + length) * 1000;
}

// Serializers.
Expand Down
4 changes: 4 additions & 0 deletions Common.define.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@
* @file
* Defines common defines.
*/

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

// Data types.
#include <string>
typedef std::string string;
Expand Down
4 changes: 3 additions & 1 deletion Common.extern.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@

// Define external global functions.
#ifndef __MQL__
// Allows the preprocessor to include a header file when it is needed.
#pragma once

#include <csignal>
#include <string>

#include "Platform/Chart/Chart.enum.h"
#include "Storage/DateTime.enum.h"
#include "Platform/Terminal.define.h"
#include "Storage/DateTime.enum.h"

void DebugBreak() {
#ifdef _MSC_VER
Expand Down
8 changes: 4 additions & 4 deletions Config.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
#define CONFIG_MQH

// Includes.
#include "Storage/Dict/DictStruct.h"
#include "File.mqh"
#include "Storage/Object.h"
#include "Serializer/Serializer.h"
#include "Storage/Dict/DictStruct.h"
#include "Storage/Object.h"

enum CONFIG_FORMAT { CONFIG_FORMAT_JSON, CONFIG_FORMAT_JSON_NO_WHITESPACES, CONFIG_FORMAT_INI };

Expand Down Expand Up @@ -84,7 +84,7 @@ struct ConfigEntry : public MqlParam {
ConfigEntry() { type = (ENUM_DATATYPE)-1; }
ConfigEntry(const ConfigEntry& _r) { THIS_REF = _r; }

ConfigEntry(long _value) {
ConfigEntry(int64 _value) {
type = ENUM_DATATYPE::TYPE_LONG;
integer_value = _value;
}
Expand Down Expand Up @@ -198,7 +198,7 @@ class Config : public DictStruct<string, ConfigEntry> {
return Set(key, param);
}

bool Set(string key, long value) {
bool Set(string key, int64 value) {
ConfigEntry param = value;
return Set(key, param);
}
Expand Down
80 changes: 55 additions & 25 deletions Convert.basic.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@
*
*/

// Prevents processing this includes file for the second time.
#ifndef __MQL__
// Allows the preprocessor to include a header file when it is needed.
#pragma once
#endif

// Includes.
#include "Storage/Array.h"
#include "Common.extern.h"
#include "Storage/DateTime.h"
#include "Std.h"
#include "Storage/Array.h"
#include "Storage/DateTime.h"
#include "Storage/String.h"

/**
Expand All @@ -40,7 +40,7 @@ class ConvertBasic {
/**
* Convert integer to hex.
*/
static string IntToHex(long long_number) {
static string IntToHex(int64 long_number) {
string result;
int integer_number = (int)long_number;
for (int i = 0; i < 4; i++) {
Expand Down Expand Up @@ -88,8 +88,8 @@ class ConvertBasic {
static void StringToType(string _value, unsigned int& _out) { _out = (unsigned int)StringToInteger(_value); }
static void StringToType(string _value, char& _out) { _out = (char)_value[0]; }
static void StringToType(string _value, unsigned char& _out) { _out = (unsigned char)_value[0]; }
static void StringToType(string _value, long& _out) { _out = StringToInteger(_value); }
static void StringToType(string _value, unsigned long& _out) { _out = StringToInteger(_value); }
static void StringToType(string _value, int64& _out) { _out = StringToInteger(_value); }
static void StringToType(string _value, uint64& _out) { _out = StringToInteger(_value); }
static void StringToType(string _value, short& _out) { _out = (short)StringToInteger(_value); }
static void StringToType(string _value, unsigned short& _out) { _out = (unsigned short)StringToInteger(_value); }
static void StringToType(string _value, float& _out) { _out = (float)StringToDouble(_value); }
Expand All @@ -116,8 +116,8 @@ class ConvertBasic {
static void BoolToType(bool _value, unsigned char& _out) { _out = (unsigned char)_value; }
static void BoolToType(bool _value, int& _out) { _out = (int)_value; }
static void BoolToType(bool _value, unsigned int& _out) { _out = (unsigned int)_value; }
static void BoolToType(bool _value, long& _out) { _out = (long)_value; }
static void BoolToType(bool _value, unsigned long& _out) { _out = (unsigned long)_value; }
static void BoolToType(bool _value, int64& _out) { _out = (int64)_value; }
static void BoolToType(bool _value, uint64& _out) { _out = (uint64)_value; }
static void BoolToType(bool _value, short& _out) { _out = (short)_value; }
static void BoolToType(bool _value, unsigned short& _out) { _out = (unsigned short)_value; }
static void BoolToType(bool _value, float& _out) { _out = (float)_value; }
Expand All @@ -133,23 +133,23 @@ class ConvertBasic {
return _out;
}

static void LongToType(long _value, bool& _out) { _out = (bool)_value; }
static void LongToType(long _value, char& _out) { _out = (char)_value; }
static void LongToType(long _value, unsigned char& _out) { _out = (unsigned char)_value; }
static void LongToType(long _value, int& _out) { _out = (int)_value; }
static void LongToType(long _value, unsigned int& _out) { _out = (unsigned int)_value; }
static void LongToType(long _value, long& _out) { _out = (long)_value; }
static void LongToType(long _value, unsigned long& _out) { _out = (unsigned long)_value; }
static void LongToType(long _value, short& _out) { _out = (short)_value; }
static void LongToType(long _value, unsigned short& _out) { _out = (unsigned short)_value; }
static void LongToType(long _value, float& _out) { _out = (float)_value; }
static void LongToType(long _value, double& _out) { _out = (double)_value; }
static void LongToType(long _value, string& _out) { _out = _value ? "1" : "0"; }
static void LongToType(long _value, color& _out) { _out = 0; }
static void LongToType(long _value, datetime& _out) {}
static void LongToType(int64 _value, bool& _out) { _out = (bool)_value; }
static void LongToType(int64 _value, char& _out) { _out = (char)_value; }
static void LongToType(int64 _value, unsigned char& _out) { _out = (unsigned char)_value; }
static void LongToType(int64 _value, int& _out) { _out = (int)_value; }
static void LongToType(int64 _value, unsigned int& _out) { _out = (unsigned int)_value; }
static void LongToType(int64 _value, int64& _out) { _out = (int64)_value; }
static void LongToType(int64 _value, uint64& _out) { _out = (uint64)_value; }
static void LongToType(int64 _value, short& _out) { _out = (short)_value; }
static void LongToType(int64 _value, unsigned short& _out) { _out = (unsigned short)_value; }
static void LongToType(int64 _value, float& _out) { _out = (float)_value; }
static void LongToType(int64 _value, double& _out) { _out = (double)_value; }
static void LongToType(int64 _value, string& _out) { _out = _value ? "1" : "0"; }
static void LongToType(int64 _value, color& _out) { _out = 0; }
static void LongToType(int64 _value, datetime& _out) {}

template <typename X>
static X LongTo(long _value) {
static X LongTo(int64 _value) {
X _out;
LongToType(_value, _out);
return _out;
Expand All @@ -160,8 +160,8 @@ class ConvertBasic {
static void DoubleToType(double _value, unsigned char& _out) { _out = (unsigned char)_value; }
static void DoubleToType(double _value, int& _out) { _out = (int)_value; }
static void DoubleToType(double _value, unsigned int& _out) { _out = (unsigned int)_value; }
static void DoubleToType(double _value, long& _out) { _out = (long)_value; }
static void DoubleToType(double _value, unsigned long& _out) { _out = (unsigned long)_value; }
static void DoubleToType(double _value, int64& _out) { _out = (int64)_value; }
static void DoubleToType(double _value, uint64& _out) { _out = (uint64)_value; }
static void DoubleToType(double _value, short& _out) { _out = (short)_value; }
static void DoubleToType(double _value, unsigned short& _out) { _out = (unsigned short)_value; }
static void DoubleToType(double _value, float& _out) { _out = (float)_value; }
Expand All @@ -176,4 +176,34 @@ class ConvertBasic {
DoubleToType(_value, _out);
return _out;
}

template <typename T>
static T Convert(bool _value, T& _out) {
BoolToType(_value, _out);
return _out;
}

template <typename T>
static T Convert(int _value, T& _out) {
LongToType((long)_value, _out);
return _out;
}

template <typename T>
static T Convert(int64 _value, T& _out) {
LongToType(_value, _out);
return _out;
}

template <typename T>
static T Convert(double _value, T& _out) {
DoubleToType(_value, _out);
return _out;
}

template <typename T>
static T Convert(CONST_REF_TO_SIMPLE(string) _value, T& _out) {
StringToType(_value, _out);
return _out;
}
};
2 changes: 1 addition & 1 deletion Convert.extern.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
*
*/

// Prevents processing this includes file for the second time.
#ifndef __MQL__
// Allows the preprocessor to include a header file when it is needed.
#pragma once

// Includes.
Expand Down
22 changes: 11 additions & 11 deletions Convert.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@
#endif

// Includes.
#include "Convert.extern.h"
#include "Exchange/Account/Account.enum.h"
#include "Exchange/Account/Account.extern.h"
#include "Storage/Array.h"
#include "Convert.extern.h"
#include "Storage/DateTime.extern.h"
#include "Storage/DateTime.h"
#include "Math/Math.extern.h"
#include "Platform/Order.enum.h"
#include "Exchange/SymbolInfo/SymbolInfo.enum.h"
#include "Exchange/SymbolInfo/SymbolInfo.extern.h"
#include "Exchange/SymbolInfo/SymbolInfo.struct.static.h"
#include "Math/Math.extern.h"
#include "Platform/Order.enum.h"
#include "Storage/Array.h"
#include "Storage/DateTime.extern.h"
#include "Storage/DateTime.h"

/**
* Class to provide conversion methods.
Expand Down Expand Up @@ -164,20 +164,20 @@ class Convert {
/**
* Convert points into pips.
*/
static double PointsToPips(long pts, int digits) { return (double)(pts / PointsPerPip(digits)); }
static double PointsToPips(int64 pts, int digits) { return (double)(pts / PointsPerPip(digits)); }

/**
* Convert points into pips.
*/
static double PointsToPips(long pts, string _symbol = NULL) {
static double PointsToPips(int64 pts, string _symbol = NULL) {
return PointsToPips(pts, (unsigned int)SymbolInfoStatic::SymbolInfoInteger(_symbol, SYMBOL_DIGITS));
}

/**
* Convert points into price value.
*
*/
static double PointsToValue(long pts, int mode, string _symbol = NULL) {
static double PointsToValue(int64 pts, int mode, string _symbol = NULL) {
switch (mode) {
case 0: // Forex.
// In currencies a tick is a point.
Expand All @@ -201,7 +201,7 @@ class Convert {
/**
* Convert points into price value.
*/
static double PointsToValue(long pts, int mode, int digits) {
static double PointsToValue(int64 pts, int mode, int digits) {
switch (mode) {
case 0: // Forex.
return PipsToValue((double)pts / PointsPerPip(digits), digits);
Expand All @@ -222,7 +222,7 @@ class Convert {
/**
* Convert points into price value.
*/
static double PointsToValue(long pts, string _symbol = NULL) {
static double PointsToValue(int64 pts, string _symbol = NULL) {
return PointsToValue(pts, (int)SymbolInfoStatic::SymbolInfoInteger(_symbol, SYMBOL_TRADE_CALC_MODE));
}

Expand Down
Loading

0 comments on commit 98c546f

Please sign in to comment.