Skip to content

Commit

Permalink
Merge branch 'v3.009-dev-new' of https://github.com/EA31337/EA31337-c…
Browse files Browse the repository at this point in the history
…lasses into v3.009-dev-new--get-lowest-highest-checks
  • Loading branch information
nseam committed Sep 18, 2024
2 parents aeb62f4 + 3fc6cad commit 80e370f
Show file tree
Hide file tree
Showing 66 changed files with 1,222 additions and 481 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test-storage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ jobs:
- Collection.test
- Database.test
- DateTime.test
- Instances.test
- ItemsHistory.test
- Object.test
- Redis.test
Expand Down
73 changes: 73 additions & 0 deletions .github/workflows/test-strategy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
name: Test Strategy

env:
TEST_PATH: Strategy/tests
TEST_SKIP: ${{ secrets.MT5_LOGIN == '' }}

# yamllint disable-line rule:truthy
on:
pull_request:
paths:
- .github/workflows/test-strategy.yml
- Strategy/**
push:
paths:
- .github/workflows/test-strategy.yml
- Strategy/**

jobs:

compile:
name: Compile
uses: ./.github/workflows/compile-mql.yml
with:
artifact_prefix: mt
path: Strategy/tests
skip_cleanup: true

test:
defaults:
run:
shell: bash
working-directory: ${{ env.TEST_PATH }}
name: Test
needs: compile
runs-on: ubuntu-latest
strategy:
matrix:
test:
- Strategy.test
- Strategy-RSI.test
version: [5]
max-parallel: 4
steps:
- uses: actions/download-artifact@v4
with:
name: files-ex${{ matrix.version }}
- name: List compiled files
run: find . -name '*.ex?' -type f -print
- if: ${{ env.TEST_SKIP != true && env.TEST_SKIP != 'true' }}
name: Run ${{ matrix.test }}
uses: fx31337/mql-tester-action@master
with:
Login: ${{ secrets.MT5_LOGIN }}
Password: ${{ secrets.MT5_PASSWORD }}
Server: MetaQuotes-Demo
TestDeposit: 2000
TestExpert: ${{ matrix.test }}
TestFromDate: ${{ matrix.year }}.01.01
TestPeriod: M1
TestSymbol: EURUSD
TestToDate: ${{ matrix.year }}.01.14
# yamllint disable-line rule:line-length
UrlExpert: file://${{ github.workspace }}/${{ env.TEST_PATH }}/${{ matrix.test }}.ex${{ matrix.version }}
Version: 5
- if: ${{ failure() && runner.debug == '1' }}
uses: mxschmitt/action-tmate@v3
timeout-minutes: 20

cleanup:
name: Clean-up
needs: [compile]
uses: ./.github/workflows/cleanup.yml
2 changes: 0 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ jobs:
- EATest
- MailTest
- MarketTest
- StrategyTest
- StrategyTest-RSI
- SummaryReportTest
- TradeTest
version: [5]
Expand Down
6 changes: 4 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"files.associations": {
"indicatorcandle.h": "c",
"*.mqh": "c"
"*.h": "cpp",
"*.mq4": "cpp",
"*.mq5": "cpp",
"*.mqh": "cpp"
}
}
46 changes: 33 additions & 13 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,44 @@ We use a `clang-format` code formatter tool to format the code

For example, to format file inplace, run:

clang-format -i File.mqh
clang-format -i File.h

### Syntax

To improve code compatibility, please use the following syntax:

| MQL | C++ | Syntax to use |
|:------------------|:------------------------|:---------------------------|
| `&this` | `this` | `THIS_PTR` |
| `GetPointer(obj)` | `*obj` | `GET_PTR(obj)` |
| `T name[]` | `_cpp_array<T> name` | `ARRAY(T, name)` |
| `T<A, B> N[]` | `_cpp_array<T<A, B>> N` | `ARRAY(T<A, B>, N)` |
| `long` | `long long` | `int64` |
| `obj.Method()` | `obj->Method()` | `obj PTR_DEREF Method()` |
| `obj.Ptr().a` | `obj.Ptr()->a` | `obj REF_DEREF a` |
| `obj.a1.a2` | `obj->a1->a2` | `PTR_ATTRIB2(obj, a1, a2)` |
| `obj.attr` | `obj->attr` | `PTR_ATTRIB(obj, attr)` |
| `str == NULL` | `str == NULL` | `IsNull(str)` |
| MQL | C++ | Syntax to use |
|:-------------------|:-------------------------|:---------------------------|
| `&this` | `this` | `THIS_PTR` |
| `this` | `*this` | `THIS_REF` |
| `GetPointer(obj)` | `&obj` | `GET_PTR(obj)` |
| `T name[]` | `std::vector<T> name` | `ARRAY(T, name)` |
| `T name[5]` | `T name[5]` | `FIXED_ARRAY(T, name, 5)` |
| `X f(T[] v)`| `X f(T(&n)[5])` | `FIXED_ARRAY_REF(T, n, 5)` |
| `T<A, B> name[]` | `vector<T<A, B>> name` | `ARRAY(T<A, B>, N)` |
| `long` | `long long` | `int64` |
| `unsigned long` | `unsigned long long` | `uint64` |
| `obj.Method()` ¹| `obj->Method()` | `obj PTR_DEREF Method()` |
| `obj.Ptr().a` ³| `obj.Ptr()->a` | `obj REF_DEREF a` |
| `obj.a1.a2` ¹| `obj->a1->a2` | `PTR_ATTRIB2(obj, a1, a2)` |
| `obj.attr` ¹| `obj->attr` | `PTR_ATTRIB(obj, attr)` |
| `str == NULL` | `str == NULL` | `IsNull(str)` |
| `foo((Ba&)obj)` ²| `foo(*obj)` | `foo(PTR_TO_REF(obj))` |
| `foo((Ba*)obj)` ¹| `foo(&obj)` | `foo(REF_TO_PTR(obj))` |
| `void* N`| `void*& N[]` | `VOID_DATA(N)` |
| `int foo`| `const int foo` | `CONST_CPP int foo` |
| `int foo(int v)`| `int foo(int& v)` | `int foo(int REF_CPP v)` |
| `X foo()`| `X& foo()` | `X REF_CPP foo()` |
| `obj == NULL` ¹| `obj == nullptr` | `obj == nullptr` |
| `datetime d = NULL`| `datetime d = 0` | `datetime = 0` |

Footnotes:

* ¹ Only if `obj` is a pointer.
* ² Only if `obj` is an object or reference type (e.g., `Foo &`).
* ³ Only if `obj` is `Ref<X>`.
* ⁴ Only when used as a parameter to function.
* ⁵ In C++ we could want to return structure by reference or add `const` to the variable or result.

## Proposing changes

Expand Down
2 changes: 1 addition & 1 deletion EA.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#include "Storage/Data.struct.h"
#include "Storage/Dict/Dict.h"
#include "Storage/Dict/DictObject.h"
#include "Strategy.mqh"
#include "Strategy/Strategy.h"
#include "SummaryReport.mqh"
#include "Task/Task.h"
#include "Task/TaskAction.enum.h"
Expand Down
38 changes: 33 additions & 5 deletions Exchange/Account/tests/Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,40 @@
CC := g++ # C++ compiler
CFLAGS := -Wall -Wextra -std=c++17 -w # Compiler flags
SRCS := $(wildcard *.cpp) # Get all .cpp files in the current directory
OBJS := $(SRCS:.cpp=.o) # Object files corresponding to the source files
MTE4 := metaeditor.exe
MTE5 := metaeditor64.exe
CFLAGS := -Wall -Wextra -std=c++17 -w
SRCS_CPP := $(wildcard *.cpp)
SRCS_MQ4 := $(wildcard *.mq4)
SRCS_MQ5 := $(wildcard *.mq5)
OBJS_EX4 := $(SRCS_MQ4:.mq4=.ex4)
OBJS_EX5 := $(SRCS_MQ5:.mq5=.ex5)
OBJS_O := $(SRCS_CPP:.cpp=.o)

all: $(OBJS)
# Check if the system is Linux
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
WINE := wine
# Set WINEPATH to include MetaTrader directory.
export WINEPATH := $(WINEPATH);"C:\Program Files\MetaTrader 4;C:\Program Files\MetaTrader 5"
else
WINE :=
endif

.PHONY: all cpp mql mql4 mql5

all: $(OBJS_O)
cpp: $(OBJS_O)
mql4: $(OBJS_EX4)
mql5: $(OBJS_EX5)
mql: mql4 mql5

%.ex4: %.mq4
$(WINE) $(MTE4) /compile:$< /log:CON

%.ex5: %.mq5
$(WINE) $(MTE5) /compile:$< /log:CON

%.o: %.cpp
$(CC) $(CFLAGS) -c $< -o $@

clean:
rm -v $(OBJS)
rm -v $(OBJS_EX4) $(OBJS_EX5) $(OBJS_O)
38 changes: 33 additions & 5 deletions Exchange/SymbolInfo/tests/Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,40 @@
CC := g++ # C++ compiler
CFLAGS := -Wall -Wextra -std=c++17 -w # Compiler flags
SRCS := $(wildcard *.cpp) # Get all .cpp files in the current directory
OBJS := $(SRCS:.cpp=.o) # Object files corresponding to the source files
MTE4 := metaeditor.exe
MTE5 := metaeditor64.exe
CFLAGS := -Wall -Wextra -std=c++17 -w
SRCS_CPP := $(wildcard *.cpp)
SRCS_MQ4 := $(wildcard *.mq4)
SRCS_MQ5 := $(wildcard *.mq5)
OBJS_EX4 := $(SRCS_MQ4:.mq4=.ex4)
OBJS_EX5 := $(SRCS_MQ5:.mq5=.ex5)
OBJS_O := $(SRCS_CPP:.cpp=.o)

all: $(OBJS)
# Check if the system is Linux
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
WINE := wine
# Set WINEPATH to include MetaTrader directory.
export WINEPATH := $(WINEPATH);"C:\Program Files\MetaTrader 4;C:\Program Files\MetaTrader 5"
else
WINE :=
endif

.PHONY: all cpp mql mql4 mql5

all: $(OBJS_O)
cpp: $(OBJS_O)
mql4: $(OBJS_EX4)
mql5: $(OBJS_EX5)
mql: mql4 mql5

%.ex4: %.mq4
$(WINE) $(MTE4) /compile:$< /log:CON

%.ex5: %.mq5
$(WINE) $(MTE5) /compile:$< /log:CON

%.o: %.cpp
$(CC) $(CFLAGS) -c $< -o $@

clean:
rm -v $(OBJS)
rm -v $(OBJS_EX4) $(OBJS_EX5) $(OBJS_O)
38 changes: 33 additions & 5 deletions Exchange/tests/Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,40 @@
CC := g++ # C++ compiler
CFLAGS := -Wall -Wextra -std=c++17 -w # Compiler flags
SRCS := $(wildcard *.cpp) # Get all .cpp files in the current directory
OBJS := $(SRCS:.cpp=.o) # Object files corresponding to the source files
MTE4 := metaeditor.exe
MTE5 := metaeditor64.exe
CFLAGS := -Wall -Wextra -std=c++17 -w
SRCS_CPP := $(wildcard *.cpp)
SRCS_MQ4 := $(wildcard *.mq4)
SRCS_MQ5 := $(wildcard *.mq5)
OBJS_EX4 := $(SRCS_MQ4:.mq4=.ex4)
OBJS_EX5 := $(SRCS_MQ5:.mq5=.ex5)
OBJS_O := $(SRCS_CPP:.cpp=.o)

all: $(OBJS)
# Check if the system is Linux
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
WINE := wine
# Set WINEPATH to include MetaTrader directory.
export WINEPATH := $(WINEPATH);"C:\Program Files\MetaTrader 4;C:\Program Files\MetaTrader 5"
else
WINE :=
endif

.PHONY: all cpp mql mql4 mql5

all: $(OBJS_O)
cpp: $(OBJS_O)
mql4: $(OBJS_EX4)
mql5: $(OBJS_EX5)
mql: mql4 mql5

%.ex4: %.mq4
$(WINE) $(MTE4) /compile:$< /log:CON

%.ex5: %.mq5
$(WINE) $(MTE5) /compile:$< /log:CON

%.o: %.cpp
$(CC) $(CFLAGS) -c $< -o $@

clean:
rm -v $(OBJS)
rm -v $(OBJS_EX4) $(OBJS_EX5) $(OBJS_O)
2 changes: 1 addition & 1 deletion Indicator/IndicatorBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#endif

// Includes.
#include "../Bar.struct.h"
#include "../Platform/Chart/Bar.struct.h"
#include "../Log.mqh"
#include "../Platform/Chart/Chart.struct.tf.h"
#include "../Platform/Platform.extern.h"
Expand Down
2 changes: 1 addition & 1 deletion Indicator/IndicatorCandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#endif

// Includes.
#include "../Candle.struct.h"
#include "../Platform/Chart/Candle.struct.h"
#include "../Storage/ItemsHistory.h"
#include "../Storage/ValueStorage.price_median.h"
#include "../Storage/ValueStorage.price_typical.h"
Expand Down
2 changes: 1 addition & 1 deletion Indicator/IndicatorCandle.provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#endif

// Includes.
#include "../Candle.struct.h"
#include "../Platform/Chart/Candle.struct.h"
#include "../Storage/ItemsHistory.h"

/**
Expand Down
2 changes: 1 addition & 1 deletion Indicator/IndicatorData.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct ExternInstantiateIndicatorBufferValueStorageDouble {
};

// Includes.
#include "../Bar.struct.h"
#include "../Platform/Chart/Bar.struct.h"
#include "../Exchange/SymbolInfo/SymbolInfo.struct.h"
#include "../Platform/Chart/Chart.struct.tf.h"
#include "../Storage/Cache/IndiBufferCache.h"
Expand Down
38 changes: 33 additions & 5 deletions Indicator/tests/Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,40 @@
CC := g++ # C++ compiler
CFLAGS := -Wall -Wextra -std=c++17 -w # Compiler flags
SRCS := $(wildcard *.cpp) # Get all .cpp files in the current directory
OBJS := $(SRCS:.cpp=.o) # Object files corresponding to the source files
MTE4 := metaeditor.exe
MTE5 := metaeditor64.exe
CFLAGS := -Wall -Wextra -std=c++17 -w
SRCS_CPP := $(wildcard *.cpp)
SRCS_MQ4 := $(wildcard *.mq4)
SRCS_MQ5 := $(wildcard *.mq5)
OBJS_EX4 := $(SRCS_MQ4:.mq4=.ex4)
OBJS_EX5 := $(SRCS_MQ5:.mq5=.ex5)
OBJS_O := $(SRCS_CPP:.cpp=.o)

all: $(OBJS)
# Check if the system is Linux
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
WINE := wine
# Set WINEPATH to include MetaTrader directory.
export WINEPATH := $(WINEPATH);"C:\Program Files\MetaTrader 4;C:\Program Files\MetaTrader 5"
else
WINE :=
endif

.PHONY: all cpp mql mql4 mql5

all: $(OBJS_O)
cpp: $(OBJS_O)
mql4: $(OBJS_EX4)
mql5: $(OBJS_EX5)
mql: mql4 mql5

%.ex4: %.mq4
$(WINE) $(MTE4) /compile:$< /log:CON

%.ex5: %.mq5
$(WINE) $(MTE5) /compile:$< /log:CON

%.o: %.cpp
$(CC) $(CFLAGS) -c $< -o $@

clean:
rm -v $(OBJS)
rm -v $(OBJS_EX4) $(OBJS_EX5) $(OBJS_O)
Loading

0 comments on commit 80e370f

Please sign in to comment.