Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/v3.005-dev' into v3.008-dev-new
Browse files Browse the repository at this point in the history
* origin/v3.005-dev: (42 commits)
  Fixes ZigZag and ZigZagColor value validation.
  Fixes problem with not preserving TF passed to Candle indicators.
  Fixing CompileTest
  Should fix problems with DrawIndicatorTest as Platform::AddWithDefaultBindings() must take symbol and time-frame (we use fixed pair of symbol and time-frame, so code will work in c++).
  Little changes required by emcc support.
  Should fix problem with MA expecting additional bar, despite it has all required bars to generate averages.
  Fixes warning "too many arguments for function-like macro 'RUNTIME_ERROR'"
  Tiny internal changes. Part of testing emcc API.
  Fixes tests using Platform::FetchDefaultCandleIndicator() as method now requires both, symbol and time-frame to be passed.
  Fixes Indi_RSI #elif error. Also, added PERIOD_TF_IRREGULAR enum value for ENUM_TIMEFRAME, so IndicatorTfParams could be initialized as non-tf-based indicator type.
  Empty commit to run tests.
  src/IndicatorTest.cpp
  WIP. Making a Tester class and exporting IndicatorTfDummy and RSI indicator to be used in JS.
  Little changes for array #defines.
  Fixes recent syntax errors for C++.
  WIP. Testing RSI over IndicatorTfDummy over Indi_TickProvider. RSI returns values. It's good!
  WIP. Testing RSI over IndicatorTfDummy over Indi_TickProvider. Now we need to implement missing extern functions.
  WIP. Fixing MT4 errors.
  Fixing MQL4 errors.
  WIP. Using Indi_TickProvider to provide tick for Candle indicator and finally, for RSI or other one.
  ...
  • Loading branch information
kenorb committed May 4, 2024
2 parents 9aed662 + 2fa7dd0 commit 9a9d453
Show file tree
Hide file tree
Showing 156 changed files with 4,951 additions and 2,388 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/compile-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ on:
jobs:

FileList:
if: ${{ false }} # @fixme
outputs:
filelist: ${{ steps.get-files.outputs.filelist }}
runs-on: ubuntu-latest
Expand All @@ -30,7 +29,6 @@ jobs:
run: echo ${{ steps.get-files.outputs.filelist }}

Compile:
if: ${{ false }} # @fixme
runs-on: ubuntu-latest
needs: [FileList]
strategy:
Expand All @@ -45,9 +43,11 @@ jobs:
with:
compiler: gcc-latest
- name: Compile ${{ matrix.file }} via emcc
run: emcc "${{ matrix.file }}"
if: always()
run: >
emcc -s WASM=1 -s ENVIRONMENT=node -s EXIT_RUNTIME=0 -s NO_EXIT_RUNTIME=1 -s ASSERTIONS=1 -Wall -s
MODULARIZE=1 -s ERROR_ON_UNDEFINED_SYMBOLS=0 --bind -s EXPORTED_FUNCTIONS="[]" -g -std=c++17
"${{ matrix.file }}"
- name: Compile ${{ matrix.file }} via g++
run: g++ -c "${{ matrix.file }}"
- if: failure()
# Force success.
run: exit 0
if: always()
run: g++ -g -std=c++17 -c "${{ matrix.file }}"
6 changes: 6 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ jobs:
- SummaryReportTest
- TickerTest
- TradeTest
max-parallel: 4
steps:
- uses: actions/download-artifact@v2
with:
Expand All @@ -73,6 +74,7 @@ jobs:
Version: 4
TestExpert: ${{ matrix.test }}
RunOnError: show_logs 200
if: always()
timeout-minutes: 10

Scripts-MQL4:
Expand Down Expand Up @@ -101,6 +103,7 @@ jobs:
- TerminalTest
- TimerTest
- ValueStorageTest
max-parallel: 4
steps:
- uses: actions/download-artifact@v2
with:
Expand All @@ -109,6 +112,7 @@ jobs:
uses: fx31337/mql-tester-action@master
with:
Script: ${{ matrix.test }}
if: always()
timeout-minutes: 10

