diff --git a/.github/workflows/test-storage.yml b/.github/workflows/test-storage.yml index 81c19879f..5b3b795c0 100644 --- a/.github/workflows/test-storage.yml +++ b/.github/workflows/test-storage.yml @@ -40,6 +40,7 @@ jobs: - Collection.test - Database.test - DateTime.test + - Instances.test - ItemsHistory.test - Object.test - Redis.test diff --git a/.github/workflows/test-strategy.yml b/.github/workflows/test-strategy.yml new file mode 100644 index 000000000..bc5c78103 --- /dev/null +++ b/.github/workflows/test-strategy.yml @@ -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d80482805..e4c38cdd7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -46,8 +46,6 @@ jobs: - EATest - MailTest - MarketTest - - StrategyTest - - StrategyTest-RSI - SummaryReportTest - TradeTest version: [5] diff --git a/.vscode/settings.json b/.vscode/settings.json index 7417eab66..bb0dddd03 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,8 @@ { "files.associations": { - "indicatorcandle.h": "c", - "*.mqh": "c" + "*.h": "cpp", + "*.mq4": "cpp", + "*.mq5": "cpp", + "*.mqh": "cpp" } } diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 313e71c91..480ea4df3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 name` | `ARRAY(T, name)` | -| `T N[]` | `_cpp_array> N` | `ARRAY(T, 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 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 name[]` | `vector> name` | `ARRAY(T, 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`. +* ⁴ 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 diff --git a/EA.mqh b/EA.mqh index 82b5c9cb2..21f7aec76 100644 --- a/EA.mqh +++ b/EA.mqh @@ -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" diff --git a/Exchange/Account/tests/Makefile b/Exchange/Account/tests/Makefile index e792364f0..ba14b9322 100644 --- a/Exchange/Account/tests/Makefile +++ b/Exchange/Account/tests/Makefile @@ -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) diff --git a/Exchange/SymbolInfo/tests/Makefile b/Exchange/SymbolInfo/tests/Makefile index e792364f0..ba14b9322 100644 --- a/Exchange/SymbolInfo/tests/Makefile +++ b/Exchange/SymbolInfo/tests/Makefile @@ -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) diff --git a/Exchange/tests/Makefile b/Exchange/tests/Makefile index e792364f0..ba14b9322 100644 --- a/Exchange/tests/Makefile +++ b/Exchange/tests/Makefile @@ -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) diff --git a/Indicator/IndicatorBase.h b/Indicator/IndicatorBase.h index e15aaff42..a2bfbe26c 100644 --- a/Indicator/IndicatorBase.h +++ b/Indicator/IndicatorBase.h @@ -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" diff --git a/Indicator/IndicatorCandle.h b/Indicator/IndicatorCandle.h index 7d7fb0072..7124a3506 100644 --- a/Indicator/IndicatorCandle.h +++ b/Indicator/IndicatorCandle.h @@ -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" diff --git a/Indicator/IndicatorCandle.provider.h b/Indicator/IndicatorCandle.provider.h index 4eb894c06..d050a9ee0 100644 --- a/Indicator/IndicatorCandle.provider.h +++ b/Indicator/IndicatorCandle.provider.h @@ -30,7 +30,7 @@ #endif // Includes. -#include "../Candle.struct.h" +#include "../Platform/Chart/Candle.struct.h" #include "../Storage/ItemsHistory.h" /** diff --git a/Indicator/IndicatorData.h b/Indicator/IndicatorData.h index dbfb05b87..ff184156d 100644 --- a/Indicator/IndicatorData.h +++ b/Indicator/IndicatorData.h @@ -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" diff --git a/Indicator/tests/Makefile b/Indicator/tests/Makefile index e792364f0..ba14b9322 100644 --- a/Indicator/tests/Makefile +++ b/Indicator/tests/Makefile @@ -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) diff --git a/Indicators/Bitwise/Indi_Candle.mqh b/Indicators/Bitwise/Indi_Candle.mqh index bd2bd31e0..1a286092d 100644 --- a/Indicators/Bitwise/Indi_Candle.mqh +++ b/Indicators/Bitwise/Indi_Candle.mqh @@ -26,9 +26,9 @@ #endif // Includes. -#include "../../Bar.struct.h" +#include "../../Platform/Chart/Bar.struct.h" #include "../../Indicator/Indicator.h" -#include "../../Pattern.struct.h" +#include "../../Platform/Chart/Pattern.struct.h" #include "../../Serializer/Serializer.h" #include "../../Storage/Dict/Buffer/BufferStruct.h" #include "../Price/Indi_Price.h" diff --git a/Indicators/Bitwise/Indi_Pattern.mqh b/Indicators/Bitwise/Indi_Pattern.mqh index 6ad40f135..13f805124 100644 --- a/Indicators/Bitwise/Indi_Pattern.mqh +++ b/Indicators/Bitwise/Indi_Pattern.mqh @@ -26,10 +26,10 @@ #endif // Includes. -#include "../../Bar.struct.h" +#include "../../Platform/Chart/Bar.struct.h" #include "../../Indicator/Indicator.define.h" #include "../../Indicator/Indicator.h" -#include "../../Pattern.struct.h" +#include "../../Platform/Chart/Pattern.struct.h" #include "../../Serializer/Serializer.h" #include "../../Storage/Dict/Buffer/BufferStruct.h" #include "../Price/Indi_Price.h" diff --git a/Indicators/Bitwise/tests/Makefile b/Indicators/Bitwise/tests/Makefile index e792364f0..ba14b9322 100644 --- a/Indicators/Bitwise/tests/Makefile +++ b/Indicators/Bitwise/tests/Makefile @@ -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) diff --git a/Indicators/OHLC/tests/Makefile b/Indicators/OHLC/tests/Makefile index e792364f0..ba14b9322 100644 --- a/Indicators/OHLC/tests/Makefile +++ b/Indicators/OHLC/tests/Makefile @@ -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) diff --git a/Indicators/Oscillator/tests/Makefile b/Indicators/Oscillator/tests/Makefile index e792364f0..ba14b9322 100644 --- a/Indicators/Oscillator/tests/Makefile +++ b/Indicators/Oscillator/tests/Makefile @@ -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) diff --git a/Indicators/Price/tests/Makefile b/Indicators/Price/tests/Makefile index e792364f0..ba14b9322 100644 --- a/Indicators/Price/tests/Makefile +++ b/Indicators/Price/tests/Makefile @@ -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) diff --git a/Indicators/PriceMulti/tests/Makefile b/Indicators/PriceMulti/tests/Makefile index e792364f0..ba14b9322 100644 --- a/Indicators/PriceMulti/tests/Makefile +++ b/Indicators/PriceMulti/tests/Makefile @@ -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) diff --git a/Indicators/PriceRange/Indi_Pivot.h b/Indicators/PriceRange/Indi_Pivot.h index 47d45cfe7..c27387015 100644 --- a/Indicators/PriceRange/Indi_Pivot.h +++ b/Indicators/PriceRange/Indi_Pivot.h @@ -26,7 +26,7 @@ #endif // Includes. -#include "../../Bar.struct.h" +#include "../../Platform/Chart/Bar.struct.h" #include "../../Indicator/Indicator.struct.h" #include "../../Serializer/Serializer.h" #include "../Special/Indi_Math.mqh" diff --git a/Indicators/PriceRange/tests/Makefile b/Indicators/PriceRange/tests/Makefile index e792364f0..ba14b9322 100644 --- a/Indicators/PriceRange/tests/Makefile +++ b/Indicators/PriceRange/tests/Makefile @@ -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) diff --git a/Indicators/Special/tests/Makefile b/Indicators/Special/tests/Makefile index e792364f0..ba14b9322 100644 --- a/Indicators/Special/tests/Makefile +++ b/Indicators/Special/tests/Makefile @@ -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) diff --git a/Indicators/Tick/tests/Makefile b/Indicators/Tick/tests/Makefile index e792364f0..ba14b9322 100644 --- a/Indicators/Tick/tests/Makefile +++ b/Indicators/Tick/tests/Makefile @@ -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) diff --git a/Indicators/tests/Makefile b/Indicators/tests/Makefile index e792364f0..ba14b9322 100644 --- a/Indicators/tests/Makefile +++ b/Indicators/tests/Makefile @@ -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) diff --git a/Math.h b/Math.h deleted file mode 100644 index 371451f66..000000000 --- a/Math.h +++ /dev/null @@ -1,267 +0,0 @@ -//+------------------------------------------------------------------+ -//| EA31337 framework | -//| Copyright 2016-2023, EA31337 Ltd | -//| https://github.com/EA31337 | -//+------------------------------------------------------------------+ - -/* - * This file is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#ifndef __MQL__ -// Allows the preprocessor to include a header file when it is needed. -#pragma once -#endif - -// Includes. -#include "Data.struct.h" -#include "Indicator/Indicator.struct.h" -#include "Math.define.h" -#include "Math.enum.h" -#include "Math.extern.h" -#include "Math.struct.h" - -/** - * Class to provide math related methods. - */ -class Math { - protected: - public: - Math() {} - - /* Calculation */ - - template - static X ReLU(X _value) { - return (X)fmax(0, _value); - } - - /** - * Returns value changed by the given percentage. - * - * @param double _value - * Base value to change. - * @param float _pct - * Percentage to change (1 is 100%). - * - * @return - * Returns value after the change. - */ - static double ChangeByPct(double _v, float _pct) { return _v != 0 ? _v + (fabs(_v) * _pct) : 0; } - - /** - * Calculates change between 2 values in percentage. - * - * @docs: https://stackoverflow.com/a/65511594/55075 - * - * @param double _v1 - * First value. - * @param double _v2 - * Second value. - * @param bool _hundreds - * When true, 100% is 100, otherwise 1. - * @return - * Returns percentage change. - */ - static double ChangeInPct(double _v1, double _v2, bool _hundreds = false) { - double _result = 0; - if (_v1 == 0 || _v2 == 0) { - // Change is zero when both values are zeros, otherwise it's 1 (100%). - _result = _v1 == 0 && _v2 == 0 ? 0 : 1; - } else { - // If values are non-zero, use the standard formula. - _result = (_v2 / _v1) - 1; - } - _result = _v2 > _v1 ? fabs(_result) : -fabs(_result); - return _hundreds ? _result * 100 : _result; - } - - /** - * Checks condition for 2 values based on the given comparison operator. - */ - template - static bool Compare(T1 _v1, T2 _v2, ENUM_MATH_CONDITION _op = MATH_COND_EQ) { - switch (_op) { - case MATH_COND_EQ: - return _v1 == _v2; - case MATH_COND_GT: - return _v1 > _v2; - case MATH_COND_LE: - return _v1 < _v2; - default: - break; - } - return false; - } - - /** - * Gets number of digits after decimal in a floating point number. - */ - template - static short FloatDigits(V _value) { - short _cnt = 0; - while ((int)_value != _value) { - _value *= 10; - _cnt++; - } - return _cnt; - } - - /** - * Returns a non-zero value. - * - * @return - * Returns a non-zero value. - */ - static double NonZero(double _v) { return _v == 0 ? DBL_MIN : _v; } - - /* Conditions */ - - /** - * Checks for math condition. - * - * @param ENUM_MATH_CONDITION _cond - * Math condition. - * @param MqlParam[] _args - * Condition arguments. - * @return - * Returns true when the condition is met. - */ - /* - bool CheckCondition(ENUM_MATH_CONDITION _cond, DataParamEntry &_args[]) { - switch (_cond) { - case MATH_COND_EQ: - // @todo - return false; - case MATH_COND_GT: - // @todo - return false; - case MATH_COND_LE: - // @todo - return false; - default: - // logger.Error(StringFormat("Invalid math condition: %s!", EnumToString(_cond), __FUNCTION_LINE__)); - return false; - } - } - bool CheckCondition(ENUM_MATH_CONDITION _cond) { - DataParamEntry _args[] = {}; - return Math::CheckCondition(_cond, _args); - } - */ - - template - static T Add(T a, T b) { - return a + b; - } - template - static T Sub(T a, T b) { - return a - b; - } - template - static T Mul(T a, T b) { - return a * b; - } - template - static T Div(T a, T b) { - return a / b; - } - template - static T Sin(T a) { - return sin(a); - } - template - static T Cos(T a) { - return cos(a); - } - template - static T Tang(T a) { - return tan(a); - } - template - static T Min(T a, T b) { - return MathMin(a, b); - } - template - static T Min(T a, T b, T c) { - return MathMin(MathMin(a, b), c); - } - template - static T Min(T a, T b, T c, T d) { - return MathMin(MathMin(MathMin(a, b), c), d); - } - template - static T Max(T a, T b) { - return MathMax(a, b); - } - template - static T Max(T a, T b, T c) { - return MathMax(MathMax(a, b), c); - } - template - static T Max(T a, T b, T c, T d) { - return MathMax(MathMax(MathMax(a, b), c), d); - } - template - static T Avg(T a, T b) { - return (a + b) / 2; - } - template - static T Avg(T a, T b, T c) { - return (a + b + c) / 3; - } - template - static T Avg(T a, T b, T c, T d) { - return (a + b + c + d) / 4; - } - template - static T Abs(T a) { - return MathAbs(a); - } - - template - static T Op(ENUM_MATH_OP _op, T _val_1, T _val_2 = 0) { - switch (_op) { - case MATH_OP_ADD: - return Add(_val_1, _val_2); - case MATH_OP_SUB: - return Sub(_val_1, _val_2); - case MATH_OP_MUL: - return Mul(_val_1, _val_2); - case MATH_OP_DIV: - return Div(_val_1, _val_2); - case MATH_OP_SIN: - return Sin(_val_1); - case MATH_OP_COS: - return Cos(_val_2); - case MATH_OP_TAN: - return Tang(_val_2); - case MATH_OP_MIN: - return Min(_val_1, _val_2); - case MATH_OP_MAX: - return Max(_val_1, _val_2); - case MATH_OP_AVG: - return Avg(_val_1, _val_2); - case MATH_OP_RELU: - return ReLU(_val_1); - case MATH_OP_ABS: - return Abs(_val_1); - case MATH_OP_ABS_DIFF: - return Abs(_val_1 - _val_2); - default: - return EMPTY_VALUE; - } - } -}; diff --git a/Math/tests/Makefile b/Math/tests/Makefile index e792364f0..ba14b9322 100644 --- a/Math/tests/Makefile +++ b/Math/tests/Makefile @@ -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) diff --git a/Bar.enum.h b/Platform/Chart/Bar.enum.h similarity index 100% rename from Bar.enum.h rename to Platform/Chart/Bar.enum.h diff --git a/Bar.struct.h b/Platform/Chart/Bar.struct.h similarity index 98% rename from Bar.struct.h rename to Platform/Chart/Bar.struct.h index f931af0a4..6b372d08f 100644 --- a/Bar.struct.h +++ b/Platform/Chart/Bar.struct.h @@ -35,12 +35,12 @@ class Serializer; // Includes. #include "Bar.enum.h" -#include "Platform/Chart/Chart.enum.h" -#include "Serializer/Serializable.h" -#include "Serializer/Serializer.enum.h" -#include "Serializer/Serializer.h" -#include "Serializer/SerializerNode.enum.h" -#include "Std.h" +#include "Chart.enum.h" +#include "../../Serializer/Serializable.h" +#include "../../Serializer/Serializer.enum.h" +#include "../../Serializer/Serializer.h" +#include "../../Serializer/SerializerNode.enum.h" +#include "../../Std.h" /* Struct for storing OHLC values. */ struct BarOHLC diff --git a/Candle.struct.h b/Platform/Chart/Candle.struct.h similarity index 98% rename from Candle.struct.h rename to Platform/Chart/Candle.struct.h index 4d01e0474..55d0da7aa 100644 --- a/Candle.struct.h +++ b/Platform/Chart/Candle.struct.h @@ -35,12 +35,12 @@ class Serializer; // Includes. #include "Bar.enum.h" -#include "Platform/Chart/Chart.enum.h" -#include "Serializer/Serializable.h" -#include "Serializer/Serializer.enum.h" -#include "Serializer/Serializer.h" -#include "Serializer/SerializerNode.enum.h" -#include "Std.h" +#include "Chart.enum.h" +#include "../../Serializer/Serializable.h" +#include "../../Serializer/Serializer.enum.h" +#include "../../Serializer/Serializer.h" +#include "../../Serializer/SerializerNode.enum.h" +#include "../../Std.h" /* Structure for storing OHLC values. */ template diff --git a/Platform/Chart/Chart.struct.h b/Platform/Chart/Chart.struct.h index ef0d2e3f0..d7a690c06 100644 --- a/Platform/Chart/Chart.struct.h +++ b/Platform/Chart/Chart.struct.h @@ -35,7 +35,7 @@ class Class; struct ChartTf; // Includes. -#include "../../Bar.struct.h" +#include "Bar.struct.h" #include "../../Serializer/Serializer.h" #include "../../Serializer/SerializerNode.enum.h" #include "../../Std.h" diff --git a/Pattern.enum.h b/Platform/Chart/Pattern.enum.h similarity index 100% rename from Pattern.enum.h rename to Platform/Chart/Pattern.enum.h diff --git a/Pattern.mqh b/Platform/Chart/Pattern.h similarity index 100% rename from Pattern.mqh rename to Platform/Chart/Pattern.h diff --git a/Pattern.struct.h b/Platform/Chart/Pattern.struct.h similarity index 99% rename from Pattern.struct.h rename to Platform/Chart/Pattern.struct.h index f8aebe7d8..4a0377287 100644 --- a/Pattern.struct.h +++ b/Platform/Chart/Pattern.struct.h @@ -32,7 +32,7 @@ // Includes. #include "Bar.struct.h" -#include "Math/Math.define.h" +#include "../../Math/Math.define.h" #include "Pattern.enum.h" // Defines structure for bitwise pattern values. diff --git a/Platform/Chart/tests/Chart.test.mq5 b/Platform/Chart/tests/Chart.test.mq5 index f3b9f9779..10875e102 100644 --- a/Platform/Chart/tests/Chart.test.mq5 +++ b/Platform/Chart/tests/Chart.test.mq5 @@ -25,6 +25,8 @@ */ // Includes. +#include "../Bar.struct.h" +#include "../Candle.struct.h" #include "../Chart.h" #include "../../../Convert.mqh" #include "../../../Test.mqh" diff --git a/Platform/Chart/tests/Makefile b/Platform/Chart/tests/Makefile index e792364f0..ba14b9322 100644 --- a/Platform/Chart/tests/Makefile +++ b/Platform/Chart/tests/Makefile @@ -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) diff --git a/Platform/Chart3D/Chart3D.h b/Platform/Chart3D/Chart3D.h index f8b267eec..165ca88ec 100644 --- a/Platform/Chart3D/Chart3D.h +++ b/Platform/Chart3D/Chart3D.h @@ -30,10 +30,10 @@ #pragma once #endif -#include "../../Bar.struct.h" +#include "../Chart/Bar.struct.h" #include "../../Indicator/IndicatorData.h" #include "../../Indicators/Price/Indi_MA.h" -#include "../../Instances.h" +#include "../../Storage/Instances.h" #include "../../Refs.mqh" #include "../../Serializer/SerializerConverter.h" #include "../../Serializer/SerializerJson.h" diff --git a/Platform/Chart3D/tests/Makefile b/Platform/Chart3D/tests/Makefile index e792364f0..ba14b9322 100644 --- a/Platform/Chart3D/tests/Makefile +++ b/Platform/Chart3D/tests/Makefile @@ -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) diff --git a/Platform/Web/tests/Makefile b/Platform/Web/tests/Makefile index e792364f0..ba14b9322 100644 --- a/Platform/Web/tests/Makefile +++ b/Platform/Web/tests/Makefile @@ -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) diff --git a/Platform/tests/Makefile b/Platform/tests/Makefile index e792364f0..ba14b9322 100644 --- a/Platform/tests/Makefile +++ b/Platform/tests/Makefile @@ -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) diff --git a/Serializer/tests/Makefile b/Serializer/tests/Makefile index e792364f0..ba14b9322 100644 --- a/Serializer/tests/Makefile +++ b/Serializer/tests/Makefile @@ -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) diff --git a/Storage/Cache/tests/Makefile b/Storage/Cache/tests/Makefile index e792364f0..ba14b9322 100644 --- a/Storage/Cache/tests/Makefile +++ b/Storage/Cache/tests/Makefile @@ -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) diff --git a/Storage/Dict/Buffer/BufferCandle.h b/Storage/Dict/Buffer/BufferCandle.h index 1126963b8..eb0406f66 100644 --- a/Storage/Dict/Buffer/BufferCandle.h +++ b/Storage/Dict/Buffer/BufferCandle.h @@ -26,7 +26,7 @@ #endif // Includes. -#include "../../../Candle.struct.h" +#include "../../../Platform/Chart/Candle.struct.h" #include "../../../Serializer/SerializerConverter.h" #include "../../../Serializer/SerializerJson.h" #include "BufferStruct.h" diff --git a/Storage/Dict/Buffer/tests/Makefile b/Storage/Dict/Buffer/tests/Makefile index e792364f0..ba14b9322 100644 --- a/Storage/Dict/Buffer/tests/Makefile +++ b/Storage/Dict/Buffer/tests/Makefile @@ -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) diff --git a/Storage/Dict/tests/Makefile b/Storage/Dict/tests/Makefile index e792364f0..ba14b9322 100644 --- a/Storage/Dict/tests/Makefile +++ b/Storage/Dict/tests/Makefile @@ -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) diff --git a/Instances.h b/Storage/Instances.h similarity index 92% rename from Instances.h rename to Storage/Instances.h index 548aaa015..726bf072d 100644 --- a/Instances.h +++ b/Storage/Instances.h @@ -34,8 +34,8 @@ #ifndef INSTANCES_H #define INSTANCES_H -#include "Storage/Dict/Dict.h" -#include "Util.h" +#include "Dict/Dict.h" +#include "../Util.h" template class Instances { @@ -52,7 +52,8 @@ template #ifdef __MQL__ T* Instances::instances[]; #else -T* Instances::instances[]; +//T* Instances::instances[]; +ARRAY(T*, Instances::instances); #endif -#endif // INSTANCES_MQH +#endif // INSTANCES_H diff --git a/Storage/tests/Instances.test.cpp b/Storage/tests/Instances.test.cpp new file mode 100644 index 000000000..2dc6b3f7a --- /dev/null +++ b/Storage/tests/Instances.test.cpp @@ -0,0 +1,41 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2024, EA31337 Ltd | +//| https://ea31337.github.io | +//+------------------------------------------------------------------+ + +/* + * This file is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * @file + * Test C++ compilation of Instances class. + */ + +// Includes. +#include "../Instances.h" + +int main(int argc, char **argv) { + // Create a new object. + // Instances *obj = new Instances(); + + // @todo: Add more tests. + // ... + + // Clean up. + // Instances::Delete(obj); + + return 0; +} diff --git a/Storage/tests/Instances.test.mq4 b/Storage/tests/Instances.test.mq4 new file mode 100644 index 000000000..b5d94b5f1 --- /dev/null +++ b/Storage/tests/Instances.test.mq4 @@ -0,0 +1,28 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2024, EA31337 Ltd | +//| https://ea31337.github.io | +//+------------------------------------------------------------------+ + +/* + * This file is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * @file + * Test functionality of Instances class. + */ + +// Includes. +#include "Instances.test.mq5" diff --git a/Storage/tests/Instances.test.mq5 b/Storage/tests/Instances.test.mq5 new file mode 100644 index 000000000..c46c59ff0 --- /dev/null +++ b/Storage/tests/Instances.test.mq5 @@ -0,0 +1,45 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2024, EA31337 Ltd | +//| https://ea31337.github.io | +//+------------------------------------------------------------------+ + +/* + * This file is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * @file + * Test functionality of Instances class. + */ + +// Includes. +#include "../../Test.mqh" +#include "../Instances.h" + +/** + * Implements OnInit(). + */ +int OnInit() { + // Create a new object. + // Instances *obj = new Instances(); + + // @todo: Add more tests. + // ... + + // Clean up. + // Instances::Delete(obj); + + return (GetLastError() > 0 ? INIT_FAILED : INIT_SUCCEEDED); +} diff --git a/Storage/tests/Makefile b/Storage/tests/Makefile index e792364f0..ba14b9322 100644 --- a/Storage/tests/Makefile +++ b/Storage/tests/Makefile @@ -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) diff --git a/Strategy.enum.h b/Strategy/Strategy.enum.h similarity index 100% rename from Strategy.enum.h rename to Strategy/Strategy.enum.h diff --git a/Strategy.mqh b/Strategy/Strategy.h similarity index 99% rename from Strategy.mqh rename to Strategy/Strategy.h index 4f51cc261..f397ef318 100644 --- a/Strategy.mqh +++ b/Strategy/Strategy.h @@ -21,25 +21,25 @@ */ // Prevents processing this includes file for the second time. -#ifndef STRATEGY_MQH -#define STRATEGY_MQH +#ifndef STRATEGY_H +#define STRATEGY_H // Forward declaration. class Trade; // Includes. -#include "Indicator/Indicator.h" -#include "Market.mqh" -#include "Math/Math.h" -#include "Storage/Data.struct.h" -#include "Storage/Dict/Dict.h" -#include "Storage/Object.h" -#include "Storage/String.h" +#include "../Indicator/Indicator.h" +#include "../Market.mqh" +#include "../Math/Math.h" +#include "../Storage/Data.struct.h" +#include "../Storage/Dict/Dict.h" +#include "../Storage/Object.h" +#include "../Storage/String.h" #include "Strategy.enum.h" #include "Strategy.struct.h" -#include "Task/TaskManager.h" -#include "Task/Taskable.h" -#include "Trade.mqh" +#include "../Task/TaskManager.h" +#include "../Task/Taskable.h" +#include "../Trade.mqh" // Defines. // Primary inputs. @@ -1285,4 +1285,4 @@ class Strategy : public Taskable { return SerializerNodeObject; } }; -#endif // STRATEGY_MQH +#endif // STRATEGY_H diff --git a/Strategy.struct.h b/Strategy/Strategy.struct.h similarity index 99% rename from Strategy.struct.h rename to Strategy/Strategy.struct.h index 178197aed..74adf6efc 100644 --- a/Strategy.struct.h +++ b/Strategy/Strategy.struct.h @@ -31,10 +31,10 @@ #endif // Includes. -#include "Serializer/Serializer.h" +#include "../Serializer/Serializer.h" #include "Strategy.enum.h" #include "Strategy.struct.pricestop.h" -#include "Task/Task.struct.h" +#include "../Task/Task.struct.h" // Forward class declaration. class Strategy; diff --git a/Strategy.struct.pricestop.h b/Strategy/Strategy.struct.pricestop.h similarity index 99% rename from Strategy.struct.pricestop.h rename to Strategy/Strategy.struct.pricestop.h index 772a3862f..9794e49fd 100644 --- a/Strategy.struct.pricestop.h +++ b/Strategy/Strategy.struct.pricestop.h @@ -35,7 +35,7 @@ struct ChartParams; struct IndicatorParams; // Includes. -#include "Platform/Chart/Chart.struct.h" +#include "../Platform/Chart/Chart.struct.h" /* Structure for strategy price stops. */ struct StrategyPriceStop { diff --git a/Strategy/tests/Makefile b/Strategy/tests/Makefile new file mode 100644 index 000000000..ba14b9322 --- /dev/null +++ b/Strategy/tests/Makefile @@ -0,0 +1,40 @@ +CC := g++ # C++ compiler +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) + +# 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_EX4) $(OBJS_EX5) $(OBJS_O) diff --git a/tests/StrategyTest-RSI.mq4 b/Strategy/tests/Strategy-RSI.test.mq4 similarity index 97% rename from tests/StrategyTest-RSI.mq4 rename to Strategy/tests/Strategy-RSI.test.mq4 index 2517e2405..29b948365 100644 --- a/tests/StrategyTest-RSI.mq4 +++ b/Strategy/tests/Strategy-RSI.test.mq4 @@ -27,4 +27,4 @@ #define __debug__ // Includes. -#include "StrategyTest-RSI.mq5" +#include "Strategy-RSI.test.mq5" diff --git a/tests/StrategyTest-RSI.mq5 b/Strategy/tests/Strategy-RSI.test.mq5 similarity index 96% rename from tests/StrategyTest-RSI.mq5 rename to Strategy/tests/Strategy-RSI.test.mq5 index 46783323f..04bca242e 100644 --- a/tests/StrategyTest-RSI.mq5 +++ b/Strategy/tests/Strategy-RSI.test.mq5 @@ -28,12 +28,12 @@ //#define __debug_verbose__ // Includes. -#include "../Indicator/tests/classes/IndicatorTfDummy.h" -#include "../Indicators/Oscillator/Indi_RSI.h" -#include "../Indicators/Tick/Indi_TickMt.h" -#include "../Platform/Chart/ChartMt.h" -#include "../Strategy.mqh" -#include "../Test.mqh" +#include "../../Indicator/tests/classes/IndicatorTfDummy.h" +#include "../../Indicators/Oscillator/Indi_RSI.h" +#include "../../Indicators/Tick/Indi_TickMt.h" +#include "../../Platform/Chart/ChartMt.h" +#include "../Strategy.h" +#include "../../Test.mqh" // Define strategy classes. class Stg_RSI : public Strategy { diff --git a/tests/Strategy.test.cpp b/Strategy/tests/Strategy.test.cpp similarity index 94% rename from tests/Strategy.test.cpp rename to Strategy/tests/Strategy.test.cpp index 30f554008..a3af9807d 100644 --- a/tests/Strategy.test.cpp +++ b/Strategy/tests/Strategy.test.cpp @@ -25,8 +25,8 @@ */ // Includes. -#include "../Strategy.mqh" -#include "../Platform/Platform.h" +#include "../Strategy.h" +#include "../../Platform/Platform.h" int main(int argc, char **argv) { // @todo diff --git a/tests/StrategyTest.mq4 b/Strategy/tests/Strategy.test.mq4 similarity index 97% rename from tests/StrategyTest.mq4 rename to Strategy/tests/Strategy.test.mq4 index 981f90c9e..6fd28390f 100644 --- a/tests/StrategyTest.mq4 +++ b/Strategy/tests/Strategy.test.mq4 @@ -25,4 +25,4 @@ */ // Includes. -#include "StrategyTest.mq5" +#include "Strategy.test.mq5" diff --git a/tests/StrategyTest.mq5 b/Strategy/tests/Strategy.test.mq5 similarity index 98% rename from tests/StrategyTest.mq5 rename to Strategy/tests/Strategy.test.mq5 index 6ebf91b9e..468f7963e 100644 --- a/tests/StrategyTest.mq5 +++ b/Strategy/tests/Strategy.test.mq5 @@ -28,9 +28,9 @@ struct DataParamEntry; // Includes. -#include "../Indicators/Indi_Demo.mqh" -#include "../Strategy.mqh" -#include "../Test.mqh" +#include "../../Indicators/Indi_Demo.mqh" +#include "../Strategy.h" +#include "../../Test.mqh" // Define strategy classes. class Stg1 : public Strategy { diff --git a/Task/tests/Makefile b/Task/tests/Makefile index e792364f0..ba14b9322 100644 --- a/Task/tests/Makefile +++ b/Task/tests/Makefile @@ -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) diff --git a/Tick/tests/Makefile b/Tick/tests/Makefile index e792364f0..ba14b9322 100644 --- a/Tick/tests/Makefile +++ b/Tick/tests/Makefile @@ -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) diff --git a/Trade/tests/Makefile b/Trade/tests/Makefile index e792364f0..ba14b9322 100644 --- a/Trade/tests/Makefile +++ b/Trade/tests/Makefile @@ -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) diff --git a/tests/CompileTest.mq5 b/tests/CompileTest.mq5 index 6cc33363b..bc7f1602a 100644 --- a/tests/CompileTest.mq5 +++ b/tests/CompileTest.mq5 @@ -57,6 +57,7 @@ struct IndicatorParams; #include "../Storage/Dict/DictObject.h" #include "../Storage/Dict/DictSlot.h" #include "../Storage/Dict/DictStruct.h" +#include "../Storage/Instances.h" #include "../Platform/Plot.h" #include "../Indicators/DrawIndicator.mqh" #include "../EA.mqh" @@ -73,7 +74,7 @@ struct IndicatorParams; #include "../Storage/Object.h" #include "../Platform/Order.h" #include "../Platform/Orders.h" -#include "../Pattern.mqh" +#include "../Platform/Chart/Pattern.h" // #include "../Profiler.mqh" #include "../Storage/Redis.h" #include "../Refs.mqh" @@ -84,7 +85,7 @@ struct IndicatorParams; #include "../Socket.mqh" #include "../Std.h" #include "../Storage/Singleton.h" -#include "../Strategy.mqh" +#include "../Strategy/Strategy.h" #include "../Storage/String.h" #include "../SummaryReport.mqh" #include "../Exchange/SymbolInfo/SymbolInfo.h" diff --git a/tests/Makefile b/tests/Makefile index e792364f0..ba14b9322 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -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)