Scripts-MQL4-Ignore:
Expand All @@ -135,6 +139,7 @@ jobs:
with:
Script: ${{ matrix.test }}
RunOnFail: "exit 0"
if: always()
timeout-minutes: 10

Trade-Tests-MQL4:
Expand All @@ -157,6 +162,7 @@ jobs:
uses: fx31337/mql-tester-action@master
with:
Script: ${{ matrix.test }}
if: always()
timeout-minutes: 10

cleanup:
Expand Down
1 change: 1 addition & 0 deletions 3D/Chart3DCandles.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
* 3D chart candles renderer.
*/

#include "../Chart.define.h"
#include "Chart3DType.h"
#include "Cube.h"
#include "Device.h"
Expand Down
5 changes: 5 additions & 0 deletions 3D/Mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,13 @@ struct PointEntry {
T point;
long key;

// Default constructor.
PointEntry() {}

// Copy constructor.
PointEntry(const PointEntry<T>& r) : point(r.point), key(r.key) {}

// Constructor.
PointEntry(const T& _point) {
point = _point;
key = MakeKey(_point.Position.x, _point.Position.y, _point.Position.z);
Expand Down
17 changes: 12 additions & 5 deletions 3D/Vertex.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,18 @@ struct Vertex {
DXVector3 Normal;
DXColor Color;

Vertex() {
Color.r = 1.0f;
Color.g = 1.0f;
Color.b = 1.0f;
Color.a = 1.0f;
// Default constructor.
Vertex(float r = 1, float g = 1, float b = 1, float a = 1) {
Color.r = r;
Color.g = g;
Color.b = b;
Color.a = a;
}

Vertex(const Vertex &r) {
Position = r.Position;
Normal = r.Normal;
Color = r.Color;
}

static const ShaderVertexLayout Layout[3];
Expand Down
17 changes: 16 additions & 1 deletion Account/Account.struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#ifndef __MQL__
// Allows the preprocessor to include a header file when it is needed.
#pragma once
#include "../Serializer.enum.h"
#include "../Serializer/Serializer.enum.h"
#endif

// Forward class declaration.
Expand All @@ -48,6 +48,21 @@ struct AccountEntry {
double margin_used;
double margin_free;
double margin_avail;

// Default constructor.
AccountEntry() {}

// Constructor.
AccountEntry(const AccountEntry& r)
: dtime(r.dtime),
balance(r.balance),
credit(r.credit),
equity(r.equity),
profit(r.profit),
margin_used(r.margin_used),
margin_free(r.margin_free),
margin_avail(r.margin_avail) {}

// Serializers.
void SerializeStub(int _n1 = 1, int _n2 = 1, int _n3 = 1, int _n4 = 1, int _n5 = 1) {}
SerializerNodeType Serialize(Serializer& _s) {
Expand Down
3 changes: 2 additions & 1 deletion Account/AccountBase.struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@
#ifndef __MQL__
// Allows the preprocessor to include a header file when it is needed.
#pragma once
#include "../Serializer.enum.h"
#include "../Serializer/Serializer.enum.h"
#endif

// Forward class declaration.
class Serializer;

// Includes.
#include "../Serializer/Serializer.h"
#include "../Std.h"
#include "../Terminal.define.h"

// Struct for account entries.
Expand Down
14 changes: 8 additions & 6 deletions Account/AccountMt.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class AccountMt;
#include "../Orders.mqh"
#include "../Serializer/Serializer.h"
#include "../SymbolInfo.mqh"
#include "../Task/TaskCondition.enum.h"
#include "../Trade.struct.h"
#include "Account.define.h"
#include "Account.enum.h"
Expand Down Expand Up @@ -284,7 +285,7 @@ class AccountMt : public AccountBase {
return ::AccountFreeMarginMode();
#else
// @todo: Not implemented yet.
return NULL;
return NULL_VALUE;
#endif
}
static double GetAccountFreeMarginMode() { return AccountMt::AccountFreeMarginMode(); }
Expand Down Expand Up @@ -470,7 +471,7 @@ class AccountMt : public AccountBase {
*/
bool IsFreeMargin(ENUM_ORDER_TYPE _cmd, double size_of_lot, string _symbol = NULL) {
bool _res = true;
double margin = AccountFreeMarginCheck(_symbol, _cmd, size_of_lot);
// double margin = AccountFreeMarginCheck(_symbol, _cmd, size_of_lot);
if (GetLastError() == 134 /* NOT_ENOUGH_MONEY */) _res = false;
return (_res);
}
Expand Down Expand Up @@ -614,13 +615,14 @@ class AccountMt : public AccountBase {
/**
* Returns text info about the account.
*/
string ToString() {
string const ToString() {
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)",
GetType(), GetServerName(), GetCompanyName(), GetAccountName(), GetCurrency(), GetBalance(), GetCredit(),
GetEquity(), GetProfit(), GetMarginUsed(), GetMarginUsedInPct(), GetMarginFree(), GetMarginAvail(),
GetLimitOrders(), GetLeverage(), GetStopoutLevel(), GetStopoutMode());
C_STR(GetType()), C_STR(GetServerName()), C_STR(GetCompanyName()), C_STR(GetAccountName()),
C_STR(GetCurrency()), GetBalance(), GetCredit(), GetEquity(), GetProfit(), GetMarginUsed(),
GetMarginUsedInPct(), GetMarginFree(), GetMarginAvail(), GetLimitOrders(), GetLeverage(), GetStopoutLevel(),
GetStopoutMode());
}

/**
Expand Down
55 changes: 45 additions & 10 deletions Array.extern.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,36 +24,71 @@
#ifndef __MQL__
#pragma once

#include "Common.extern.h"
#include "Std.h"
#include "String.extern.h"

template <typename T>
extern int ArraySize(const ARRAY_REF(T, _array));
int ArraySize(const ARRAY_REF(T, _array)) {
return _array.size();
}

template <typename T, int size>
extern constexpr int ArraySize(const T REF(_array)[size]);
constexpr int ArraySize(const T REF(_array)[size]) {
return size;
}

template <typename T>
extern int ArrayResize(ARRAY_REF(T, _array), int _new_size, int _reserve_size = 0);
int ArrayResize(ARRAY_REF(T, _array), int _new_size, int _reserve_size = 0) {
_array.resize(_new_size, _reserve_size);
return _new_size;
}

template <typename T>
extern bool ArraySetAsSeries(ARRAY_REF(T, _array), bool _flag);
bool ArraySetAsSeries(ARRAY_REF(T, _array), bool _flag) {
_array.setIsSeries(_flag);
return true;
}

template <typename T>
extern int ArrayMaximum(const ARRAY_REF(T, _array), int _start = 0, unsigned int _count = WHOLE_ARRAY);
bool ArrayGetAsSeries(ARRAY_REF(T, _array)) {
return _array.getIsSeries();
}

template <typename T>
extern int ArrayMinimum(const ARRAY_REF(T, _array), int _start = 0, unsigned int _count = WHOLE_ARRAY);
int ArrayMaximum(const ARRAY_REF(T, _array), int _start = 0, unsigned int _count = WHOLE_ARRAY) {
Print("Not yet implemented: ", __FUNCTION__, " returns 0.");
return 0;
}

template <typename T>
extern int ArrayFree(const ARRAY_REF(T, _array));
int ArrayMinimum(const ARRAY_REF(T, _array), int _start = 0, unsigned int _count = WHOLE_ARRAY) {
Print("Not yet implemented: ", __FUNCTION__, " returns 0.");
return 0;
}

template <typename T>
extern int ArrayReverse(const ARRAY_REF(T, _array));
int ArrayFree(ARRAY_REF(T, _array)) {
_array.resize(0, 0);
return 0;
}

template <typename T>
extern int ArrayInitialize(ARRAY_REF(T, array), char value);
bool ArrayReverse(ARRAY_REF(T, _array)) {
_array.reverse();
return true;
}

template <typename T>
extern int ArraySort(ARRAY_REF(T, array));
extern int ArrayInitialize(ARRAY_REF(T, array), char value) {
Print("Not yet implemented: ", __FUNCTION__, " returns 0.");
return 0;
}

template <typename T>
extern int ArraySort(ARRAY_REF(T, array)) {
Print("Not yet implemented: ", __FUNCTION__, " returns 0.");
return 0;
}

#endif
8 changes: 4 additions & 4 deletions Bar.struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ struct BarOHLC
datetime time;
double open, high, low, close;
// Struct constructor.
BarOHLC() : open(0), high(0), low(0), close(0), time(0){};
BarOHLC() : time(0), open(0), high(0), low(0), close(0){};
BarOHLC(double _open, double _high, double _low, double _close, datetime _time = 0)
: time(_time), open(_open), high(_high), low(_low), close(_close) {
if (_time == 0) {
if (_time == (datetime)0) {
_time = TimeCurrent();
}
}
BarOHLC(ARRAY_REF(double, _prices), datetime _time = 0) : time(_time) {
_time = _time == 0 ? TimeCurrent() : _time;
_time = _time == (datetime)0 ? TimeCurrent() : _time;
int _size = ArraySize(_prices);
close = _prices[0];
open = _prices[_size - 1];
Expand Down Expand Up @@ -261,5 +261,5 @@ struct BarEntry {
s.PassStruct(THIS_REF, "ohlc", ohlc, SERIALIZER_FIELD_FLAG_DYNAMIC);
return SerializerNodeObject;
}
string ToCSV() { return StringFormat("%s", ohlc.ToCSV()); }
string ToCSV() { return StringFormat("%s", C_STR(ohlc.ToCSV())); }
};
8 changes: 6 additions & 2 deletions Buffer/BufferTick.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
#include "../Storage/IValueStorage.h"
#include "../Tick/Tick.struct.h"

// Forward declarations.
template <typename TV>
class BufferTick;

// TV = Type of price stored by BufferTick. RV = Type of property to be retrieved from BufferTick.
template <typename TV, typename RV>
class BufferTickValueStorage : ValueStorage<TV> {
Expand Down Expand Up @@ -71,7 +75,7 @@ class BufferTickValueStorage : ValueStorage<TV> {
/**
* Returns number of values available to fetch (size of the values buffer).
*/
int Size() override { return (int)buffer_tick.Size(); }
int Size() override { return (int)THIS_ATTR buffer_tick.Size(); }
};

/**
Expand Down Expand Up @@ -109,7 +113,7 @@ class BufferTick : public BufferStruct<TickAB<TV>> {
_vs_spread = NULL;
_vs_volume = NULL;
_vs_tick_volume = NULL;
SetOverflowListener(BufferStructOverflowListener, 10);
THIS_ATTR SetOverflowListener(BufferStructOverflowListener, 10);
}

public:
Expand Down
14 changes: 14 additions & 0 deletions BufferFXT.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,20 @@ struct BufferFXTEntry {
int flag; // Flag to launch an expert (0 - bar will be modified, but the expert will not be launched).

public:
// Default constructor
BufferFXTEntry() {}

// Copy constructor
BufferFXTEntry(const BufferFXTEntry &r)
: otm(r.otm),
open(r.open),
high(r.high),
low(r.low),
close(r.close),
volume(r.volume),
ctm(r.ctm),
flag(r.flag) {}

bool operator==(const BufferFXTEntry &_s) {
// @fixme
return false;
Expand Down
Loading

0 comments on commit 9a9d453

Please sign in to comment.