From 143e9e6eb3cd6f528a60ea0081ae80b11b20fb25 Mon Sep 17 00:00:00 2001 From: kenorb Date: Mon, 19 Jun 2023 00:47:05 +0100 Subject: [PATCH 01/26] Moves SymbolInfo under Exchange/ --- .../workflows/test-exchange-symbolinfo.yml | 60 +++++++++++++++++++ .github/workflows/test.yml | 1 - Convert.mqh | 6 +- Exchange/Account/AccountMt.h | 2 +- Exchange/Exchange.h | 2 +- .../SymbolInfo/SymbolInfo.define.h | 0 .../SymbolInfo/SymbolInfo.enum.h | 0 .../SymbolInfo/SymbolInfo.enum.symbols.h | 0 .../SymbolInfo/SymbolInfo.extern.h | 4 +- .../SymbolInfo/SymbolInfo.h | 6 +- .../SymbolInfo/SymbolInfo.struct.h | 8 +-- .../SymbolInfo/SymbolInfo.struct.static.h | 10 ++-- Exchange/SymbolInfo/tests/Makefile | 12 ++++ Exchange/SymbolInfo/tests/SymbolInfo.test.cpp | 36 +++++++++++ .../SymbolInfo/tests/SymbolInfo.test.mq4 | 2 +- .../SymbolInfo/tests/SymbolInfo.test.mq5 | 4 +- Indicator/IndicatorData.h | 2 +- Indicator/tests/IndicatorTf.test.mq5 | 2 +- Market.mqh | 4 +- Platform/Order.h | 2 +- Platform/Order.struct.h | 2 +- Platform/Orders.h | 1 + Platform/Platform.h | 2 +- Storage/tests/Database.test.mq5 | 2 +- Tester.mqh | 2 +- Ticker.mqh | 2 +- tests/CompileTest.mq5 | 2 +- 27 files changed, 142 insertions(+), 34 deletions(-) create mode 100644 .github/workflows/test-exchange-symbolinfo.yml rename SymbolInfo.define.h => Exchange/SymbolInfo/SymbolInfo.define.h (100%) rename SymbolInfo.enum.h => Exchange/SymbolInfo/SymbolInfo.enum.h (100%) rename SymbolInfo.enum.symbols.h => Exchange/SymbolInfo/SymbolInfo.enum.symbols.h (100%) rename SymbolInfo.extern.h => Exchange/SymbolInfo/SymbolInfo.extern.h (95%) rename SymbolInfo.mqh => Exchange/SymbolInfo/SymbolInfo.h (99%) rename SymbolInfo.struct.h => Exchange/SymbolInfo/SymbolInfo.struct.h (97%) rename SymbolInfo.struct.static.h => Exchange/SymbolInfo/SymbolInfo.struct.static.h (99%) create mode 100644 Exchange/SymbolInfo/tests/Makefile create mode 100644 Exchange/SymbolInfo/tests/SymbolInfo.test.cpp rename tests/SymbolInfoTest.mq4 => Exchange/SymbolInfo/tests/SymbolInfo.test.mq4 (97%) rename tests/SymbolInfoTest.mq5 => Exchange/SymbolInfo/tests/SymbolInfo.test.mq5 (99%) diff --git a/.github/workflows/test-exchange-symbolinfo.yml b/.github/workflows/test-exchange-symbolinfo.yml new file mode 100644 index 000000000..230dfccc2 --- /dev/null +++ b/.github/workflows/test-exchange-symbolinfo.yml @@ -0,0 +1,60 @@ +--- +name: Test Exchange/SymbolInfo + +# yamllint disable-line rule:truthy +on: + pull_request: + paths: + - 'Exchange/SymbolInfo/**' + - '.github/workflows/test-exchange/symbolinfo.yml' + push: + paths: + - 'Exchange/SymbolInfo/**' + - '.github/workflows/test-exchange/symbolinfo.yml' + +jobs: + + Compile: + runs-on: windows-latest + steps: + - uses: actions/checkout@v3 + - name: Compile + uses: fx31337/mql-compile-action@master + with: + init-platform: true + path: 'Exchange/SymbolInfo/tests' + verbose: true + - name: Print compiled files + run: '(Get-ChildItem -Recurse -Path . -Include *.ex[45]).fullname' + shell: powershell + - name: Upload artifacts (MQL4) + uses: actions/upload-artifact@v3 + with: + name: files-ex4 + path: '**/*.ex4' + - name: Upload artifacts (MQL5) + uses: actions/upload-artifact@v3 + with: + name: files-ex5 + path: '**/*.ex5' + + Tests-MQL4: + defaults: + run: + shell: bash + working-directory: Exchange/SymbolInfo/tests + needs: Compile + runs-on: ubuntu-latest + strategy: + matrix: + test: + - SymbolInfo.test + steps: + - uses: actions/download-artifact@v3 + with: + name: files-ex4 + - name: Run ${{ matrix.test }} + uses: fx31337/mql-tester-action@master + with: + Script: ${{ matrix.test }} + timeout-minutes: 10 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d08552121..7897fbefd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -60,7 +60,6 @@ jobs: - StrategyTest - StrategyTest-RSI - SummaryReportTest - - SymbolInfoTest - TickerTest - TradeTest max-parallel: 4 diff --git a/Convert.mqh b/Convert.mqh index 07f02c2bd..1103756d2 100644 --- a/Convert.mqh +++ b/Convert.mqh @@ -34,9 +34,9 @@ #include "Storage/DateTime.h" #include "Math/Math.extern.h" #include "Platform/Order.enum.h" -#include "SymbolInfo.enum.h" -#include "SymbolInfo.extern.h" -#include "SymbolInfo.struct.static.h" +#include "Exchange/SymbolInfo/SymbolInfo.enum.h" +#include "Exchange/SymbolInfo/SymbolInfo.extern.h" +#include "Exchange/SymbolInfo/SymbolInfo.struct.static.h" /** * Class to provide conversion methods. diff --git a/Exchange/Account/AccountMt.h b/Exchange/Account/AccountMt.h index eb53bed17..36f7fa12f 100644 --- a/Exchange/Account/AccountMt.h +++ b/Exchange/Account/AccountMt.h @@ -36,7 +36,7 @@ class AccountMt; #include "../../Platform/Order.struct.h" #include "../../Platform/Orders.h" #include "../../Serializer/Serializer.h" -#include "../../SymbolInfo.mqh" +#include "../../Exchange/SymbolInfo/SymbolInfo.h" #include "../../Task/TaskCondition.enum.h" #include "../../Trade.struct.h" #include "Account.define.h" diff --git a/Exchange/Exchange.h b/Exchange/Exchange.h index 784416e9b..cefd5847b 100644 --- a/Exchange/Exchange.h +++ b/Exchange/Exchange.h @@ -29,7 +29,7 @@ // Includes. #include "Account/Account.h" #include "../Storage/Dict/DictObject.h" -#include "../SymbolInfo.mqh" +#include "../Exchange/SymbolInfo/SymbolInfo.h" #include "../Trade.mqh" #include "Exchange.struct.h" diff --git a/SymbolInfo.define.h b/Exchange/SymbolInfo/SymbolInfo.define.h similarity index 100% rename from SymbolInfo.define.h rename to Exchange/SymbolInfo/SymbolInfo.define.h diff --git a/SymbolInfo.enum.h b/Exchange/SymbolInfo/SymbolInfo.enum.h similarity index 100% rename from SymbolInfo.enum.h rename to Exchange/SymbolInfo/SymbolInfo.enum.h diff --git a/SymbolInfo.enum.symbols.h b/Exchange/SymbolInfo/SymbolInfo.enum.symbols.h similarity index 100% rename from SymbolInfo.enum.symbols.h rename to Exchange/SymbolInfo/SymbolInfo.enum.symbols.h diff --git a/SymbolInfo.extern.h b/Exchange/SymbolInfo/SymbolInfo.extern.h similarity index 95% rename from SymbolInfo.extern.h rename to Exchange/SymbolInfo/SymbolInfo.extern.h index d95799228..e6577ec2b 100644 --- a/SymbolInfo.extern.h +++ b/Exchange/SymbolInfo/SymbolInfo.extern.h @@ -21,9 +21,9 @@ */ // Includes. -#include "Platform/Order.enum.h" +#include "../../Platform/Order.enum.h" #include "SymbolInfo.enum.h" -#include "Tick/Tick.struct.h" +#include "../../Tick/Tick.struct.h" // Define external global functions. #ifndef __MQL__ diff --git a/SymbolInfo.mqh b/Exchange/SymbolInfo/SymbolInfo.h similarity index 99% rename from SymbolInfo.mqh rename to Exchange/SymbolInfo/SymbolInfo.h index 6e7581194..f62ed4443 100644 --- a/SymbolInfo.mqh +++ b/Exchange/SymbolInfo/SymbolInfo.h @@ -37,9 +37,9 @@ class Log; class SymbolInfo; // Includes. -#include "Log.mqh" -#include "Serializer/Serializer.h" -#include "Serializer/SerializerNode.enum.h" +#include "../../Log.mqh" +#include "../../Serializer/Serializer.h" +#include "../../Serializer/SerializerNode.enum.h" /** * Class to provide symbol information. diff --git a/SymbolInfo.struct.h b/Exchange/SymbolInfo/SymbolInfo.struct.h similarity index 97% rename from SymbolInfo.struct.h rename to Exchange/SymbolInfo/SymbolInfo.struct.h index 46c91e477..866fcd088 100644 --- a/SymbolInfo.struct.h +++ b/Exchange/SymbolInfo/SymbolInfo.struct.h @@ -31,11 +31,11 @@ #endif // Includes. -#include "Serializer/Serializable.h" -#include "Serializer/Serializer.h" -#include "Std.h" +#include "../../Serializer/Serializable.h" +#include "../../Serializer/Serializer.h" +#include "../../Std.h" #include "SymbolInfo.struct.static.h" -#include "Tick/Tick.struct.h" +#include "../../Tick/Tick.struct.h" // Defines struct to store symbol data. struct SymbolInfoEntry diff --git a/SymbolInfo.struct.static.h b/Exchange/SymbolInfo/SymbolInfo.struct.static.h similarity index 99% rename from SymbolInfo.struct.static.h rename to Exchange/SymbolInfo/SymbolInfo.struct.static.h index d6ff0c70e..2ab5f6257 100644 --- a/SymbolInfo.struct.static.h +++ b/Exchange/SymbolInfo/SymbolInfo.struct.static.h @@ -25,13 +25,13 @@ #pragma once #endif -#include "Platform/MQL5.mqh" -#include "Platform/Order.enum.h" -#include "Platform/Platform.extern.h" -#include "Std.h" +#include "../../Platform/MQL5.mqh" +#include "../../Platform/Order.enum.h" +#include "../../Platform/Platform.extern.h" +#include "../../Std.h" #include "SymbolInfo.enum.h" #include "SymbolInfo.extern.h" -#include "Tick/Tick.struct.h" +#include "../../Tick/Tick.struct.h" /** * Struct to provide symbol information. diff --git a/Exchange/SymbolInfo/tests/Makefile b/Exchange/SymbolInfo/tests/Makefile new file mode 100644 index 000000000..e792364f0 --- /dev/null +++ b/Exchange/SymbolInfo/tests/Makefile @@ -0,0 +1,12 @@ +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 + +all: $(OBJS) + +%.o: %.cpp + $(CC) $(CFLAGS) -c $< -o $@ + +clean: + rm -v $(OBJS) diff --git a/Exchange/SymbolInfo/tests/SymbolInfo.test.cpp b/Exchange/SymbolInfo/tests/SymbolInfo.test.cpp new file mode 100644 index 000000000..2ac8589ce --- /dev/null +++ b/Exchange/SymbolInfo/tests/SymbolInfo.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 SymbolInfo class. + */ + +// Includes. +#include "../SymbolInfo.h" +#include "../../../Platform/Platform.h" + +int main(int argc, char **argv) { + + // @todo + + return 0; +} diff --git a/tests/SymbolInfoTest.mq4 b/Exchange/SymbolInfo/tests/SymbolInfo.test.mq4 similarity index 97% rename from tests/SymbolInfoTest.mq4 rename to Exchange/SymbolInfo/tests/SymbolInfo.test.mq4 index 7ef7c4c2c..972bc282e 100644 --- a/tests/SymbolInfoTest.mq4 +++ b/Exchange/SymbolInfo/tests/SymbolInfo.test.mq4 @@ -25,4 +25,4 @@ */ // Includes. -#include "SymbolInfoTest.mq5" +#include "SymbolInfo.test.mq5" diff --git a/tests/SymbolInfoTest.mq5 b/Exchange/SymbolInfo/tests/SymbolInfo.test.mq5 similarity index 99% rename from tests/SymbolInfoTest.mq5 rename to Exchange/SymbolInfo/tests/SymbolInfo.test.mq5 index 3318f213b..55f2e2448 100644 --- a/tests/SymbolInfoTest.mq5 +++ b/Exchange/SymbolInfo/tests/SymbolInfo.test.mq5 @@ -25,8 +25,8 @@ */ // Includes. -#include "../SymbolInfo.mqh" -#include "../Test.mqh" +#include "../SymbolInfo.h" +#include "../../../Test.mqh" /** * Implements OnInit(). diff --git a/Indicator/IndicatorData.h b/Indicator/IndicatorData.h index 80a5b4881..fe415e9df 100644 --- a/Indicator/IndicatorData.h +++ b/Indicator/IndicatorData.h @@ -45,7 +45,7 @@ struct ExternInstantiateIndicatorBufferValueStorageDouble { #include "../Storage/Flags.struct.h" #include "../Storage/IValueStorage.h" #include "../Storage/ItemsHistory.h" -#include "../SymbolInfo.struct.h" +#include "../Exchange/SymbolInfo/SymbolInfo.struct.h" #include "Indicator.enum.h" #include "IndicatorBase.h" #include "IndicatorData.enum.h" diff --git a/Indicator/tests/IndicatorTf.test.mq5 b/Indicator/tests/IndicatorTf.test.mq5 index a136b6801..58f48f951 100644 --- a/Indicator/tests/IndicatorTf.test.mq5 +++ b/Indicator/tests/IndicatorTf.test.mq5 @@ -32,7 +32,7 @@ #include "../../Log.mqh" #include "../../Platform/Platform.h" #include "../../Storage/Dict/DictBase.h" -#include "../../SymbolInfo.mqh" +#include "../../Exchange/SymbolInfo/SymbolInfo.h" #include "../../Test.mqh" #include "../../Util.h" #include "../IndicatorTf.h" diff --git a/Market.mqh b/Market.mqh index b78fa7977..47d7a516c 100644 --- a/Market.mqh +++ b/Market.mqh @@ -28,8 +28,8 @@ #include "Market.struct.h" #include "Math/Math.h" #include "Serializer/Serializer.h" -#include "SymbolInfo.mqh" -#include "SymbolInfo.struct.static.h" +#include "Exchange/SymbolInfo/SymbolInfo.h" +#include "Exchange/SymbolInfo/SymbolInfo.struct.static.h" #include "Task/TaskCondition.enum.h" /** diff --git a/Platform/Order.h b/Platform/Order.h index ef1aa45e8..4e0f14a19 100644 --- a/Platform/Order.h +++ b/Platform/Order.h @@ -47,7 +47,7 @@ class SymbolInfo; #include "../Serializer/SerializerJson.h" #include "../Std.h" #include "../Storage/String.h" -#include "../SymbolInfo.mqh" +#include "../Exchange/SymbolInfo/SymbolInfo.h" #include "../Task/TaskAction.enum.h" /* Defines for backward compatibility. */ diff --git a/Platform/Order.struct.h b/Platform/Order.struct.h index 0b6aa9d61..be4d53b2b 100644 --- a/Platform/Order.struct.h +++ b/Platform/Order.struct.h @@ -35,7 +35,7 @@ #include "Order.enum.h" #include "Platform.extern.h" #include "../Serializer/Serializer.h" -#include "../SymbolInfo.struct.static.h" +#include "../Exchange/SymbolInfo/SymbolInfo.struct.static.h" #include "Terminal.h" #ifndef __MQL5__ diff --git a/Platform/Orders.h b/Platform/Orders.h index 93fc2ded7..6341f2002 100644 --- a/Platform/Orders.h +++ b/Platform/Orders.h @@ -25,6 +25,7 @@ class Orders; // Includes. #include "../Exchange/Account/Account.h" +#include "../Exchange/SymbolInfo/SymbolInfo.struct.static.h" #include "Chart/Chart.struct.static.h" #include "../Log.mqh" #include "../Math/Math.h" diff --git a/Platform/Platform.h b/Platform/Platform.h index 35903ea95..e5910add4 100644 --- a/Platform/Platform.h +++ b/Platform/Platform.h @@ -59,7 +59,7 @@ extern int Bars(CONST_REF_TO(string) _symbol, ENUM_TIMEFRAMES _tf); #include "../Indicators/Tick/Indi_TickProvider.h" #define PLATFORM_DEFAULT_INDICATOR_TICK Indi_TickProvider #endif -#include "../SymbolInfo.struct.static.h" +#include "../Exchange/SymbolInfo/SymbolInfo.struct.static.h" class Platform { // Whether Init() was already called. diff --git a/Storage/tests/Database.test.mq5 b/Storage/tests/Database.test.mq5 index 94d709e79..0ddda6d1d 100644 --- a/Storage/tests/Database.test.mq5 +++ b/Storage/tests/Database.test.mq5 @@ -25,7 +25,7 @@ */ // Need to be include before Database.h. -#include "../../SymbolInfo.mqh" // FOOBAR pragma: keep +#include "../../Exchange/SymbolInfo/SymbolInfo.h" // FOOBAR pragma: keep // Includes. #include "../../Test.mqh" diff --git a/Tester.mqh b/Tester.mqh index 9f4fb4ed3..0538230cf 100644 --- a/Tester.mqh +++ b/Tester.mqh @@ -21,7 +21,7 @@ */ // Includes. -#include "SymbolInfo.mqh" +#include "Exchange/SymbolInfo/SymbolInfo.h" #include "Platform/Terminal.h" /** diff --git a/Ticker.mqh b/Ticker.mqh index 53b7097d7..a1d90d55c 100644 --- a/Ticker.mqh +++ b/Ticker.mqh @@ -30,7 +30,7 @@ class Chart; // Includes. #include "Platform/Chart/Chart.h" #include "Log.mqh" -#include "SymbolInfo.mqh" +#include "Exchange/SymbolInfo/SymbolInfo.h" //#include "Market.mqh" // Define an assert macros. diff --git a/tests/CompileTest.mq5 b/tests/CompileTest.mq5 index 0fc665dbf..e00a17cbd 100644 --- a/tests/CompileTest.mq5 +++ b/tests/CompileTest.mq5 @@ -88,7 +88,7 @@ struct IndicatorParams; #include "../Strategy.mqh" #include "../Storage/String.h" #include "../SummaryReport.mqh" -#include "../SymbolInfo.mqh" +#include "../Exchange/SymbolInfo/SymbolInfo.h" #include "../Task/Task.h" #include "../Task/TaskAction.h" #include "../Task/TaskCondition.h" From e4fdf8cfcae0119a1765f87f5a640927c884644c Mon Sep 17 00:00:00 2001 From: kenorb Date: Tue, 20 Jun 2023 00:09:04 +0100 Subject: [PATCH 02/26] Moves Indi_Pivot to PriceRange/ --- .github/workflows/test-indicators-pricerange.yml | 1 + .github/workflows/test-indicators.yml | 1 - Indicators/{Indi_Pivot.mqh => PriceRange/Indi_Pivot.h} | 8 ++++---- Indicators/PriceRange/includes.h | 1 + Indicators/{ => PriceRange}/tests/Indi_Pivot.test.mq4 | 0 Indicators/{ => PriceRange}/tests/Indi_Pivot.test.mq5 | 6 +++--- Indicators/includes.h | 1 - 7 files changed, 9 insertions(+), 9 deletions(-) rename Indicators/{Indi_Pivot.mqh => PriceRange/Indi_Pivot.h} (97%) rename Indicators/{ => PriceRange}/tests/Indi_Pivot.test.mq4 (100%) rename Indicators/{ => PriceRange}/tests/Indi_Pivot.test.mq5 (92%) diff --git a/.github/workflows/test-indicators-pricerange.yml b/.github/workflows/test-indicators-pricerange.yml index d7f14cf45..1a9b1938d 100644 --- a/.github/workflows/test-indicators-pricerange.yml +++ b/.github/workflows/test-indicators-pricerange.yml @@ -52,6 +52,7 @@ jobs: test: - Indi_Bands.test - Indi_Envelopes.test + - Indi_Pivot.test - Indi_SAR.test steps: - uses: actions/download-artifact@v3 diff --git a/.github/workflows/test-indicators.yml b/.github/workflows/test-indicators.yml index 7a0ffa7dc..2d68e970f 100644 --- a/.github/workflows/test-indicators.yml +++ b/.github/workflows/test-indicators.yml @@ -86,7 +86,6 @@ jobs: - Indi_Momentum.test - Indi_OBV.test - Indi_OsMA.test - - Indi_Pivot.test - Indi_PriceChannel.test - Indi_PriceFeeder.test - Indi_PriceVolumeTrend.test diff --git a/Indicators/Indi_Pivot.mqh b/Indicators/PriceRange/Indi_Pivot.h similarity index 97% rename from Indicators/Indi_Pivot.mqh rename to Indicators/PriceRange/Indi_Pivot.h index 3a3f4e8eb..f19c7fa4a 100644 --- a/Indicators/Indi_Pivot.mqh +++ b/Indicators/PriceRange/Indi_Pivot.h @@ -21,10 +21,10 @@ */ // Includes. -#include "../Bar.struct.h" -#include "../Indicator/Indicator.struct.h" -#include "../Serializer/Serializer.h" -#include "Special/Indi_Math.mqh" +#include "../../Bar.struct.h" +#include "../../Indicator/Indicator.struct.h" +#include "../../Serializer/Serializer.h" +#include "../Special/Indi_Math.mqh" // Structs. struct IndiPivotParams : IndicatorParams { diff --git a/Indicators/PriceRange/includes.h b/Indicators/PriceRange/includes.h index 9275ab9b4..b4f73d5bc 100644 --- a/Indicators/PriceRange/includes.h +++ b/Indicators/PriceRange/includes.h @@ -28,4 +28,5 @@ // Price indicators. #include "Indi_Bands.h" #include "Indi_Envelopes.h" +#include "Indi_Pivot.h" #include "Indi_SAR.h" diff --git a/Indicators/tests/Indi_Pivot.test.mq4 b/Indicators/PriceRange/tests/Indi_Pivot.test.mq4 similarity index 100% rename from Indicators/tests/Indi_Pivot.test.mq4 rename to Indicators/PriceRange/tests/Indi_Pivot.test.mq4 diff --git a/Indicators/tests/Indi_Pivot.test.mq5 b/Indicators/PriceRange/tests/Indi_Pivot.test.mq5 similarity index 92% rename from Indicators/tests/Indi_Pivot.test.mq5 rename to Indicators/PriceRange/tests/Indi_Pivot.test.mq5 index 8aa9a0135..39c819b81 100644 --- a/Indicators/tests/Indi_Pivot.test.mq5 +++ b/Indicators/PriceRange/tests/Indi_Pivot.test.mq5 @@ -20,9 +20,9 @@ */ // Includes. -#include "../../Platform/Platform.h" -#include "../../Test.mqh" -#include "../Indi_Pivot.mqh" +#include "../../../Platform/Platform.h" +#include "../../../Test.mqh" +#include "../Indi_Pivot.h" /** * @file diff --git a/Indicators/includes.h b/Indicators/includes.h index 02c2c29e5..e7c2d0799 100644 --- a/Indicators/includes.h +++ b/Indicators/includes.h @@ -62,7 +62,6 @@ #include "Indi_Momentum.mqh" #include "Indi_OBV.mqh" #include "Indi_OsMA.mqh" -#include "Indi_Pivot.mqh" #include "Indi_PriceChannel.mqh" #include "Indi_PriceFeeder.mqh" #include "Indi_PriceVolumeTrend.mqh" From e5ea52c45eeec3b988b857758c9ab44838ee4373 Mon Sep 17 00:00:00 2001 From: kenorb Date: Wed, 21 Jun 2023 21:09:31 +0100 Subject: [PATCH 03/26] Adds Indicators.test.cpp --- Indicators/tests/Indicators.test.cpp | 35 ++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Indicators/tests/Indicators.test.cpp diff --git a/Indicators/tests/Indicators.test.cpp b/Indicators/tests/Indicators.test.cpp new file mode 100644 index 000000000..2b8c62847 --- /dev/null +++ b/Indicators/tests/Indicators.test.cpp @@ -0,0 +1,35 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 all indicators. + */ + +// Includes. +#include "../../Platform/Platform.h" +#include "../includes.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} From 2d458f6602e645dd19f53a5c655f06202e6433ae Mon Sep 17 00:00:00 2001 From: kenorb Date: Wed, 21 Jun 2023 23:31:58 +0100 Subject: [PATCH 04/26] Adds Database enums and externs --- Storage/Database.enum.h | 30 +++++++++++++++++++ Storage/Database.extern.h | 63 +++++++++++++++++++++++++++++++++++++++ Storage/Database.h | 4 ++- 3 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 Storage/Database.enum.h create mode 100644 Storage/Database.extern.h diff --git a/Storage/Database.enum.h b/Storage/Database.enum.h new file mode 100644 index 000000000..dd755b9bf --- /dev/null +++ b/Storage/Database.enum.h @@ -0,0 +1,30 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 . + * + */ + +// @docs: https://www.mql5.com/en/docs/database/databaseopen#enum_database_open_flags +enum ENUM_DATABASE_OPEN_FLAGS { + DATABASE_OPEN_READONLY, // Read only. + DATABASE_OPEN_READWRITE, // Open for reading and writing. + DATABASE_OPEN_CREATE, // Create the file on a disk if necessary. + DATABASE_OPEN_MEMORY, // Create a database in RAM. + DATABASE_OPEN_COMMON, // The file is in the common folder of all terminals. +}; diff --git a/Storage/Database.extern.h b/Storage/Database.extern.h new file mode 100644 index 000000000..1376330ac --- /dev/null +++ b/Storage/Database.extern.h @@ -0,0 +1,63 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 . + * + */ + +// Includes. + +// Define external global functions. +#ifndef __MQL__ +// Closes a database. +// @docs: https://www.mql5.com/en/docs/database/databaseclose +void DatabaseClose(int database // database handle received in DatabaseOpen +); +// Executes a request to a specified database. +// @docs: https://www.mql5.com/en/docs/database/databaseexecute +extern bool DatabaseExecute(int database, // database handle received in DatabaseOpen + string sql // SQL request +); + +// Opens or creates a database in a specified file. +// @docs: https://www.mql5.com/en/docs/database/databaseopen +int DatabaseOpen(string filename, // file name + uint flags // combination of flags +); + +// Starts transaction execution. +// @docs: https://www.mql5.com/en/docs/database/databasetransactionbegin +bool DatabaseTransactionBegin(int database // database handle received in DatabaseOpen +); + +// Completes transaction execution. +// @docs: https://www.mql5.com/en/docs/database/databasetransactioncommit +extern bool DatabaseTransactionCommit(int database // database handle received in DatabaseOpen +); + +// Checks the presence of the table in a database. +// @docs: https://www.mql5.com/en/docs/database/databasetableexists +bool DatabaseTableExists(int database, // database handle received in DatabaseOpen + string table // table name +); + +// Rolls back transactions. +// @docs: https://www.mql5.com/en/docs/database/databasetransactionrollback +extern bool DatabaseTransactionRollback(int database // database handle received in DatabaseOpen +); +#endif diff --git a/Storage/Database.h b/Storage/Database.h index 53cee9ac8..ac0293a12 100644 --- a/Storage/Database.h +++ b/Storage/Database.h @@ -35,6 +35,8 @@ // Includes. #include "../Math/MatrixMini.h" #include "../Storage/Dict/DictStruct.h" +#include "Database.enum.h" +#include "Database.extern.h" #include "Database.struct.h" class Database { @@ -175,7 +177,7 @@ bool ImportData(const string _name, MatrixMini2d &data) { for (x = 0; x < data.SizeX(); ++x) { _query += data.Get(x, y) + (x < data.SizeX() - 1 ? ", " : ""); } - _query += ")" + (y < data.SizeY() - 1 ? ",\n" : ""); + _query += ")" + (string)(y < data.SizeY() - 1 ? ",\n" : ""); } #ifdef __debug__ From 1d264b44f0f1336ccde0bcc306febae8a0efc889 Mon Sep 17 00:00:00 2001 From: kenorb Date: Wed, 21 Jun 2023 23:36:26 +0100 Subject: [PATCH 05/26] SerializerBinary: Comments missing logger --- Serializer/SerializerBinary.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Serializer/SerializerBinary.h b/Serializer/SerializerBinary.h index 003fa6163..789c9adeb 100644 --- a/Serializer/SerializerBinary.h +++ b/Serializer/SerializerBinary.h @@ -115,7 +115,7 @@ class SerializerBinary { Serializer serializer(node, Unserialize); - if (logger != NULL) serializer.Logger().Link(logger); + // if (logger != NULL) serializer.Logger().Link(logger); // We don't use result. We parse data as it is. obj.Serialize(serializer); From 00e04851f9d38755519100de5de782ef007fdb91 Mon Sep 17 00:00:00 2001 From: kenorb Date: Wed, 21 Jun 2023 23:59:06 +0100 Subject: [PATCH 06/26] Indicators: Improves #ifdef condition and forward declaration syntax --- Indicators/Indi_AC.mqh | 21 ++++++++++++--------- Indicators/Indi_AD.mqh | 8 ++++++++ Indicators/Indi_ADX.mqh | 3 +++ Indicators/Indi_AO.mqh | 3 +++ Indicators/Indi_ATR.mqh | 3 +++ Indicators/Indi_BWMFI.mqh | 3 +++ Indicators/Indi_BearsPower.mqh | 3 +++ Indicators/Indi_BullsPower.mqh | 3 +++ Indicators/Indi_CCI.mqh | 3 +++ Indicators/Indi_DeMarker.mqh | 3 +++ Indicators/Indi_Force.mqh | 3 +++ Indicators/Indi_Fractals.mqh | 3 +++ Indicators/Indi_Gator.mqh | 3 +++ Indicators/Indi_Ichimoku.mqh | 3 +++ Indicators/Indi_MFI.mqh | 3 +++ Indicators/Indi_Momentum.mqh | 3 +++ Indicators/Indi_OBV.mqh | 3 +++ Indicators/Indi_OsMA.mqh | 3 +++ Indicators/Indi_RVI.mqh | 3 +++ Indicators/Indi_StdDev.mqh | 3 +++ Indicators/Oscillator/Indi_MACD.h | 2 +- Indicators/Oscillator/Indi_Stochastic.h | 3 +++ Indicators/Oscillator/Indi_WPR.h | 3 +++ Indicators/Price/Indi_MA.h | 2 +- Indicators/PriceMulti/Indi_Alligator.h | 3 +++ Indicators/PriceRange/Indi_Bands.h | 3 +++ Indicators/PriceRange/Indi_Envelopes.h | 3 +++ Indicators/PriceRange/Indi_SAR.h | 3 +++ 28 files changed, 94 insertions(+), 11 deletions(-) diff --git a/Indicators/Indi_AC.mqh b/Indicators/Indi_AC.mqh index c54961599..f323fa4f1 100644 --- a/Indicators/Indi_AC.mqh +++ b/Indicators/Indi_AC.mqh @@ -29,6 +29,17 @@ #include "../Indicator/Indicator.h" #include "../Storage/Dict/Buffer/BufferStruct.h" +#ifndef __MQL4__ +// Forward declaration. +class Indi_AC; + +// Defines global functions (for MQL4 backward compability). +double iAC(string _symbol, int _tf, int _shift) { + ResetLastError(); + return Indi_AC::iAC(_symbol, (ENUM_TIMEFRAMES)_tf, _shift); +} +#endif + // Structs. struct IndiACParams : IndicatorParams { // Struct constructor. @@ -139,16 +150,8 @@ class Indi_AC : public Indicator { if (!Objects::TryGet(_key, _ptr)) { _ptr = Objects::Set(_key, new Indi_AC()); // Assigning the same candle indicator for AC as in _indi. - _ptr.SetDataSource(_indi PTR_DEREF GetCandle()); + _ptr PTR_DEREF SetDataSource(_indi PTR_DEREF GetCandle()); } return _ptr; } }; - -#ifndef __MQL4__ -// Defines global functions (for MQL4 backward compability). -double iAC(string _symbol, int _tf, int _shift) { - ResetLastError(); - return Indi_AC::iAC(_symbol, (ENUM_TIMEFRAMES)_tf, _shift); -} -#endif diff --git a/Indicators/Indi_AD.mqh b/Indicators/Indi_AD.mqh index 30efa4106..4147ab62e 100644 --- a/Indicators/Indi_AD.mqh +++ b/Indicators/Indi_AD.mqh @@ -20,10 +20,18 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Indicator/Indicator.h" #ifndef __MQL4__ +// Forward declaration. +class Indi_AD; + // Defines global functions (for MQL4 backward compability). double iAD(string _symbol, int _tf, int _shift) { ResetLastError(); diff --git a/Indicators/Indi_ADX.mqh b/Indicators/Indi_ADX.mqh index e2cdd7702..c904740f2 100644 --- a/Indicators/Indi_ADX.mqh +++ b/Indicators/Indi_ADX.mqh @@ -25,6 +25,9 @@ #include "Price/Indi_Price.h" #ifndef __MQL4__ +// Forward declaration. +class Indi_ADX; + // Defines global functions (for MQL4 backward compability). double iADX(string _symbol, int _tf, int _period, int _ap, int _mode, int _shift) { ResetLastError(); diff --git a/Indicators/Indi_AO.mqh b/Indicators/Indi_AO.mqh index c2d972279..bfff08ce4 100644 --- a/Indicators/Indi_AO.mqh +++ b/Indicators/Indi_AO.mqh @@ -24,6 +24,9 @@ #include "../Indicator/Indicator.h" #ifndef __MQL4__ +// Forward declaration. +class Indi_AO; + // Defines global functions (for MQL4 backward compability). double iAO(string _symbol, int _tf, int _shift) { ResetLastError(); diff --git a/Indicators/Indi_ATR.mqh b/Indicators/Indi_ATR.mqh index 55043c5b0..19113ce3f 100644 --- a/Indicators/Indi_ATR.mqh +++ b/Indicators/Indi_ATR.mqh @@ -24,6 +24,9 @@ #include "../Indicator/Indicator.h" #ifndef __MQL4__ +// Forward declaration. +class Indi_ATR; + // Defines global functions (for MQL4 backward compability). double iATR(string _symbol, int _tf, int _period, int _shift) { ResetLastError(); diff --git a/Indicators/Indi_BWMFI.mqh b/Indicators/Indi_BWMFI.mqh index ee7fb57e5..13ca86bc0 100644 --- a/Indicators/Indi_BWMFI.mqh +++ b/Indicators/Indi_BWMFI.mqh @@ -24,6 +24,9 @@ #include "../Indicator/Indicator.h" #ifndef __MQL4__ +// Forward declaration. +class Indi_BWMFI; + // Defines global functions (for MQL4 backward compability). double iBWMFI(string _symbol, int _tf, int _shift) { ResetLastError(); diff --git a/Indicators/Indi_BearsPower.mqh b/Indicators/Indi_BearsPower.mqh index 2301ac84b..6dea2d286 100644 --- a/Indicators/Indi_BearsPower.mqh +++ b/Indicators/Indi_BearsPower.mqh @@ -24,6 +24,9 @@ #include "../Indicator/Indicator.h" #ifndef __MQL4__ +// Forward declaration. +class Indi_BearsPower; + // Defines global functions (for MQL4 backward compability). double iBearsPower(string _symbol, int _tf, int _period, int _ap, int _shift) { ResetLastError(); diff --git a/Indicators/Indi_BullsPower.mqh b/Indicators/Indi_BullsPower.mqh index 0efe8c5e2..16ad2b2d6 100644 --- a/Indicators/Indi_BullsPower.mqh +++ b/Indicators/Indi_BullsPower.mqh @@ -24,6 +24,9 @@ #include "../Indicator/Indicator.h" #ifndef __MQL4__ +// Forward declaration. +class Indi_BullsPower; + // Defines global functions (for MQL4 backward compability). double iBullsPower(string _symbol, int _tf, int _period, int _ap, int _shift) { ResetLastError(); diff --git a/Indicators/Indi_CCI.mqh b/Indicators/Indi_CCI.mqh index 81901f1cb..6584925db 100644 --- a/Indicators/Indi_CCI.mqh +++ b/Indicators/Indi_CCI.mqh @@ -27,6 +27,9 @@ #include "Price/Indi_Price.h" #ifndef __MQL4__ +// Forward declaration. +class Indi_CCI; + // Defines global functions (for MQL4 backward compability). double iCCI(string _symbol, int _tf, int _period, int _ap, int _shift) { ResetLastError(); diff --git a/Indicators/Indi_DeMarker.mqh b/Indicators/Indi_DeMarker.mqh index 61ae7f172..dad279880 100644 --- a/Indicators/Indi_DeMarker.mqh +++ b/Indicators/Indi_DeMarker.mqh @@ -24,6 +24,9 @@ #include "../Indicator/Indicator.h" #ifndef __MQL4__ +// Forward declaration. +class Indi_DeMarker; + // Defines global functions (for MQL4 backward compability). double iDeMarker(string _symbol, int _tf, int _period, int _shift) { ResetLastError(); diff --git a/Indicators/Indi_Force.mqh b/Indicators/Indi_Force.mqh index 773f44c16..9c599a1d7 100644 --- a/Indicators/Indi_Force.mqh +++ b/Indicators/Indi_Force.mqh @@ -35,6 +35,9 @@ #include "../Indicator/Indicator.h" #ifndef __MQL4__ +// Forward declaration. +class Indi_Force; + // Defines global functions (for MQL4 backward compability). double iForce(string _symbol, int _tf, int _period, int _ma_method, int _ap, int _shift) { ResetLastError(); diff --git a/Indicators/Indi_Fractals.mqh b/Indicators/Indi_Fractals.mqh index ed7a2636a..4eb4a0f27 100644 --- a/Indicators/Indi_Fractals.mqh +++ b/Indicators/Indi_Fractals.mqh @@ -24,6 +24,9 @@ #include "../Indicator/Indicator.h" #ifndef __MQL4__ +// Forward declaration. +class Indi_Fractals; + // Defines global functions (for MQL4 backward compability). double iFractals(string _symbol, int _tf, int _mode, int _shift) { ResetLastError(); diff --git a/Indicators/Indi_Gator.mqh b/Indicators/Indi_Gator.mqh index 510a30ae9..a3088f23b 100644 --- a/Indicators/Indi_Gator.mqh +++ b/Indicators/Indi_Gator.mqh @@ -31,6 +31,9 @@ #include "../Indicator/Indicator.h" #ifndef __MQL4__ +// Forward declaration. +class Indi_Gator; + // Defines global functions (for MQL4 backward compability). double iGator(string _symbol, int _tf, int _jp, int _js, int _tp, int _ts, int _lp, int _ls, int _ma_method, int _ap, int _mode, int _shift) { diff --git a/Indicators/Indi_Ichimoku.mqh b/Indicators/Indi_Ichimoku.mqh index a5b790165..8541d85a6 100644 --- a/Indicators/Indi_Ichimoku.mqh +++ b/Indicators/Indi_Ichimoku.mqh @@ -24,6 +24,9 @@ #include "../Indicator/Indicator.h" #ifndef __MQL4__ +// Forward declaration. +class Indi_Ichimoku; + // Defines global functions (for MQL4 backward compability). double iIchimoku(string _symbol, int _tf, int _ts, int _ks, int _ssb, int _mode, int _shift) { ResetLastError(); diff --git a/Indicators/Indi_MFI.mqh b/Indicators/Indi_MFI.mqh index 93e712ffb..c38cf4d72 100644 --- a/Indicators/Indi_MFI.mqh +++ b/Indicators/Indi_MFI.mqh @@ -24,6 +24,9 @@ #include "../Indicator/Indicator.h" #ifndef __MQL4__ +// Forward declaration. +class Indi_MFI; + // Defines global functions (for MQL4 backward compability). double iMFI(string _symbol, int _tf, int _period, int _shift) { ResetLastError(); diff --git a/Indicators/Indi_Momentum.mqh b/Indicators/Indi_Momentum.mqh index 5b9eeca44..953d63d0f 100644 --- a/Indicators/Indi_Momentum.mqh +++ b/Indicators/Indi_Momentum.mqh @@ -34,6 +34,9 @@ #include "Indi_PriceFeeder.mqh" #ifndef __MQL4__ +// Forward declaration. +class Indi_Momentum; + // Defines global functions (for MQL4 backward compability). double iMomentum(string _symbol, int _tf, int _period, int _ap, int _shift) { ResetLastError(); diff --git a/Indicators/Indi_OBV.mqh b/Indicators/Indi_OBV.mqh index 3578134e4..b9128b1f2 100644 --- a/Indicators/Indi_OBV.mqh +++ b/Indicators/Indi_OBV.mqh @@ -24,6 +24,9 @@ #include "../Indicator/Indicator.h" #ifndef __MQL4__ +// Forward declaration. +class Indi_OBV; + // Defines global functions (for MQL4 backward compability). double iOBV(string _symbol, int _tf, int _av, int _shift) { ResetLastError(); diff --git a/Indicators/Indi_OsMA.mqh b/Indicators/Indi_OsMA.mqh index f4f85b0da..60587bda7 100644 --- a/Indicators/Indi_OsMA.mqh +++ b/Indicators/Indi_OsMA.mqh @@ -24,6 +24,9 @@ #include "../Indicator/Indicator.h" #ifndef __MQL4__ +// Forward declaration. +class Indi_OsMA; + // Defines global functions (for MQL4 backward compability). double iOsMA(string _symbol, int _tf, int _ema_fp, int _ema_sp, int _signal_period, int _ap, int _shift) { ResetLastError(); diff --git a/Indicators/Indi_RVI.mqh b/Indicators/Indi_RVI.mqh index 00f1f4ad7..07a0a5bb1 100644 --- a/Indicators/Indi_RVI.mqh +++ b/Indicators/Indi_RVI.mqh @@ -24,6 +24,9 @@ #include "../Indicator/Indicator.h" #ifndef __MQL4__ +// Forward declaration. +class Indi_RVI; + // Defines global functions (for MQL4 backward compability). double iRVI(string _symbol, int _tf, int _period, int _mode, int _shift) { ResetLastError(); diff --git a/Indicators/Indi_StdDev.mqh b/Indicators/Indi_StdDev.mqh index 3be952ed0..53078a1e4 100644 --- a/Indicators/Indi_StdDev.mqh +++ b/Indicators/Indi_StdDev.mqh @@ -34,6 +34,9 @@ #include "Price/Indi_MA.h" #ifndef __MQL4__ +// Forward declaration. +class Indi_StdDev; + // Defines global functions (for MQL4 backward compability). double iStdDev(string _symbol, int _tf, int _ma_period, int _ma_shift, int _ma_method, int _ap, int _shift) { ResetLastError(); diff --git a/Indicators/Oscillator/Indi_MACD.h b/Indicators/Oscillator/Indi_MACD.h index d93fc3780..fa192afe0 100644 --- a/Indicators/Oscillator/Indi_MACD.h +++ b/Indicators/Oscillator/Indi_MACD.h @@ -23,7 +23,7 @@ // Includes. #include "../../Indicator/Indicator.h" -#ifdef __MQL5__ +#ifndef __MQL4__ // Forward declaration. class Indi_MACD; diff --git a/Indicators/Oscillator/Indi_Stochastic.h b/Indicators/Oscillator/Indi_Stochastic.h index 7893f4ff8..156ddc379 100644 --- a/Indicators/Oscillator/Indi_Stochastic.h +++ b/Indicators/Oscillator/Indi_Stochastic.h @@ -34,6 +34,9 @@ enum ENUM_STO_PRICE { #endif #ifndef __MQL4__ +// Forward declaration. +class Indi_Stochastic; + // Defines global functions (for MQL4 backward compability). double iStochastic(string _symbol, int _tf, int _kperiod, int _dperiod, int _slowing, int _ma_method, int _pf, int _mode, int _shift) { diff --git a/Indicators/Oscillator/Indi_WPR.h b/Indicators/Oscillator/Indi_WPR.h index 3ed9b7c9e..24253b345 100644 --- a/Indicators/Oscillator/Indi_WPR.h +++ b/Indicators/Oscillator/Indi_WPR.h @@ -25,6 +25,9 @@ #include "../../Platform/Terminal.h" #ifndef __MQL4__ +// Forward declaration. +class Indi_WPR; + // Defines global functions (for MQL4 backward compability). double iWPR(string _symbol, int _tf, int _period, int _shift) { ResetLastError(); diff --git a/Indicators/Price/Indi_MA.h b/Indicators/Price/Indi_MA.h index 16dcd6f57..ad744a073 100644 --- a/Indicators/Price/Indi_MA.h +++ b/Indicators/Price/Indi_MA.h @@ -44,7 +44,7 @@ enum ENUM_MA_METHOD { }; #endif -#ifdef __MQL5__ +#ifndef __MQL4__ // Forward declaration. class Indi_MA; diff --git a/Indicators/PriceMulti/Indi_Alligator.h b/Indicators/PriceMulti/Indi_Alligator.h index 47ee1efe3..a286c5d6d 100644 --- a/Indicators/PriceMulti/Indi_Alligator.h +++ b/Indicators/PriceMulti/Indi_Alligator.h @@ -25,6 +25,9 @@ #include "../Price/Indi_MA.h" #ifndef __MQL4__ +// Forward declaration. +class Indi_Alligator; + // Defines global functions (for MQL4 backward compability). double iAlligator(string _symbol, int _tf, int _jp, int _js, int _tp, int _ts, int _lp, int _ls, int _ma_method, int _ap, int _mode, int _shift) { diff --git a/Indicators/PriceRange/Indi_Bands.h b/Indicators/PriceRange/Indi_Bands.h index 2f54bea7d..9207bcb48 100644 --- a/Indicators/PriceRange/Indi_Bands.h +++ b/Indicators/PriceRange/Indi_Bands.h @@ -31,6 +31,9 @@ #include "../Price/Indi_Price.h" #ifndef __MQL4__ +// Forward declaration. +class Indi_Bands; + // Defines global functions (for MQL4 backward compability). double iBands(string _symbol, int _tf, int _period, double _deviation, int _bands_shift, int _ap, int _mode, int _shift) { diff --git a/Indicators/PriceRange/Indi_Envelopes.h b/Indicators/PriceRange/Indi_Envelopes.h index 3ccd7eedf..a9c23ee7c 100644 --- a/Indicators/PriceRange/Indi_Envelopes.h +++ b/Indicators/PriceRange/Indi_Envelopes.h @@ -28,6 +28,9 @@ #include "../Price/Indi_Price.h" #ifndef __MQL4__ +// Forward declaration. +class Indi_Envelopes; + // Defines global functions (for MQL4 backward compability). double iEnvelopes(string _symbol, int _tf, int _period, int _ma_method, int _ma_shift, int _ap, double _deviation, int _mode, int _shift) { diff --git a/Indicators/PriceRange/Indi_SAR.h b/Indicators/PriceRange/Indi_SAR.h index c8c3bc8ce..9ff35dbc8 100644 --- a/Indicators/PriceRange/Indi_SAR.h +++ b/Indicators/PriceRange/Indi_SAR.h @@ -24,6 +24,9 @@ #include "../../Indicator/Indicator.h" #ifndef __MQL4__ +// Forward declaration. +class Indi_SAR; + // Defines global functions (for MQL4 backward compability). double iSAR(string _symbol, int _tf, double _step, double _max, int _shift) { ResetLastError(); From 4624e222dffd10c11eb6f6fedc2994b930bb258f Mon Sep 17 00:00:00 2001 From: kenorb Date: Thu, 22 Jun 2023 00:00:15 +0100 Subject: [PATCH 07/26] Indicators: Code reformats --- Indicators/Oscillator/Indi_MACD.h | 4 ++-- Indicators/Oscillator/Indi_RSI.h | 6 +++--- Indicators/Oscillator/Indi_Stochastic.h | 8 ++++---- Indicators/Oscillator/Indi_WPR.h | 4 ++-- Indicators/Price/Indi_AppliedPrice.h | 2 +- Indicators/Price/Indi_Price.h | 2 +- Indicators/PriceMulti/Indi_Alligator.h | 2 +- Indicators/PriceRange/Indi_Bands.h | 11 +++++------ Indicators/PriceRange/Indi_Envelopes.h | 7 +++---- Indicators/PriceRange/Indi_SAR.h | 2 +- Indicators/Tick/Indi_TickMt.h | 2 +- 11 files changed, 24 insertions(+), 26 deletions(-) diff --git a/Indicators/Oscillator/Indi_MACD.h b/Indicators/Oscillator/Indi_MACD.h index fa192afe0..bdf3a2992 100644 --- a/Indicators/Oscillator/Indi_MACD.h +++ b/Indicators/Oscillator/Indi_MACD.h @@ -100,11 +100,11 @@ class Indi_MACD : public Indicator { #ifdef __MQL__ #ifdef __MQL4__ return ::iMACD(_symbol, _tf, _ema_fast_period, _ema_slow_period, _signal_period, _applied_price, _mode, _shift); -#else // __MQL5__ +#else // __MQL5__ INDICATOR_BUILTIN_CALL_AND_RETURN( ::iMACD(_symbol, _tf, _ema_fast_period, _ema_slow_period, _signal_period, _applied_price), _mode, _shift); #endif -#else // Non-MQL. +#else // Non-MQL. // @todo: Use Platform class. RUNTIME_ERROR( "Not implemented. Please use an On-Indicator mode and attach " diff --git a/Indicators/Oscillator/Indi_RSI.h b/Indicators/Oscillator/Indi_RSI.h index 34650fc5a..36948b52a 100644 --- a/Indicators/Oscillator/Indi_RSI.h +++ b/Indicators/Oscillator/Indi_RSI.h @@ -21,8 +21,8 @@ */ // Includes. -#include "../../Storage/Dict/DictStruct.h" #include "../../Indicator/Indicator.h" +#include "../../Storage/Dict/DictStruct.h" #include "../Price/Indi_Price.h" // Structs. @@ -113,10 +113,10 @@ class Indi_RSI : public Indicator { #ifdef __MQL__ #ifdef __MQL4__ return ::iRSI(_symbol, _tf, _period, _applied_price, _shift); -#else // __MQL5__ +#else // __MQL5__ INDICATOR_BUILTIN_CALL_AND_RETURN(::iRSI(_symbol, _tf, _period, _applied_price), 0, _shift); #endif -#else // Non-MQL. +#else // Non-MQL. // @todo: Use Platform class. RUNTIME_ERROR( "Not implemented. Please use an On-Indicator mode and attach " diff --git a/Indicators/Oscillator/Indi_Stochastic.h b/Indicators/Oscillator/Indi_Stochastic.h index 156ddc379..d8eb72b4c 100644 --- a/Indicators/Oscillator/Indi_Stochastic.h +++ b/Indicators/Oscillator/Indi_Stochastic.h @@ -28,8 +28,8 @@ // Enums. // @see: https://www.mql5.com/en/docs/constants/indicatorconstants/prices enum ENUM_STO_PRICE { - STO_LOWHIGH = 0, // Calculation is based on Low/High prices. - STO_CLOSECLOSE, // Calculation is based on Close/Close prices. + STO_LOWHIGH = 0, // Calculation is based on Low/High prices. + STO_CLOSECLOSE, // Calculation is based on Close/Close prices. }; #endif @@ -115,11 +115,11 @@ class Indi_Stochastic : public Indicator { #ifdef __MQL__ #ifdef __MQL4__ return ::iStochastic(_symbol, _tf, _kperiod, _dperiod, _slowing, _ma_method, _price_field, _mode, _shift); -#else // __MQL5__ +#else // __MQL5__ INDICATOR_BUILTIN_CALL_AND_RETURN( ::iStochastic(_symbol, _tf, _kperiod, _dperiod, _slowing, _ma_method, _price_field), _mode, _shift); #endif -#else // Non-MQL. +#else // Non-MQL. // @todo: Use Platform class. RUNTIME_ERROR( "Not implemented. Please use an On-Indicator mode and attach " diff --git a/Indicators/Oscillator/Indi_WPR.h b/Indicators/Oscillator/Indi_WPR.h index 24253b345..7240eaa12 100644 --- a/Indicators/Oscillator/Indi_WPR.h +++ b/Indicators/Oscillator/Indi_WPR.h @@ -90,7 +90,7 @@ class Indi_WPR : public Indicator { #ifdef __MQL__ #ifdef __MQL4__ return ::iWPR(_symbol, _tf, _period, _shift); -#else // __MQL5__ +#else // __MQL5__ int _handle = Object::IsValid(_obj) ? _obj.Get(IndicatorDataState::INDICATOR_DATA_STATE_PROP_HANDLE) : NULL; double _res[]; if (_handle == NULL || _handle == INVALID_HANDLE) { @@ -117,7 +117,7 @@ class Indi_WPR : public Indicator { } return _res[0]; #endif -#else // Non-MQL. +#else // Non-MQL. // @todo: Use Platform class. RUNTIME_ERROR( "Not implemented. Please use an On-Indicator mode and attach " diff --git a/Indicators/Price/Indi_AppliedPrice.h b/Indicators/Price/Indi_AppliedPrice.h index 9183e7bae..834ea938f 100644 --- a/Indicators/Price/Indi_AppliedPrice.h +++ b/Indicators/Price/Indi_AppliedPrice.h @@ -21,8 +21,8 @@ */ // Includes. -#include "../../Storage/Dict/Buffer/BufferStruct.h" #include "../../Indicator/Indicator.h" +#include "../../Storage/Dict/Buffer/BufferStruct.h" #include "../OHLC/Indi_OHLC.mqh" // Structs. diff --git a/Indicators/Price/Indi_Price.h b/Indicators/Price/Indi_Price.h index 9c8e87753..35db3ed59 100644 --- a/Indicators/Price/Indi_Price.h +++ b/Indicators/Price/Indi_Price.h @@ -21,9 +21,9 @@ */ // Includes. -#include "../../Storage/Dict/Buffer/BufferStruct.h" #include "../../Indicator/Indicator.h" #include "../../Platform/Platform.h" +#include "../../Storage/Dict/Buffer/BufferStruct.h" #include "../../Storage/Objects.h" // Structs. diff --git a/Indicators/PriceMulti/Indi_Alligator.h b/Indicators/PriceMulti/Indi_Alligator.h index a286c5d6d..a70b4d727 100644 --- a/Indicators/PriceMulti/Indi_Alligator.h +++ b/Indicators/PriceMulti/Indi_Alligator.h @@ -152,7 +152,7 @@ class Indi_Alligator : public Indicator { _lips_period, _lips_shift, _ma_method, _applied_price), _mode, _shift); #endif -#else // Non-MQL. +#else // Non-MQL. // @todo: Use Platform class. RUNTIME_ERROR( "Not implemented. Please use an On-Indicator mode and attach " diff --git a/Indicators/PriceRange/Indi_Bands.h b/Indicators/PriceRange/Indi_Bands.h index 9207bcb48..caf00ed0f 100644 --- a/Indicators/PriceRange/Indi_Bands.h +++ b/Indicators/PriceRange/Indi_Bands.h @@ -23,12 +23,12 @@ // Includes. #include "../../Indicator/Indicator.h" #include "../Indi_CCI.mqh" -#include "Indi_Envelopes.h" -#include "../Price/Indi_MA.h" #include "../Indi_Momentum.mqh" -#include "../Oscillator/Indi_RSI.h" #include "../Indi_StdDev.mqh" +#include "../Oscillator/Indi_RSI.h" +#include "../Price/Indi_MA.h" #include "../Price/Indi_Price.h" +#include "Indi_Envelopes.h" #ifndef __MQL4__ // Forward declaration. @@ -138,7 +138,7 @@ class Indi_Bands : public Indicator { INDICATOR_BUILTIN_CALL_AND_RETURN(::iBands(_symbol, _tf, _period, _bands_shift, _deviation, _applied_price), _mode, _shift); #endif -#else // Non-MQL. +#else // Non-MQL. // @todo: Use Platform class. RUNTIME_ERROR( "Not implemented. Please use an On-Indicator mode and attach " @@ -165,8 +165,7 @@ class Indi_Bands : public Indicator { } static double iBandsOnArray(INDICATOR_CALCULATE_PARAMS_SHORT, int _period, double _deviation, int _bands_shift, - int _mode, int _abs_shift, IndiBufferCache *_cache, - bool _recalculate = false) { + int _mode, int _abs_shift, IndiBufferCache *_cache, bool _recalculate = false) { _cache.SetPriceBuffer(_price); if (!_cache.HasBuffers()) { diff --git a/Indicators/PriceRange/Indi_Envelopes.h b/Indicators/PriceRange/Indi_Envelopes.h index a9c23ee7c..8a16962ea 100644 --- a/Indicators/PriceRange/Indi_Envelopes.h +++ b/Indicators/PriceRange/Indi_Envelopes.h @@ -23,8 +23,8 @@ // Includes. #include "../../Indicator/Indicator.h" #include "../../Storage/Singleton.h" -#include "../Price/Indi_MA.h" #include "../Indi_PriceFeeder.mqh" +#include "../Price/Indi_MA.h" #include "../Price/Indi_Price.h" #ifndef __MQL4__ @@ -145,7 +145,7 @@ class Indi_Envelopes : public Indicator { INDICATOR_BUILTIN_CALL_AND_RETURN(::iEnvelopes(_symbol, _tf, _ma_period, _ma_shift, _ma_method, _ap, _deviation), _mode, _shift); #endif -#else // Non-MQL. +#else // Non-MQL. // @todo: Use Platform class. RUNTIME_ERROR( "Not implemented. Please use an On-Indicator mode and attach " @@ -166,8 +166,7 @@ class Indi_Envelopes : public Indicator { } static double iEnvelopesOnArray(double &price[], int total, int ma_period, ENUM_MA_METHOD ma_method, int ma_shift, - double deviation, int mode, int shift, - IndiBufferCache *_cache = NULL) { + double deviation, int mode, int shift, IndiBufferCache *_cache = NULL) { #ifdef __MQL4__ return iEnvelopesOnArray(price, total, ma_period, ma_method, ma_shift, deviation, mode, shift); #else diff --git a/Indicators/PriceRange/Indi_SAR.h b/Indicators/PriceRange/Indi_SAR.h index 9ff35dbc8..910ed7e3d 100644 --- a/Indicators/PriceRange/Indi_SAR.h +++ b/Indicators/PriceRange/Indi_SAR.h @@ -89,7 +89,7 @@ class Indi_SAR : public Indicator { #else // __MQL5__ INDICATOR_BUILTIN_CALL_AND_RETURN(::iSAR(_symbol, _tf, _step, _max), 0, _shift); #endif -#else // Non-MQL. +#else // Non-MQL. // @todo: Use Platform class. RUNTIME_ERROR( "Not implemented. Please use an On-Indicator mode and attach " diff --git a/Indicators/Tick/Indi_TickMt.h b/Indicators/Tick/Indi_TickMt.h index 853356601..027684237 100644 --- a/Indicators/Tick/Indi_TickMt.h +++ b/Indicators/Tick/Indi_TickMt.h @@ -31,9 +31,9 @@ #endif // Includes. -#include "../../Platform/Chart/Chart.struct.static.h" #include "../../Indicator/IndicatorTick.h" #include "../../Indicator/IndicatorTick.provider.h" +#include "../../Platform/Chart/Chart.struct.static.h" // Structs. // Params for MT patform's tick-based indicator. From 92794b912fc01881b54636e4627207e2182081f7 Mon Sep 17 00:00:00 2001 From: kenorb Date: Thu, 22 Jun 2023 00:02:29 +0100 Subject: [PATCH 08/26] Makefile: Fail when make subprocess also fail --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 34cd50b8a..6425853f4 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ MAKEFILES := $(wildcard **/tests/Makefile) all: $(MAKEFILES) @for makefile in $(MAKEFILES); do \ echo "Compiling $$makefile"; \ - $(MAKE) -C $$(dirname $$makefile) CFLAGS="$(CFLAGS)" EMCC_CFLAGS="$(EMCC_CFLAGS)"; \ + $(MAKE) -C $$(dirname $$makefile) CFLAGS="$(CFLAGS)" EMCC_CFLAGS="$(EMCC_CFLAGS)" || exit $$?; \ done clean: $(MAKEFILES) From 053b6f526dc3a9d020113c15cd6722450dac1faa Mon Sep 17 00:00:00 2001 From: kenorb Date: Thu, 22 Jun 2023 00:13:39 +0100 Subject: [PATCH 09/26] Database: Code improvements and reformat --- Storage/Database.enum.h | 18 ++- Storage/Database.h | 292 +++++++++++++++++++------------------- Storage/Database.struct.h | 7 - 3 files changed, 159 insertions(+), 158 deletions(-) diff --git a/Storage/Database.enum.h b/Storage/Database.enum.h index dd755b9bf..1a6f636f3 100644 --- a/Storage/Database.enum.h +++ b/Storage/Database.enum.h @@ -20,11 +20,19 @@ * */ +// Enums. + +enum ENUM_DATABASE_COLUMN_FLAGS { + DATABASE_COLUMN_FLAG_NONE = 0, + DATABASE_COLUMN_FLAG_IS_KEY = 1, + DATABASE_COLUMN_FLAG_IS_NULL = 2, +}; + // @docs: https://www.mql5.com/en/docs/database/databaseopen#enum_database_open_flags enum ENUM_DATABASE_OPEN_FLAGS { - DATABASE_OPEN_READONLY, // Read only. - DATABASE_OPEN_READWRITE, // Open for reading and writing. - DATABASE_OPEN_CREATE, // Create the file on a disk if necessary. - DATABASE_OPEN_MEMORY, // Create a database in RAM. - DATABASE_OPEN_COMMON, // The file is in the common folder of all terminals. + DATABASE_OPEN_READONLY = 0, // Read only. + DATABASE_OPEN_READWRITE, // Open for reading and writing. + DATABASE_OPEN_CREATE, // Create the file on a disk if necessary. + DATABASE_OPEN_MEMORY, // Create a database in RAM. + DATABASE_OPEN_COMMON, // The file is in the common folder of all terminals. }; diff --git a/Storage/Database.h b/Storage/Database.h index ac0293a12..147225b63 100644 --- a/Storage/Database.h +++ b/Storage/Database.h @@ -49,211 +49,211 @@ class Database { * Class constructor. */ #ifndef __MQL4__ - Database(string _filename, unsigned int _flags = DATABASE_OPEN_CREATE){ + Database(string _filename, unsigned int _flags = DATABASE_OPEN_CREATE) #else - Database(string _filename, unsigned int _flags = 0) { + Database(string _filename, unsigned int _flags = 0) #endif + { #ifndef __MQL4__ - handle = DatabaseOpen(_filename, _flags); + handle = DatabaseOpen(_filename, _flags); #else handle = -1; SetUserError(ERR_USER_NOT_SUPPORTED); #endif -} + } -/** - * Class deconstructor. - */ -~Database() { + /** + * Class deconstructor. + */ + ~Database() { #ifndef __MQL4__ - DatabaseClose(handle); + DatabaseClose(handle); #endif -} + } -/* Table methods */ + /* Table methods */ -/** - * Checks if table exists. - */ -bool TableExists(string _name) { + /** + * Checks if table exists. + */ + bool TableExists(string _name) { #ifndef __MQL4__ - return DatabaseTableExists(handle, _name); + return DatabaseTableExists(handle, _name); #else SetUserError(ERR_USER_NOT_SUPPORTED); return false; #endif -} + } -/** - * Creates table if not yet exist. - */ -bool CreateTableIfNotExist(string _name, DatabaseTableSchema &_schema) { - if (TableExists(_name)) { - return true; + /** + * Creates table if not yet exist. + */ + bool CreateTableIfNotExist(string _name, DatabaseTableSchema &_schema) { + if (TableExists(_name)) { + return true; + } + return CreateTable(_name, _schema); } - return CreateTable(_name, _schema); -} -/** - * Creates table. - */ -bool CreateTable(string _name, DatabaseTableSchema &_schema) { - bool _result = false; + /** + * Creates table. + */ + bool CreateTable(string _name, DatabaseTableSchema &_schema) { + bool _result = false; #ifndef __MQL4__ - if (DatabaseTableExists(handle, _name)) { - // Generic error (ERR_DATABASE_ERROR). - SetUserError(5601); - return _result; - } + if (DatabaseTableExists(handle, _name)) { + // Generic error (ERR_DATABASE_ERROR). + SetUserError(5601); + return _result; + } - string query = "", subquery = ""; + string query = "", subquery = ""; - if (_schema.columns.Size() == 0) { - // SQLite does'nt allow tables without columns; - subquery = "`dummy` INTEGER"; - } else { - for (DictStructIterator iter = _schema.columns.Begin(); iter.IsValid(); ++iter) { - subquery += - StringFormat("`%s` %s %s,", iter.Value().GetName(), iter.Value().GetDatatype(), iter.Value().GetFlags()); + if (_schema.columns.Size() == 0) { + // SQLite does'nt allow tables without columns; + subquery = "`dummy` INTEGER"; + } else { + for (DictStructIterator iter = _schema.columns.Begin(); iter.IsValid(); ++iter) { + subquery += + StringFormat("`%s` %s %s,", iter.Value().GetName(), iter.Value().GetDatatype(), iter.Value().GetFlags()); + } + subquery = StringSubstr(subquery, 0, StringLen(subquery) - 1); // Removes extra comma. } - subquery = StringSubstr(subquery, 0, StringLen(subquery) - 1); // Removes extra comma. - } - query = StringFormat("CREATE TABLE `%s`(%s);", _name, subquery); + query = StringFormat("CREATE TABLE `%s`(%s);", _name, subquery); #ifdef __debug__ - Print("Database: Executing query:\n", query); + Print("Database: Executing query:\n", query); #endif - if (_result = DatabaseExecute(handle, query)) { - ResetLastError(); - SetTableSchema(_name, _schema); - } else { + if (_result = DatabaseExecute(handle, query)) { + ResetLastError(); + SetTableSchema(_name, _schema); + } else { #ifdef __debug__ - Print("Database: Query failed with error ", _LastError); - DebugBreak(); + Print("Database: Query failed with error ", _LastError); + DebugBreak(); #endif - } + } #endif - return _result; -} + return _result; + } -/** - * Drops table. - */ -bool DropTable(string _name) { - tables.Unset(_name); + /** + * Drops table. + */ + bool DropTable(string _name) { + tables.Unset(_name); #ifndef __MQL4__ - return DatabaseExecute(handle, "DROP TABLE IF EXISTS `" + _name + "`"); + return DatabaseExecute(handle, "DROP TABLE IF EXISTS `" + _name + "`"); #else return false; #endif -} + } -/* Import methods */ + /* Import methods */ -/** - * Imports data into table. First row must contain column names. Strings must be enclosed with double quotes. - */ -bool ImportData(const string _name, MatrixMini2d &data) { - if (data.SizeY() < 2 || data.SizeX() == 0) { - // No data to import or there are no columns in input data (Serialize() serialized no fields). - return true; - } - int x; - bool _result = true; - DatabaseTableSchema _schema = GetTableSchema(_name); - string _query = "", _cols = "", _vals = ""; - for (x = 0; x < data.SizeX(); ++x) { - const string key = data.Get(x, 0); - _cols += "`" + StringSubstr(key, 1, StringLen(key) - 2) + "`,"; - } - _cols = StringSubstr(_cols, 0, StringLen(_cols) - 1); // Removes extra comma. + /** + * Imports data into table. First row must contain column names. Strings must be enclosed with double quotes. + */ + bool ImportData(const string _name, MatrixMini2d &data) { + if (data.SizeY() < 2 || data.SizeX() == 0) { + // No data to import or there are no columns in input data (Serialize() serialized no fields). + return true; + } + int x; + bool _result = true; + DatabaseTableSchema _schema = GetTableSchema(_name); + string _query = "", _cols = "", _vals = ""; + for (x = 0; x < data.SizeX(); ++x) { + const string key = data.Get(x, 0); + _cols += "`" + StringSubstr(key, 1, StringLen(key) - 2) + "`,"; + } + _cols = StringSubstr(_cols, 0, StringLen(_cols) - 1); // Removes extra comma. #ifndef __MQL4__ - if (DatabaseTransactionBegin(handle)) { - _query = StringFormat("INSERT INTO `%s`(%s) VALUES\n", _name, _cols); - for (int y = 1; y < data.SizeY(); ++y) { - _query += "("; - for (x = 0; x < data.SizeX(); ++x) { - _query += data.Get(x, y) + (x < data.SizeX() - 1 ? ", " : ""); + if (DatabaseTransactionBegin(handle)) { + _query = StringFormat("INSERT INTO `%s`(%s) VALUES\n", _name, _cols); + for (int y = 1; y < data.SizeY(); ++y) { + _query += "("; + for (x = 0; x < data.SizeX(); ++x) { + _query += data.Get(x, y) + (x < data.SizeX() - 1 ? ", " : ""); + } + _query += ")" + (string)(y < data.SizeY() - 1 ? ",\n" : ""); } - _query += ")" + (string)(y < data.SizeY() - 1 ? ",\n" : ""); - } #ifdef __debug__ - Print("Database: Executing query:\n", _query); + Print("Database: Executing query:\n", _query); #endif - _result &= DatabaseExecute(handle, _query); - } - if (_result) { - DatabaseTransactionCommit(handle); - } else { - Print("Database: Query failed with error ", _LastError); - DebugBreak(); - DatabaseTransactionRollback(handle); - } + _result &= DatabaseExecute(handle, _query); + } + if (_result) { + DatabaseTransactionCommit(handle); + } else { + Print("Database: Query failed with error ", _LastError); + DebugBreak(); + DatabaseTransactionRollback(handle); + } #else return false; #endif - return _result; -} + return _result; + } #ifdef BUFFER_STRUCT_H -/** - * Imports BufferStruct records into a table. - */ -template -bool Import(const string _name, BufferStruct &_bstruct) { - bool _result = true; - DatabaseTableSchema _schema = GetTableSchema(_name); - string _query = "", _cols = "", _vals = ""; - for (DictStructIterator iter = _schema.columns.Begin(); iter.IsValid(); ++iter) { - _cols += iter.Value().name + ","; - } - _cols = StringSubstr(_cols, 0, StringLen(_cols) - 1); // Removes extra comma. + /** + * Imports BufferStruct records into a table. + */ + template + bool Import(const string _name, BufferStruct &_bstruct) { + bool _result = true; + DatabaseTableSchema _schema = GetTableSchema(_name); + string _query = "", _cols = "", _vals = ""; + for (DictStructIterator iter = _schema.columns.Begin(); iter.IsValid(); ++iter) { + _cols += iter.Value().name + ","; + } + _cols = StringSubstr(_cols, 0, StringLen(_cols) - 1); // Removes extra comma. #ifndef __MQL4__ - if (DatabaseTransactionBegin(handle)) { - for (DictStructIterator iter = _bstruct.Begin(); iter.IsValid(); ++iter) { - _query = StringFormat("INSERT INTO %s(%s) VALUES (%s)", _name, _cols, iter.Value().ToCSV()); - _result &= DatabaseExecute(handle, _query); + if (DatabaseTransactionBegin(handle)) { + for (DictStructIterator iter = _bstruct.Begin(); iter.IsValid(); ++iter) { + _query = StringFormat("INSERT INTO %s(%s) VALUES (%s)", _name, _cols, iter.Value().ToCSV()); + _result &= DatabaseExecute(handle, _query); + } + } + if (_result) { + DatabaseTransactionCommit(handle); + } else { + DatabaseTransactionRollback(handle); } - } - if (_result) { - DatabaseTransactionCommit(handle); - } else { - DatabaseTransactionRollback(handle); - } #else - return false; + return false; #endif - return _result; -} + return _result; + } #endif -/* Getters */ + /* Getters */ -/** - * Gets database handle. - */ -int GetHandle() { return handle; } + /** + * Gets database handle. + */ + int GetHandle() { return handle; } -/** - * Gets table schema. - */ -DatabaseTableSchema GetTableSchema(string _name) { return tables.GetByKey(_name); } + /** + * Gets table schema. + */ + DatabaseTableSchema GetTableSchema(string _name) { return tables.GetByKey(_name); } -/** - * Checks if table schema exists. - */ -bool SchemaExists(string _name) { return tables.KeyExists(_name); } + /** + * Checks if table schema exists. + */ + bool SchemaExists(string _name) { return tables.KeyExists(_name); } -/* Setters */ + /* Setters */ -/** - * Sets table schema. - */ -bool SetTableSchema(string _name, DatabaseTableSchema &_schema) { return tables.Set(_name, _schema); } -} -; + /** + * Sets table schema. + */ + bool SetTableSchema(string _name, DatabaseTableSchema &_schema) { return tables.Set(_name, _schema); } +}; #endif // DATABASE_H diff --git a/Storage/Database.struct.h b/Storage/Database.struct.h index a34cf232b..46f623778 100644 --- a/Storage/Database.struct.h +++ b/Storage/Database.struct.h @@ -25,13 +25,6 @@ * */ -// Enums. -enum DATABASE_COLUMN_FLAGS { - DATABASE_COLUMN_FLAG_NONE = 0, - DATABASE_COLUMN_FLAG_IS_KEY = 1, - DATABASE_COLUMN_FLAG_IS_NULL = 2, -}; - // Structs. struct DatabaseTableColumnEntry { string name; From caffc979561257523d26adb5008b4630fd92d20b Mon Sep 17 00:00:00 2001 From: kenorb Date: Thu, 22 Jun 2023 00:33:08 +0100 Subject: [PATCH 10/26] Adds CPP tests for EA, Log, Refs, Strategy and Trade --- tests/EA.test.cpp | 35 +++++++++++++++++++++++++++++++++++ tests/Log.test.cpp | 35 +++++++++++++++++++++++++++++++++++ tests/Refs.test.cpp | 35 +++++++++++++++++++++++++++++++++++ tests/Strategy.test.cpp | 35 +++++++++++++++++++++++++++++++++++ tests/Trade.test.cpp | 35 +++++++++++++++++++++++++++++++++++ 5 files changed, 175 insertions(+) create mode 100644 tests/EA.test.cpp create mode 100644 tests/Log.test.cpp create mode 100644 tests/Refs.test.cpp create mode 100644 tests/Strategy.test.cpp create mode 100644 tests/Trade.test.cpp diff --git a/tests/EA.test.cpp b/tests/EA.test.cpp new file mode 100644 index 000000000..5a93ec93c --- /dev/null +++ b/tests/EA.test.cpp @@ -0,0 +1,35 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 EA class. + */ + +// Includes. +#include "../EA.mqh" +#include "../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/tests/Log.test.cpp b/tests/Log.test.cpp new file mode 100644 index 000000000..23112c803 --- /dev/null +++ b/tests/Log.test.cpp @@ -0,0 +1,35 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Log class. + */ + +// Includes. +#include "../Log.mqh" +#include "../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/tests/Refs.test.cpp b/tests/Refs.test.cpp new file mode 100644 index 000000000..2f78a63b1 --- /dev/null +++ b/tests/Refs.test.cpp @@ -0,0 +1,35 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Refs class. + */ + +// Includes. +#include "../Refs.mqh" +#include "../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/tests/Strategy.test.cpp b/tests/Strategy.test.cpp new file mode 100644 index 000000000..30f554008 --- /dev/null +++ b/tests/Strategy.test.cpp @@ -0,0 +1,35 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Strategy class. + */ + +// Includes. +#include "../Strategy.mqh" +#include "../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/tests/Trade.test.cpp b/tests/Trade.test.cpp new file mode 100644 index 000000000..60970ff19 --- /dev/null +++ b/tests/Trade.test.cpp @@ -0,0 +1,35 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Trade class. + */ + +// Includes. +#include "../Trade.mqh" +#include "../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} From 9bcb7ab19109fd632685900e06d7deb0f8cb3156 Mon Sep 17 00:00:00 2001 From: kenorb Date: Thu, 22 Jun 2023 00:35:21 +0100 Subject: [PATCH 11/26] Adds more tests for indicators --- Indicators/tests/Indi_AC.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_AD.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_ADX.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_ADXW.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_AMA.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_AO.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_ASI.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_ATR.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_BWMFI.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_BWZT.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_BearsPower.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_BullsPower.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_CCI.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_CHO.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_CHV.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_ColorBars.test.cpp | 36 +++++++++++++++++++ .../tests/Indi_ColorCandlesDaily.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_ColorLine.test.cpp | 36 +++++++++++++++++++ .../tests/Indi_CustomMovingAverage.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_DEMA.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_DeMarker.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_Demo.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_DetrendedPrice.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_Drawer.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_Force.test.cpp | 36 +++++++++++++++++++ .../tests/Indi_FractalAdaptiveMA.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_Fractals.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_Gator.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_HeikenAshi.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_Ichimoku.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_Killzones.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_MFI.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_MassIndex.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_Momentum.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_OBV.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_OHLC.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_OsMA.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_Pattern.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_Price.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_PriceChannel.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_PriceFeeder.test.cpp | 36 +++++++++++++++++++ .../tests/Indi_PriceVolumeTrend.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_RS.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_RVI.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_RateOfChange.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_StdDev.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_TEMA.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_TRIX.test.cpp | 36 +++++++++++++++++++ .../tests/Indi_UltimateOscillator.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_VIDYA.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_VROC.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_Volumes.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_WilliamsAD.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_ZigZag.test.cpp | 36 +++++++++++++++++++ Indicators/tests/Indi_ZigZagColor.test.cpp | 36 +++++++++++++++++++ 55 files changed, 1980 insertions(+) create mode 100644 Indicators/tests/Indi_AC.test.cpp create mode 100644 Indicators/tests/Indi_AD.test.cpp create mode 100644 Indicators/tests/Indi_ADX.test.cpp create mode 100644 Indicators/tests/Indi_ADXW.test.cpp create mode 100644 Indicators/tests/Indi_AMA.test.cpp create mode 100644 Indicators/tests/Indi_AO.test.cpp create mode 100644 Indicators/tests/Indi_ASI.test.cpp create mode 100644 Indicators/tests/Indi_ATR.test.cpp create mode 100644 Indicators/tests/Indi_BWMFI.test.cpp create mode 100644 Indicators/tests/Indi_BWZT.test.cpp create mode 100644 Indicators/tests/Indi_BearsPower.test.cpp create mode 100644 Indicators/tests/Indi_BullsPower.test.cpp create mode 100644 Indicators/tests/Indi_CCI.test.cpp create mode 100644 Indicators/tests/Indi_CHO.test.cpp create mode 100644 Indicators/tests/Indi_CHV.test.cpp create mode 100644 Indicators/tests/Indi_ColorBars.test.cpp create mode 100644 Indicators/tests/Indi_ColorCandlesDaily.test.cpp create mode 100644 Indicators/tests/Indi_ColorLine.test.cpp create mode 100644 Indicators/tests/Indi_CustomMovingAverage.test.cpp create mode 100644 Indicators/tests/Indi_DEMA.test.cpp create mode 100644 Indicators/tests/Indi_DeMarker.test.cpp create mode 100644 Indicators/tests/Indi_Demo.test.cpp create mode 100644 Indicators/tests/Indi_DetrendedPrice.test.cpp create mode 100644 Indicators/tests/Indi_Drawer.test.cpp create mode 100644 Indicators/tests/Indi_Force.test.cpp create mode 100644 Indicators/tests/Indi_FractalAdaptiveMA.test.cpp create mode 100644 Indicators/tests/Indi_Fractals.test.cpp create mode 100644 Indicators/tests/Indi_Gator.test.cpp create mode 100644 Indicators/tests/Indi_HeikenAshi.test.cpp create mode 100644 Indicators/tests/Indi_Ichimoku.test.cpp create mode 100644 Indicators/tests/Indi_Killzones.test.cpp create mode 100644 Indicators/tests/Indi_MFI.test.cpp create mode 100644 Indicators/tests/Indi_MassIndex.test.cpp create mode 100644 Indicators/tests/Indi_Momentum.test.cpp create mode 100644 Indicators/tests/Indi_OBV.test.cpp create mode 100644 Indicators/tests/Indi_OHLC.test.cpp create mode 100644 Indicators/tests/Indi_OsMA.test.cpp create mode 100644 Indicators/tests/Indi_Pattern.test.cpp create mode 100644 Indicators/tests/Indi_Price.test.cpp create mode 100644 Indicators/tests/Indi_PriceChannel.test.cpp create mode 100644 Indicators/tests/Indi_PriceFeeder.test.cpp create mode 100644 Indicators/tests/Indi_PriceVolumeTrend.test.cpp create mode 100644 Indicators/tests/Indi_RS.test.cpp create mode 100644 Indicators/tests/Indi_RVI.test.cpp create mode 100644 Indicators/tests/Indi_RateOfChange.test.cpp create mode 100644 Indicators/tests/Indi_StdDev.test.cpp create mode 100644 Indicators/tests/Indi_TEMA.test.cpp create mode 100644 Indicators/tests/Indi_TRIX.test.cpp create mode 100644 Indicators/tests/Indi_UltimateOscillator.test.cpp create mode 100644 Indicators/tests/Indi_VIDYA.test.cpp create mode 100644 Indicators/tests/Indi_VROC.test.cpp create mode 100644 Indicators/tests/Indi_Volumes.test.cpp create mode 100644 Indicators/tests/Indi_WilliamsAD.test.cpp create mode 100644 Indicators/tests/Indi_ZigZag.test.cpp create mode 100644 Indicators/tests/Indi_ZigZagColor.test.cpp diff --git a/Indicators/tests/Indi_AC.test.cpp b/Indicators/tests/Indi_AC.test.cpp new file mode 100644 index 000000000..cb31dbd00 --- /dev/null +++ b/Indicators/tests/Indi_AC.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_AC class. + */ + +// Includes. +#include "../Indi_AC.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_AD.test.cpp b/Indicators/tests/Indi_AD.test.cpp new file mode 100644 index 000000000..e7f113dca --- /dev/null +++ b/Indicators/tests/Indi_AD.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_AD class. + */ + +// Includes. +#include "../Indi_AD.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_ADX.test.cpp b/Indicators/tests/Indi_ADX.test.cpp new file mode 100644 index 000000000..7f79f5bff --- /dev/null +++ b/Indicators/tests/Indi_ADX.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_ADX class. + */ + +// Includes. +#include "../Indi_ADX.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_ADXW.test.cpp b/Indicators/tests/Indi_ADXW.test.cpp new file mode 100644 index 000000000..6adc1c09a --- /dev/null +++ b/Indicators/tests/Indi_ADXW.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_ADXW class. + */ + +// Includes. +#include "../Indi_ADXW.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_AMA.test.cpp b/Indicators/tests/Indi_AMA.test.cpp new file mode 100644 index 000000000..69e2a89c3 --- /dev/null +++ b/Indicators/tests/Indi_AMA.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_AMA class. + */ + +// Includes. +#include "../Indi_AMA.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_AO.test.cpp b/Indicators/tests/Indi_AO.test.cpp new file mode 100644 index 000000000..d2c78c25e --- /dev/null +++ b/Indicators/tests/Indi_AO.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_AO class. + */ + +// Includes. +#include "../Indi_AO.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_ASI.test.cpp b/Indicators/tests/Indi_ASI.test.cpp new file mode 100644 index 000000000..77ce2b19b --- /dev/null +++ b/Indicators/tests/Indi_ASI.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_ASI class. + */ + +// Includes. +#include "../Indi_ASI.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_ATR.test.cpp b/Indicators/tests/Indi_ATR.test.cpp new file mode 100644 index 000000000..7c1e7872a --- /dev/null +++ b/Indicators/tests/Indi_ATR.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_ATR class. + */ + +// Includes. +#include "../Indi_ATR.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_BWMFI.test.cpp b/Indicators/tests/Indi_BWMFI.test.cpp new file mode 100644 index 000000000..6591cc05d --- /dev/null +++ b/Indicators/tests/Indi_BWMFI.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_BWMFI class. + */ + +// Includes. +#include "../Indi_BWMFI.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_BWZT.test.cpp b/Indicators/tests/Indi_BWZT.test.cpp new file mode 100644 index 000000000..3c389116e --- /dev/null +++ b/Indicators/tests/Indi_BWZT.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_BWZT class. + */ + +// Includes. +#include "../Indi_BWZT.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_BearsPower.test.cpp b/Indicators/tests/Indi_BearsPower.test.cpp new file mode 100644 index 000000000..a2247a51f --- /dev/null +++ b/Indicators/tests/Indi_BearsPower.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_BearsPower class. + */ + +// Includes. +#include "../Indi_BearsPower.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_BullsPower.test.cpp b/Indicators/tests/Indi_BullsPower.test.cpp new file mode 100644 index 000000000..dd4a059e0 --- /dev/null +++ b/Indicators/tests/Indi_BullsPower.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_BullsPower class. + */ + +// Includes. +#include "../Indi_BullsPower.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_CCI.test.cpp b/Indicators/tests/Indi_CCI.test.cpp new file mode 100644 index 000000000..1221be0f7 --- /dev/null +++ b/Indicators/tests/Indi_CCI.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_CCI class. + */ + +// Includes. +#include "../Indi_CCI.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_CHO.test.cpp b/Indicators/tests/Indi_CHO.test.cpp new file mode 100644 index 000000000..40bbd0702 --- /dev/null +++ b/Indicators/tests/Indi_CHO.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_CHO class. + */ + +// Includes. +#include "../Indi_CHO.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_CHV.test.cpp b/Indicators/tests/Indi_CHV.test.cpp new file mode 100644 index 000000000..df51642ce --- /dev/null +++ b/Indicators/tests/Indi_CHV.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_CHV class. + */ + +// Includes. +#include "../Indi_CHV.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_ColorBars.test.cpp b/Indicators/tests/Indi_ColorBars.test.cpp new file mode 100644 index 000000000..9b0692069 --- /dev/null +++ b/Indicators/tests/Indi_ColorBars.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_ColorBars class. + */ + +// Includes. +#include "../Indi_ColorBars.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_ColorCandlesDaily.test.cpp b/Indicators/tests/Indi_ColorCandlesDaily.test.cpp new file mode 100644 index 000000000..f1bd10a00 --- /dev/null +++ b/Indicators/tests/Indi_ColorCandlesDaily.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_ColorCandlesDaily class. + */ + +// Includes. +#include "../Indi_ColorCandlesDaily.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_ColorLine.test.cpp b/Indicators/tests/Indi_ColorLine.test.cpp new file mode 100644 index 000000000..701f35998 --- /dev/null +++ b/Indicators/tests/Indi_ColorLine.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_ColorLine class. + */ + +// Includes. +#include "../Indi_ColorLine.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_CustomMovingAverage.test.cpp b/Indicators/tests/Indi_CustomMovingAverage.test.cpp new file mode 100644 index 000000000..2e122de71 --- /dev/null +++ b/Indicators/tests/Indi_CustomMovingAverage.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_CustomMovingAverage class. + */ + +// Includes. +#include "../Indi_CustomMovingAverage.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_DEMA.test.cpp b/Indicators/tests/Indi_DEMA.test.cpp new file mode 100644 index 000000000..48118f6af --- /dev/null +++ b/Indicators/tests/Indi_DEMA.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_DEMA class. + */ + +// Includes. +#include "../Indi_DEMA.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_DeMarker.test.cpp b/Indicators/tests/Indi_DeMarker.test.cpp new file mode 100644 index 000000000..3193ef17a --- /dev/null +++ b/Indicators/tests/Indi_DeMarker.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_DeMarker class. + */ + +// Includes. +#include "../Indi_DeMarker.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_Demo.test.cpp b/Indicators/tests/Indi_Demo.test.cpp new file mode 100644 index 000000000..e4bbfc8b7 --- /dev/null +++ b/Indicators/tests/Indi_Demo.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_Demo class. + */ + +// Includes. +#include "../Indi_Demo.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_DetrendedPrice.test.cpp b/Indicators/tests/Indi_DetrendedPrice.test.cpp new file mode 100644 index 000000000..a59478d75 --- /dev/null +++ b/Indicators/tests/Indi_DetrendedPrice.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_DetrendedPrice class. + */ + +// Includes. +#include "../Indi_DetrendedPrice.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_Drawer.test.cpp b/Indicators/tests/Indi_Drawer.test.cpp new file mode 100644 index 000000000..37f1fb554 --- /dev/null +++ b/Indicators/tests/Indi_Drawer.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_Drawer class. + */ + +// Includes. +#include "../Indi_Drawer.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_Force.test.cpp b/Indicators/tests/Indi_Force.test.cpp new file mode 100644 index 000000000..0e9bd8d4c --- /dev/null +++ b/Indicators/tests/Indi_Force.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_Force class. + */ + +// Includes. +#include "../Indi_Force.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_FractalAdaptiveMA.test.cpp b/Indicators/tests/Indi_FractalAdaptiveMA.test.cpp new file mode 100644 index 000000000..669cb9da9 --- /dev/null +++ b/Indicators/tests/Indi_FractalAdaptiveMA.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_FractalAdaptiveMA class. + */ + +// Includes. +#include "../Indi_FractalAdaptiveMA.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_Fractals.test.cpp b/Indicators/tests/Indi_Fractals.test.cpp new file mode 100644 index 000000000..50d6950cb --- /dev/null +++ b/Indicators/tests/Indi_Fractals.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_Fractals class. + */ + +// Includes. +#include "../Indi_Fractals.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_Gator.test.cpp b/Indicators/tests/Indi_Gator.test.cpp new file mode 100644 index 000000000..f4be095c1 --- /dev/null +++ b/Indicators/tests/Indi_Gator.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_Gator class. + */ + +// Includes. +#include "../Indi_Gator.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_HeikenAshi.test.cpp b/Indicators/tests/Indi_HeikenAshi.test.cpp new file mode 100644 index 000000000..326731b08 --- /dev/null +++ b/Indicators/tests/Indi_HeikenAshi.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_HeikenAshi class. + */ + +// Includes. +#include "../Indi_HeikenAshi.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_Ichimoku.test.cpp b/Indicators/tests/Indi_Ichimoku.test.cpp new file mode 100644 index 000000000..60955e6af --- /dev/null +++ b/Indicators/tests/Indi_Ichimoku.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_Ichimoku class. + */ + +// Includes. +#include "../Indi_Ichimoku.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_Killzones.test.cpp b/Indicators/tests/Indi_Killzones.test.cpp new file mode 100644 index 000000000..68be7807f --- /dev/null +++ b/Indicators/tests/Indi_Killzones.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_Killzones class. + */ + +// Includes. +#include "../Indi_Killzones.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_MFI.test.cpp b/Indicators/tests/Indi_MFI.test.cpp new file mode 100644 index 000000000..b185f1b84 --- /dev/null +++ b/Indicators/tests/Indi_MFI.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_MFI class. + */ + +// Includes. +#include "../Indi_MFI.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_MassIndex.test.cpp b/Indicators/tests/Indi_MassIndex.test.cpp new file mode 100644 index 000000000..2cce413c3 --- /dev/null +++ b/Indicators/tests/Indi_MassIndex.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_MassIndex class. + */ + +// Includes. +#include "../Indi_MassIndex.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_Momentum.test.cpp b/Indicators/tests/Indi_Momentum.test.cpp new file mode 100644 index 000000000..aa8dfee33 --- /dev/null +++ b/Indicators/tests/Indi_Momentum.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_Momentum class. + */ + +// Includes. +#include "../Indi_Momentum.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_OBV.test.cpp b/Indicators/tests/Indi_OBV.test.cpp new file mode 100644 index 000000000..c968c61d2 --- /dev/null +++ b/Indicators/tests/Indi_OBV.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_OBV class. + */ + +// Includes. +#include "../Indi_OBV.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_OHLC.test.cpp b/Indicators/tests/Indi_OHLC.test.cpp new file mode 100644 index 000000000..ba42aef26 --- /dev/null +++ b/Indicators/tests/Indi_OHLC.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_OHLC class. + */ + +// Includes. +#include "../Indi_OHLC.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_OsMA.test.cpp b/Indicators/tests/Indi_OsMA.test.cpp new file mode 100644 index 000000000..81bef59ba --- /dev/null +++ b/Indicators/tests/Indi_OsMA.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_OsMA class. + */ + +// Includes. +#include "../Indi_OsMA.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_Pattern.test.cpp b/Indicators/tests/Indi_Pattern.test.cpp new file mode 100644 index 000000000..1828b7ae0 --- /dev/null +++ b/Indicators/tests/Indi_Pattern.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_Pattern class. + */ + +// Includes. +#include "../Indi_Pattern.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_Price.test.cpp b/Indicators/tests/Indi_Price.test.cpp new file mode 100644 index 000000000..c0cd11094 --- /dev/null +++ b/Indicators/tests/Indi_Price.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_Price class. + */ + +// Includes. +#include "../Indi_Price.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_PriceChannel.test.cpp b/Indicators/tests/Indi_PriceChannel.test.cpp new file mode 100644 index 000000000..a4ceb1884 --- /dev/null +++ b/Indicators/tests/Indi_PriceChannel.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_PriceChannel class. + */ + +// Includes. +#include "../Indi_PriceChannel.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_PriceFeeder.test.cpp b/Indicators/tests/Indi_PriceFeeder.test.cpp new file mode 100644 index 000000000..fb28a6dd1 --- /dev/null +++ b/Indicators/tests/Indi_PriceFeeder.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_PriceFeeder class. + */ + +// Includes. +#include "../Indi_PriceFeeder.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_PriceVolumeTrend.test.cpp b/Indicators/tests/Indi_PriceVolumeTrend.test.cpp new file mode 100644 index 000000000..1280eac1b --- /dev/null +++ b/Indicators/tests/Indi_PriceVolumeTrend.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_PriceVolumeTrend class. + */ + +// Includes. +#include "../Indi_PriceVolumeTrend.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_RS.test.cpp b/Indicators/tests/Indi_RS.test.cpp new file mode 100644 index 000000000..d81e396e1 --- /dev/null +++ b/Indicators/tests/Indi_RS.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_RS class. + */ + +// Includes. +#include "../Indi_RS.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_RVI.test.cpp b/Indicators/tests/Indi_RVI.test.cpp new file mode 100644 index 000000000..9f15b1838 --- /dev/null +++ b/Indicators/tests/Indi_RVI.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_RVI class. + */ + +// Includes. +#include "../Indi_RVI.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_RateOfChange.test.cpp b/Indicators/tests/Indi_RateOfChange.test.cpp new file mode 100644 index 000000000..1bbec0188 --- /dev/null +++ b/Indicators/tests/Indi_RateOfChange.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_RateOfChange class. + */ + +// Includes. +#include "../Indi_RateOfChange.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_StdDev.test.cpp b/Indicators/tests/Indi_StdDev.test.cpp new file mode 100644 index 000000000..8df779140 --- /dev/null +++ b/Indicators/tests/Indi_StdDev.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_StdDev class. + */ + +// Includes. +#include "../Indi_StdDev.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_TEMA.test.cpp b/Indicators/tests/Indi_TEMA.test.cpp new file mode 100644 index 000000000..9896fb162 --- /dev/null +++ b/Indicators/tests/Indi_TEMA.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_TEMA class. + */ + +// Includes. +#include "../Indi_TEMA.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_TRIX.test.cpp b/Indicators/tests/Indi_TRIX.test.cpp new file mode 100644 index 000000000..c8694d834 --- /dev/null +++ b/Indicators/tests/Indi_TRIX.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_TRIX class. + */ + +// Includes. +#include "../Indi_TRIX.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_UltimateOscillator.test.cpp b/Indicators/tests/Indi_UltimateOscillator.test.cpp new file mode 100644 index 000000000..4bbe6e77c --- /dev/null +++ b/Indicators/tests/Indi_UltimateOscillator.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_UltimateOscillator class. + */ + +// Includes. +#include "../Indi_UltimateOscillator.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_VIDYA.test.cpp b/Indicators/tests/Indi_VIDYA.test.cpp new file mode 100644 index 000000000..8a5820691 --- /dev/null +++ b/Indicators/tests/Indi_VIDYA.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_VIDYA class. + */ + +// Includes. +#include "../Indi_VIDYA.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_VROC.test.cpp b/Indicators/tests/Indi_VROC.test.cpp new file mode 100644 index 000000000..8f983e407 --- /dev/null +++ b/Indicators/tests/Indi_VROC.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_VROC class. + */ + +// Includes. +#include "../Indi_VROC.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_Volumes.test.cpp b/Indicators/tests/Indi_Volumes.test.cpp new file mode 100644 index 000000000..1c91cc7a4 --- /dev/null +++ b/Indicators/tests/Indi_Volumes.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_Volumes class. + */ + +// Includes. +#include "../Indi_Volumes.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_WilliamsAD.test.cpp b/Indicators/tests/Indi_WilliamsAD.test.cpp new file mode 100644 index 000000000..0b014600a --- /dev/null +++ b/Indicators/tests/Indi_WilliamsAD.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_WilliamsAD class. + */ + +// Includes. +#include "../Indi_WilliamsAD.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_ZigZag.test.cpp b/Indicators/tests/Indi_ZigZag.test.cpp new file mode 100644 index 000000000..1e78a2a62 --- /dev/null +++ b/Indicators/tests/Indi_ZigZag.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_ZigZag class. + */ + +// Includes. +#include "../Indi_ZigZag.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/tests/Indi_ZigZagColor.test.cpp b/Indicators/tests/Indi_ZigZagColor.test.cpp new file mode 100644 index 000000000..8a8f46ff6 --- /dev/null +++ b/Indicators/tests/Indi_ZigZagColor.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_ZigZagColor class. + */ + +// Includes. +#include "../Indi_ZigZagColor.mqh" + +#include "../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} From b22c2a44b8d1f5ac19fa380c59921de5268cc219 Mon Sep 17 00:00:00 2001 From: kenorb Date: Thu, 22 Jun 2023 00:44:59 +0100 Subject: [PATCH 12/26] Makefile: Improves syntax --- Makefile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 6425853f4..d8c1fdb97 100644 --- a/Makefile +++ b/Makefile @@ -5,13 +5,14 @@ MAKEFILES := $(wildcard **/tests/Makefile) .PHONY: all all: $(MAKEFILES) - @for makefile in $(MAKEFILES); do \ - echo "Compiling $$makefile"; \ - $(MAKE) -C $$(dirname $$makefile) CFLAGS="$(CFLAGS)" EMCC_CFLAGS="$(EMCC_CFLAGS)" || exit $$?; \ - done + @ret=0; \ + for makefile in $(MAKEFILES); do \ + $(MAKE) -C $$(dirname $$makefile) CFLAGS="$(CFLAGS)" EMCC_CFLAGS="$(EMCC_CFLAGS)" || { ret=$$?; }; \ + done; \ + exit $$ret clean: $(MAKEFILES) @for makefile in $(MAKEFILES); do \ - echo "Compiling $$makefile"; \ + echo "Cleaning $$makefile"; \ $(MAKE) -C $$(dirname $$makefile) clean; \ done From 2ca9366b07f00817dc5020b3d33336f72bcc3a7c Mon Sep 17 00:00:00 2001 From: kenorb Date: Thu, 22 Jun 2023 00:55:21 +0100 Subject: [PATCH 13/26] Adds more tests for indicators --- Indicators/Bitwise/tests/Indi_Candle.test.cpp | 36 +++++++++++++++++++ .../Bitwise/tests/Indi_Pattern.test.cpp | 36 +++++++++++++++++++ .../Oscillator/tests/Indi_Stochastic.test.cpp | 36 +++++++++++++++++++ Indicators/Oscillator/tests/Indi_WPR.test.cpp | 36 +++++++++++++++++++ .../Price/tests/Indi_AppliedPrice.test.cpp | 36 +++++++++++++++++++ Indicators/Price/tests/Indi_MA.test.cpp | 36 +++++++++++++++++++ .../PriceMulti/tests/Indi_Alligator.test.cpp | 36 +++++++++++++++++++ .../PriceRange/tests/Indi_Bands.test.cpp | 36 +++++++++++++++++++ .../PriceRange/tests/Indi_Envelopes.test.cpp | 36 +++++++++++++++++++ .../PriceRange/tests/Indi_Pivot.test.cpp | 35 ++++++++++++++++++ .../PriceRange/tests/Indi_PriceRange.test.cpp | 35 ++++++++++++++++++ Indicators/PriceRange/tests/Indi_SAR.test.cpp | 36 +++++++++++++++++++ Indicators/Special/tests/Indi_Custom.test.cpp | 36 +++++++++++++++++++ Indicators/Tick/tests/Indi_TickMt.test.cpp | 36 +++++++++++++++++++ 14 files changed, 502 insertions(+) create mode 100644 Indicators/Bitwise/tests/Indi_Candle.test.cpp create mode 100644 Indicators/Bitwise/tests/Indi_Pattern.test.cpp create mode 100644 Indicators/Oscillator/tests/Indi_Stochastic.test.cpp create mode 100644 Indicators/Oscillator/tests/Indi_WPR.test.cpp create mode 100644 Indicators/Price/tests/Indi_AppliedPrice.test.cpp create mode 100644 Indicators/Price/tests/Indi_MA.test.cpp create mode 100644 Indicators/PriceMulti/tests/Indi_Alligator.test.cpp create mode 100644 Indicators/PriceRange/tests/Indi_Bands.test.cpp create mode 100644 Indicators/PriceRange/tests/Indi_Envelopes.test.cpp create mode 100644 Indicators/PriceRange/tests/Indi_Pivot.test.cpp create mode 100644 Indicators/PriceRange/tests/Indi_PriceRange.test.cpp create mode 100644 Indicators/PriceRange/tests/Indi_SAR.test.cpp create mode 100644 Indicators/Special/tests/Indi_Custom.test.cpp create mode 100644 Indicators/Tick/tests/Indi_TickMt.test.cpp diff --git a/Indicators/Bitwise/tests/Indi_Candle.test.cpp b/Indicators/Bitwise/tests/Indi_Candle.test.cpp new file mode 100644 index 000000000..edc1a920a --- /dev/null +++ b/Indicators/Bitwise/tests/Indi_Candle.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_Candle indicator class. + */ + +// Includes. +#include "../Indi_Candle.mqh" + +#include "../../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/Bitwise/tests/Indi_Pattern.test.cpp b/Indicators/Bitwise/tests/Indi_Pattern.test.cpp new file mode 100644 index 000000000..dce78be8a --- /dev/null +++ b/Indicators/Bitwise/tests/Indi_Pattern.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_Pattern indicator class. + */ + +// Includes. +#include "../Indi_Pattern.mqh" + +#include "../../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/Oscillator/tests/Indi_Stochastic.test.cpp b/Indicators/Oscillator/tests/Indi_Stochastic.test.cpp new file mode 100644 index 000000000..d38039d0d --- /dev/null +++ b/Indicators/Oscillator/tests/Indi_Stochastic.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_Stochastic class. + */ + +// Includes. +#include "../Indi_Stochastic.h" + +#include "../../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/Oscillator/tests/Indi_WPR.test.cpp b/Indicators/Oscillator/tests/Indi_WPR.test.cpp new file mode 100644 index 000000000..bc9bdff13 --- /dev/null +++ b/Indicators/Oscillator/tests/Indi_WPR.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_WPR class. + */ + +// Includes. +#include "../Indi_WPR.h" + +#include "../../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/Price/tests/Indi_AppliedPrice.test.cpp b/Indicators/Price/tests/Indi_AppliedPrice.test.cpp new file mode 100644 index 000000000..b918fd4d5 --- /dev/null +++ b/Indicators/Price/tests/Indi_AppliedPrice.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_AppliedPrice class. + */ + +// Includes. +#include "../Indi_AppliedPrice.h" + +#include "../../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/Price/tests/Indi_MA.test.cpp b/Indicators/Price/tests/Indi_MA.test.cpp new file mode 100644 index 000000000..4d4c45d9e --- /dev/null +++ b/Indicators/Price/tests/Indi_MA.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_MA class. + */ + +// Includes. +#include "../Indi_MA.h" + +#include "../../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/PriceMulti/tests/Indi_Alligator.test.cpp b/Indicators/PriceMulti/tests/Indi_Alligator.test.cpp new file mode 100644 index 000000000..f966ae735 --- /dev/null +++ b/Indicators/PriceMulti/tests/Indi_Alligator.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_Alligator class. + */ + +// Includes. +#include "../Indi_Alligator.h" + +#include "../../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/PriceRange/tests/Indi_Bands.test.cpp b/Indicators/PriceRange/tests/Indi_Bands.test.cpp new file mode 100644 index 000000000..266225f20 --- /dev/null +++ b/Indicators/PriceRange/tests/Indi_Bands.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_Bands class. + */ + +// Includes. +#include "../Indi_Bands.h" + +#include "../../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/PriceRange/tests/Indi_Envelopes.test.cpp b/Indicators/PriceRange/tests/Indi_Envelopes.test.cpp new file mode 100644 index 000000000..244ffaea8 --- /dev/null +++ b/Indicators/PriceRange/tests/Indi_Envelopes.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_Envelopes class. + */ + +// Includes. +#include "../Indi_Envelopes.h" + +#include "../../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/PriceRange/tests/Indi_Pivot.test.cpp b/Indicators/PriceRange/tests/Indi_Pivot.test.cpp new file mode 100644 index 000000000..407445ee1 --- /dev/null +++ b/Indicators/PriceRange/tests/Indi_Pivot.test.cpp @@ -0,0 +1,35 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_Pivot class. + */ + +// Includes. +#include "../Indi_Pivot.h" +#include "../../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/PriceRange/tests/Indi_PriceRange.test.cpp b/Indicators/PriceRange/tests/Indi_PriceRange.test.cpp new file mode 100644 index 000000000..d6c820fed --- /dev/null +++ b/Indicators/PriceRange/tests/Indi_PriceRange.test.cpp @@ -0,0 +1,35 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 all price range classes. + */ + +// Includes. +#include "../../../Platform/Platform.h" +#include "../includes.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/PriceRange/tests/Indi_SAR.test.cpp b/Indicators/PriceRange/tests/Indi_SAR.test.cpp new file mode 100644 index 000000000..af7b0a987 --- /dev/null +++ b/Indicators/PriceRange/tests/Indi_SAR.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_SAR class. + */ + +// Includes. +#include "../Indi_SAR.h" + +#include "../../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/Special/tests/Indi_Custom.test.cpp b/Indicators/Special/tests/Indi_Custom.test.cpp new file mode 100644 index 000000000..26e5bf6b5 --- /dev/null +++ b/Indicators/Special/tests/Indi_Custom.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_Custom indicator class. + */ + +// Includes. +#include "../Indi_Custom.mqh" + +#include "../../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} diff --git a/Indicators/Tick/tests/Indi_TickMt.test.cpp b/Indicators/Tick/tests/Indi_TickMt.test.cpp new file mode 100644 index 000000000..78cb8b856 --- /dev/null +++ b/Indicators/Tick/tests/Indi_TickMt.test.cpp @@ -0,0 +1,36 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 Indi_TickMt indicator class. + */ + +// Includes. +#include "../Indi_TickMt.h" + +#include "../../../Platform/Platform.h" + +int main(int argc, char **argv) { + // @todo + + return 0; +} From 1fe4be43eab8855cb50613b16dad633d404ee68e Mon Sep 17 00:00:00 2001 From: Adrian Kierzkowski Date: Thu, 22 Jun 2023 17:32:50 +0200 Subject: [PATCH 14/26] Another step in fixing C++ compile errors. --- Storage/Database.enum.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Storage/Database.enum.h b/Storage/Database.enum.h index 1a6f636f3..926d67ed9 100644 --- a/Storage/Database.enum.h +++ b/Storage/Database.enum.h @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Enums. enum ENUM_DATABASE_COLUMN_FLAGS { @@ -28,6 +33,8 @@ enum ENUM_DATABASE_COLUMN_FLAGS { DATABASE_COLUMN_FLAG_IS_NULL = 2, }; +#ifndef __MQL5__ + // @docs: https://www.mql5.com/en/docs/database/databaseopen#enum_database_open_flags enum ENUM_DATABASE_OPEN_FLAGS { DATABASE_OPEN_READONLY = 0, // Read only. @@ -36,3 +43,5 @@ enum ENUM_DATABASE_OPEN_FLAGS { DATABASE_OPEN_MEMORY, // Create a database in RAM. DATABASE_OPEN_COMMON, // The file is in the common folder of all terminals. }; + +#endif From ba9afe30fc4492851efa684375c1739418a1df6b Mon Sep 17 00:00:00 2001 From: Adrian Kierzkowski Date: Thu, 22 Jun 2023 20:31:05 +0200 Subject: [PATCH 15/26] A little step forward in fixing C++ compile errors. --- Indicators/Bitwise/Indi_Candle.mqh | 10 ++--- Indicators/Bitwise/Indi_Pattern.mqh | 12 +++--- Indicators/Special/Indi_Math.mqh | 14 +++---- Pattern.struct.h | 61 +++++++++++++++++------------ 4 files changed, 54 insertions(+), 43 deletions(-) diff --git a/Indicators/Bitwise/Indi_Candle.mqh b/Indicators/Bitwise/Indi_Candle.mqh index 27d6e3233..154129dcd 100644 --- a/Indicators/Bitwise/Indi_Candle.mqh +++ b/Indicators/Bitwise/Indi_Candle.mqh @@ -105,7 +105,7 @@ class Indi_Candle : public Indicator { // must have at least 4 buffers and define OHLC in the first 4 buffers. // Indi_Price is an example of such indicator. if (!indi_src.IsSet()) { - GetLogger().Error( + GetLogger() PTR_DEREF Error( "In order use custom indicator as a source, you need to select one using SetIndicatorData() method, " "which is a part of CandleParams structure.", "Indi_Candle"); @@ -117,10 +117,10 @@ class Indi_Candle : public Indicator { break; } - _ohlcs[0].open = GetDataSource().GetValue(PRICE_OPEN, ToRelShift(_abs_shift)); - _ohlcs[0].high = GetDataSource().GetValue(PRICE_HIGH, ToRelShift(_abs_shift)); - _ohlcs[0].low = GetDataSource().GetValue(PRICE_LOW, ToRelShift(_abs_shift)); - _ohlcs[0].close = GetDataSource().GetValue(PRICE_CLOSE, ToRelShift(_abs_shift)); + _ohlcs[0].open = GetDataSource() PTR_DEREF GetValue(PRICE_OPEN, ToRelShift(_abs_shift)); + _ohlcs[0].high = GetDataSource() PTR_DEREF GetValue(PRICE_HIGH, ToRelShift(_abs_shift)); + _ohlcs[0].low = GetDataSource() PTR_DEREF GetValue(PRICE_LOW, ToRelShift(_abs_shift)); + _ohlcs[0].close = GetDataSource() PTR_DEREF GetValue(PRICE_CLOSE, ToRelShift(_abs_shift)); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Bitwise/Indi_Pattern.mqh b/Indicators/Bitwise/Indi_Pattern.mqh index 7fa156adb..2b1f5ccd1 100644 --- a/Indicators/Bitwise/Indi_Pattern.mqh +++ b/Indicators/Bitwise/Indi_Pattern.mqh @@ -90,7 +90,7 @@ class Indi_Pattern : public Indicator { INDI_REQUIRE_SHIFT_OR_RETURN(GetCandle(), ToRelShift(_abs_shift) + _max_modes, WRONG_VALUE); - BarOHLC _ohlcs[8]; + FIXED_ARRAY(BarOHLC, _ohlcs, 8); switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_BUILTIN: @@ -108,7 +108,7 @@ class Indi_Pattern : public Indicator { // must have at least 4 buffers and define OHLC in the first 4 buffers. // Indi_Price is an example of such indicator. if (!indi_src.IsSet()) { - GetLogger().Error( + GetLogger() PTR_DEREF Error( "In order use custom indicator as a source, you need to select one using SetIndicatorData() method, " "which is a part of PatternParams structure.", "Indi_Pattern"); @@ -121,10 +121,10 @@ class Indi_Pattern : public Indicator { } for (i = 0; i < _max_modes; ++i) { - _ohlcs[i].open = GetDataSource().GetValue(PRICE_OPEN, ToRelShift(_abs_shift) + i); - _ohlcs[i].high = GetDataSource().GetValue(PRICE_HIGH, ToRelShift(_abs_shift) + i); - _ohlcs[i].low = GetDataSource().GetValue(PRICE_LOW, ToRelShift(_abs_shift) + i); - _ohlcs[i].close = GetDataSource().GetValue(PRICE_CLOSE, ToRelShift(_abs_shift) + i); + _ohlcs[i].open = GetDataSource() PTR_DEREF GetValue(PRICE_OPEN, ToRelShift(_abs_shift) + i); + _ohlcs[i].high = GetDataSource() PTR_DEREF GetValue(PRICE_HIGH, ToRelShift(_abs_shift) + i); + _ohlcs[i].low = GetDataSource() PTR_DEREF GetValue(PRICE_LOW, ToRelShift(_abs_shift) + i); + _ohlcs[i].close = GetDataSource() PTR_DEREF GetValue(PRICE_CLOSE, ToRelShift(_abs_shift) + i); if (!_ohlcs[i].IsValid()) { // Return empty entry on invalid candles. return WRONG_VALUE; diff --git a/Indicators/Special/Indi_Math.mqh b/Indicators/Special/Indi_Math.mqh index 4c622c46b..0df25f3be 100644 --- a/Indicators/Special/Indi_Math.mqh +++ b/Indicators/Special/Indi_Math.mqh @@ -119,7 +119,7 @@ class Indi_Math : public Indicator { switch (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE))) { case IDATA_INDICATOR: if (!indi_src.IsSet()) { - GetLogger().Error( + GetLogger() PTR_DEREF Error( "In order use custom indicator as a source, you need to select one using SetIndicatorData() method, " "which is a part of IndiMathParams structure.", "Indi_Math"); @@ -133,12 +133,12 @@ class Indi_Math : public Indicator { case MATH_OP_MODE_BUILTIN: _value = Indi_Math::iMathOnIndicator(GetDataSource(), GetSymbol(), GetTf(), /*[*/ GetOpBuiltIn(), GetMode1(), GetMode2(), GetShift1(), - GetShift2() /*]*/, 0, ToRelShift(_abs_shift), &this); + GetShift2() /*]*/, 0, ToRelShift(_abs_shift), THIS_PTR); break; case MATH_OP_MODE_CUSTOM_FUNCTION: _value = Indi_Math::iMathOnIndicator(GetDataSource(), GetSymbol(), GetTf(), /*[*/ GetOpFunction(), GetMode1(), GetMode2(), GetShift1(), - GetShift2() /*]*/, 0, ToRelShift(_abs_shift), &this); + GetShift2() /*]*/, 0, ToRelShift(_abs_shift), THIS_PTR); break; } break; @@ -153,8 +153,8 @@ class Indi_Math : public Indicator { unsigned int _mode_1, unsigned int _mode_2, unsigned int _shift_1, unsigned int _shift_2, unsigned int _mode, int _shift, Indi_Math *_obj) { INDI_REQUIRE_SHIFT_OR_RETURN_EMPTY(_indi, MathMax(_shift_1, _shift_2)); - double _val_1 = _indi.GetValue(_mode_1, _shift_1); - double _val_2 = _indi.GetValue(_mode_2, _shift_2); + double _val_1 = _indi PTR_DEREF GetValue(_mode_1, _shift_1); + double _val_2 = _indi PTR_DEREF GetValue(_mode_2, _shift_2); return Math::Op(op, _val_1, _val_2); } @@ -162,8 +162,8 @@ class Indi_Math : public Indicator { unsigned int _mode_1, unsigned int _mode_2, unsigned int _shift_1, unsigned int _shift_2, unsigned int _mode, int _shift, Indi_Math *_obj) { INDI_REQUIRE_SHIFT_OR_RETURN_EMPTY(_indi, MathMax(_shift_1, _shift_2)); - double _val_1 = _indi.GetValue(_mode_1, _shift_1); - double _val_2 = _indi.GetValue(_mode_2, _shift_2); + double _val_1 = _indi PTR_DEREF GetValue(_mode_1, _shift_1); + double _val_2 = _indi PTR_DEREF GetValue(_mode_2, _shift_2); return _op(_val_1, _val_2); } diff --git a/Pattern.struct.h b/Pattern.struct.h index b71c4d709..b304263cb 100644 --- a/Pattern.struct.h +++ b/Pattern.struct.h @@ -37,7 +37,7 @@ // Defines structure for bitwise pattern values. struct PatternBitwise { - unsigned int v[]; + ARRAY(unsigned int, v); // Operator methods. unsigned int operator[](const int _index) const { return v[_index]; } // Adds new value to the end of the array. @@ -52,7 +52,7 @@ struct PatternBitwise { * @return * Returns array of counts. */ - void GetBitCount(short& _depths[]) { + void GetBitCount(ARRAY_REF(short, _depths)) { int _size = sizeof(int) * 8; for (int _bi = 0; _bi < _size; _bi++) { _depths[_bi] = GetBitCount(_bi); @@ -125,7 +125,7 @@ struct PatternBitwise { * @return * Returns array of depths. */ - void GetBitDepth(short& _depths[]) { + void GetBitDepth(ARRAY_REF(short, _depths)) { int _size = sizeof(int) * 8; for (int _bi = 0; _bi < _size; _bi++) { _depths[_bi] = GetBitDepth(_bi); @@ -163,7 +163,7 @@ struct PatternCandle { int _size = sizeof(int) * 8; for (int i = 0; i < _size; i++) { int _value = CheckPattern(1 << i) ? 1 : 0; - _s.Pass(THIS_REF, (string)(i + 1), _value, SERIALIZER_FIELD_FLAG_DYNAMIC); + _s.Pass(THIS_REF, IntegerToString(i + 1), _value, SERIALIZER_FIELD_FLAG_DYNAMIC); } return SerializerNodeObject; } @@ -296,14 +296,14 @@ struct PatternCandle1 : PatternCandle { // Struct for calculating and storing 2-candlestick patterns. struct PatternCandle2 : PatternCandle { PatternCandle2(unsigned int _pattern = 0) : PatternCandle(_pattern) {} - PatternCandle2(const BarOHLC& _c[]) : PatternCandle(PATTERN_2CANDLE_NONE) { + PatternCandle2(CONST_ARRAY_REF(BarOHLC, _c)) : PatternCandle(PATTERN_2CANDLE_NONE) { for (int i = 0; i < sizeof(int) * 8; i++) { ENUM_PATTERN_2CANDLE _enum = (ENUM_PATTERN_2CANDLE)(1 << i); SetPattern(_enum, CheckPattern(_enum, _c)); } } // Calculation methods. - static bool CheckPattern(ENUM_PATTERN_2CANDLE _enum, const BarOHLC& _c[]) { + static bool CheckPattern(ENUM_PATTERN_2CANDLE _enum, CONST_ARRAY_REF(BarOHLC, _c)) { switch (_enum) { case PATTERN_2CANDLE_BEARS: // Two bear candles. @@ -405,14 +405,14 @@ struct PatternCandle2 : PatternCandle { // Struct for calculating and storing 3-candlestick patterns. struct PatternCandle3 : PatternCandle { PatternCandle3(unsigned int _pattern = 0) : PatternCandle(_pattern) {} - PatternCandle3(const BarOHLC& _c[]) : PatternCandle(PATTERN_3CANDLE_NONE) { + PatternCandle3(CONST_ARRAY_REF(BarOHLC, _c)) : PatternCandle(PATTERN_3CANDLE_NONE) { for (int i = 0; i < sizeof(int) * 8; i++) { ENUM_PATTERN_3CANDLE _enum = (ENUM_PATTERN_3CANDLE)(1 << i); SetPattern(_enum, CheckPattern(_enum, _c)); } } // Calculation methods. - static bool CheckPattern(ENUM_PATTERN_3CANDLE _enum, const BarOHLC& _c[]) { + static bool CheckPattern(ENUM_PATTERN_3CANDLE _enum, CONST_ARRAY_REF(BarOHLC, _c)) { switch (_enum) { case PATTERN_3CANDLE_BEARS: // Three bear candles. @@ -521,14 +521,14 @@ struct PatternCandle3 : PatternCandle { // Struct for calculating and storing 4-candlestick patterns. struct PatternCandle4 : PatternCandle { PatternCandle4(unsigned int _pattern = 0) : PatternCandle(_pattern) {} - PatternCandle4(const BarOHLC& _c[]) : PatternCandle(PATTERN_4CANDLE_NONE) { + PatternCandle4(CONST_ARRAY_REF(BarOHLC, _c)) : PatternCandle(PATTERN_4CANDLE_NONE) { for (int i = 0; i < sizeof(int) * 8; i++) { ENUM_PATTERN_4CANDLE _enum = (ENUM_PATTERN_4CANDLE)(1 << i); SetPattern(_enum, CheckPattern(_enum, _c)); } } // Calculation methods. - static bool CheckPattern(ENUM_PATTERN_4CANDLE _enum, const BarOHLC& _c[]) { + static bool CheckPattern(ENUM_PATTERN_4CANDLE _enum, CONST_ARRAY_REF(BarOHLC, _c)) { PatternCandle3 _c3(_c); switch (_enum) { case PATTERN_4CANDLE_BEARS: @@ -539,7 +539,7 @@ struct PatternCandle4 : PatternCandle { return /* Bear 0 cont. */ _c[0].open > _c[0].close && /* Bear 0 is low */ _c[0].low < _c[3].low && - /* Bear 0 body is large */ _c3.CheckPattern(PATTERN_3CANDLE_BODY0_GT_SUM) && + /* Bear 0 body is large */ _c3.CheckPattern(PATTERN_3CANDLE_BODY0_GT_SUM, _c) && /* Bull 1 */ _c[1].open < _c[1].close && /* Bull 2 */ _c[2].open < _c[2].close && /* Bear 3 */ _c[3].open > _c[3].close && @@ -575,7 +575,7 @@ struct PatternCandle4 : PatternCandle { return /* Bull 0 cont. */ _c[0].open < _c[0].close && /* Bull 0 is high */ _c[0].high > _c[3].high && - /* Bull 0 body is large */ _c3.CheckPattern(PATTERN_3CANDLE_BODY0_GT_SUM) && + /* Bull 0 body is large */ _c3.CheckPattern(PATTERN_3CANDLE_BODY0_GT_SUM, _c) && /* Bear 1 */ _c[1].open > _c[1].close && /* Bear 2 */ _c[2].open > _c[2].close && /* Bull 3 */ _c[3].open < _c[3].close && @@ -687,14 +687,14 @@ struct PatternCandle4 : PatternCandle { // Struct for calculating and storing 4-candlestick patterns. struct PatternCandle5 : PatternCandle { PatternCandle5(unsigned int _pattern = 0) : PatternCandle(_pattern) {} - PatternCandle5(const BarOHLC& _c[]) : PatternCandle(PATTERN_5CANDLE_NONE) { + PatternCandle5(CONST_ARRAY_REF(BarOHLC, _c)) : PatternCandle(PATTERN_5CANDLE_NONE) { for (int i = 0; i < sizeof(int) * 8; i++) { ENUM_PATTERN_5CANDLE _enum = (ENUM_PATTERN_5CANDLE)(1 << i); SetPattern(_enum, CheckPattern(_enum, _c)); } } // Calculation methods. - static bool CheckPattern(ENUM_PATTERN_5CANDLE _enum, const BarOHLC& _c[]) { + static bool CheckPattern(ENUM_PATTERN_5CANDLE _enum, CONST_ARRAY_REF(BarOHLC, _c)) { switch (_enum) { case PATTERN_5CANDLE_BODY0_DIFF_PEAK: // Diff of the last two bodies is at a peak. @@ -838,14 +838,14 @@ struct PatternCandle5 : PatternCandle { // Struct for calculating and storing 4-candlestick patterns. struct PatternCandle6 : PatternCandle { PatternCandle6(unsigned int _pattern = 0) : PatternCandle(_pattern) {} - PatternCandle6(const BarOHLC& _c[]) : PatternCandle(PATTERN_6CANDLE_NONE) { + PatternCandle6(CONST_ARRAY_REF(BarOHLC, _c)) : PatternCandle(PATTERN_6CANDLE_NONE) { for (int i = 0; i < sizeof(int) * 8; i++) { ENUM_PATTERN_6CANDLE _enum = (ENUM_PATTERN_6CANDLE)(1 << i); SetPattern(_enum, CheckPattern(_enum, _c)); } } // Calculation methods. - static bool CheckPattern(ENUM_PATTERN_6CANDLE _enum, const BarOHLC& _c[]) { + static bool CheckPattern(ENUM_PATTERN_6CANDLE _enum, CONST_ARRAY_REF(BarOHLC, _c)) { switch (_enum) { case PATTERN_6CANDLE_NONE: return false; @@ -857,14 +857,14 @@ struct PatternCandle6 : PatternCandle { // Struct for calculating and storing 4-candlestick patterns. struct PatternCandle7 : PatternCandle { PatternCandle7(unsigned int _pattern = 0) : PatternCandle(_pattern) {} - PatternCandle7(const BarOHLC& _c[]) : PatternCandle(PATTERN_7CANDLE_NONE) { + PatternCandle7(CONST_ARRAY_REF(BarOHLC, _c)) : PatternCandle(PATTERN_7CANDLE_NONE) { for (int i = 0; i < sizeof(int) * 8; i++) { ENUM_PATTERN_7CANDLE _enum = (ENUM_PATTERN_7CANDLE)(1 << i); SetPattern(_enum, CheckPattern(_enum, _c)); } } // Calculation methods. - static bool CheckPattern(ENUM_PATTERN_7CANDLE _enum, const BarOHLC& _c[]) { + static bool CheckPattern(ENUM_PATTERN_7CANDLE _enum, CONST_ARRAY_REF(BarOHLC, _c)) { switch (_enum) { case PATTERN_7CANDLE_NONE: return false; @@ -876,14 +876,14 @@ struct PatternCandle7 : PatternCandle { // Struct for calculating and storing 4-candlestick patterns. struct PatternCandle8 : PatternCandle { PatternCandle8(unsigned int _pattern = 0) : PatternCandle(_pattern) {} - PatternCandle8(const BarOHLC& _c[]) : PatternCandle(PATTERN_8CANDLE_NONE) { + PatternCandle8(CONST_ARRAY_REF(BarOHLC, _c)) : PatternCandle(PATTERN_8CANDLE_NONE) { for (int i = 0; i < sizeof(int) * 8; i++) { ENUM_PATTERN_8CANDLE _enum = (ENUM_PATTERN_8CANDLE)(1 << i); SetPattern(_enum, CheckPattern(_enum, _c)); } } // Calculation methods. - static bool CheckPattern(ENUM_PATTERN_8CANDLE _enum, const BarOHLC& _c[]) { + static bool CheckPattern(ENUM_PATTERN_8CANDLE _enum, CONST_ARRAY_REF(BarOHLC, _c)) { switch (_enum) { case PATTERN_8CANDLE_NONE: return false; @@ -895,14 +895,14 @@ struct PatternCandle8 : PatternCandle { // Struct for calculating and storing 4-candlestick patterns. struct PatternCandle9 : PatternCandle { PatternCandle9(unsigned int _pattern = 0) : PatternCandle(_pattern) {} - PatternCandle9(const BarOHLC& _c[]) : PatternCandle(PATTERN_9CANDLE_NONE) { + PatternCandle9(CONST_ARRAY_REF(BarOHLC, _c)) : PatternCandle(PATTERN_9CANDLE_NONE) { for (int i = 0; i < sizeof(int) * 8; i++) { ENUM_PATTERN_9CANDLE _enum = (ENUM_PATTERN_9CANDLE)(1 << i); SetPattern(_enum, CheckPattern(_enum, _c)); } } // Calculation methods. - static bool CheckPattern(ENUM_PATTERN_9CANDLE _enum, const BarOHLC& _c[]) { + static bool CheckPattern(ENUM_PATTERN_9CANDLE _enum, CONST_ARRAY_REF(BarOHLC, _c)) { switch (_enum) { case PATTERN_9CANDLE_NONE: return false; @@ -914,14 +914,14 @@ struct PatternCandle9 : PatternCandle { // Struct for calculating and storing 4-candlestick patterns. struct PatternCandle10 : PatternCandle { PatternCandle10(unsigned int _pattern = 0) : PatternCandle(_pattern) {} - PatternCandle10(const BarOHLC& _c[]) : PatternCandle(PATTERN_10CANDLE_NONE) { + PatternCandle10(CONST_ARRAY_REF(BarOHLC, _c)) : PatternCandle(PATTERN_10CANDLE_NONE) { for (int i = 0; i < sizeof(int) * 8; i++) { ENUM_PATTERN_10CANDLE _enum = (ENUM_PATTERN_10CANDLE)(1 << i); SetPattern(_enum, CheckPattern(_enum, _c)); } } // Calculation methods. - static bool CheckPattern(ENUM_PATTERN_10CANDLE _enum, const BarOHLC& _c[]) { + static bool CheckPattern(ENUM_PATTERN_10CANDLE _enum, CONST_ARRAY_REF(BarOHLC, _c)) { switch (_enum) { case PATTERN_10CANDLE_NONE: return false; @@ -954,7 +954,18 @@ struct PatternEntry { pattern8(0), pattern9(0), pattern10(0) {} - PatternEntry(BarOHLC& _c[]) + PatternEntry(ARRAY_REF(BarOHLC, _c)) + : pattern1(_c[0]), + pattern2(_c), + pattern3(_c), + pattern4(_c), + pattern5(_c), + pattern6(_c), + pattern7(_c), + pattern8(_c), + pattern9(_c), + pattern10(_c) {} + PatternEntry(ARRAY_REF(BarOHLC, _c)) : pattern1(_c[0]), pattern2(_c), pattern3(_c), From fd5e6dbe4ddd4119ec72be2da50b758fbb5d25b6 Mon Sep 17 00:00:00 2001 From: kenorb Date: Thu, 22 Jun 2023 23:29:11 +0100 Subject: [PATCH 16/26] Moves global functions at the end for C++ compatibility --- Indicators/DrawIndicator.mqh | 4 +-- Indicators/Indi_AC.mqh | 25 ++++++++---------- Indicators/Indi_AD.mqh | 25 ++++++++---------- Indicators/Indi_ADX.mqh | 21 +++++++-------- Indicators/Indi_AO.mqh | 19 ++++++-------- Indicators/Indi_ATR.mqh | 19 ++++++-------- Indicators/Indi_BWMFI.mqh | 19 ++++++-------- Indicators/Indi_BearsPower.mqh | 19 ++++++-------- Indicators/Indi_BullsPower.mqh | 19 ++++++-------- Indicators/Indi_CCI.mqh | 27 +++++++++---------- Indicators/Indi_DeMarker.mqh | 19 ++++++-------- Indicators/Indi_Force.mqh | 21 +++++++-------- Indicators/Indi_Fractals.mqh | 19 ++++++-------- Indicators/Indi_Gator.mqh | 23 +++++++--------- Indicators/Indi_Ichimoku.mqh | 19 ++++++-------- Indicators/Indi_MFI.mqh | 19 ++++++-------- Indicators/Indi_Momentum.mqh | 19 ++++++-------- Indicators/Indi_OBV.mqh | 19 ++++++-------- Indicators/Indi_OsMA.mqh | 21 +++++++-------- Indicators/Indi_RVI.mqh | 19 ++++++-------- Indicators/Indi_StdDev.mqh | 29 +++++++++----------- Indicators/Oscillator/Indi_MACD.h | 21 +++++++-------- Indicators/Oscillator/Indi_Stochastic.h | 23 +++++++--------- Indicators/Oscillator/Indi_WPR.h | 19 ++++++-------- Indicators/Price/Indi_MA.h | 32 +++++++++++----------- Indicators/PriceMulti/Indi_Alligator.h | 25 ++++++++---------- Indicators/PriceRange/Indi_Bands.h | 23 +++++++--------- Indicators/PriceRange/Indi_Envelopes.h | 35 +++++++++++-------------- Indicators/PriceRange/Indi_SAR.h | 19 ++++++-------- 29 files changed, 268 insertions(+), 353 deletions(-) diff --git a/Indicators/DrawIndicator.mqh b/Indicators/DrawIndicator.mqh index a34e8b708..7293b5cdc 100644 --- a/Indicators/DrawIndicator.mqh +++ b/Indicators/DrawIndicator.mqh @@ -33,9 +33,7 @@ #include "../Platform/Plot.h" #include "../Storage/Dict/DictObject.h" #include "../Storage/Object.h" - -// Forward declaration. -class IndicatorBase; +#include "../Indicator/IndicatorBase.h" class DrawPoint { public: diff --git a/Indicators/Indi_AC.mqh b/Indicators/Indi_AC.mqh index f323fa4f1..0cd7efe82 100644 --- a/Indicators/Indi_AC.mqh +++ b/Indicators/Indi_AC.mqh @@ -20,24 +20,13 @@ * */ -#ifndef __MQL__ -// Allows the preprocessor to include a header file when it is needed. -#pragma once -#endif - // Includes. #include "../Indicator/Indicator.h" #include "../Storage/Dict/Buffer/BufferStruct.h" -#ifndef __MQL4__ -// Forward declaration. -class Indi_AC; - -// Defines global functions (for MQL4 backward compability). -double iAC(string _symbol, int _tf, int _shift) { - ResetLastError(); - return Indi_AC::iAC(_symbol, (ENUM_TIMEFRAMES)_tf, _shift); -} +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once #endif // Structs. @@ -155,3 +144,11 @@ class Indi_AC : public Indicator { return _ptr; } }; + +#ifndef __MQL4__ +// Defines global functions (for MQL4 backward compability). +double iAC(string _symbol, int _tf, int _shift) { + ResetLastError(); + return Indi_AC::iAC(_symbol, (ENUM_TIMEFRAMES)_tf, _shift); +} +#endif diff --git a/Indicators/Indi_AD.mqh b/Indicators/Indi_AD.mqh index 4147ab62e..e4bb3ee92 100644 --- a/Indicators/Indi_AD.mqh +++ b/Indicators/Indi_AD.mqh @@ -20,23 +20,12 @@ * */ -#ifndef __MQL__ -// Allows the preprocessor to include a header file when it is needed. -#pragma once -#endif - // Includes. #include "../Indicator/Indicator.h" -#ifndef __MQL4__ -// Forward declaration. -class Indi_AD; - -// Defines global functions (for MQL4 backward compability). -double iAD(string _symbol, int _tf, int _shift) { - ResetLastError(); - return Indi_AD::iAD(_symbol, (ENUM_TIMEFRAMES)_tf, _shift); -} +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once #endif // Structs. @@ -128,3 +117,11 @@ class Indi_AD : public Indicator { return _value; } }; + +#ifndef __MQL4__ +// Defines global functions (for MQL4 backward compability). +double iAD(string _symbol, int _tf, int _shift) { + ResetLastError(); + return Indi_AD::iAD(_symbol, (ENUM_TIMEFRAMES)_tf, _shift); +} +#endif diff --git a/Indicators/Indi_ADX.mqh b/Indicators/Indi_ADX.mqh index c904740f2..2d0a81e4a 100644 --- a/Indicators/Indi_ADX.mqh +++ b/Indicators/Indi_ADX.mqh @@ -24,18 +24,6 @@ #include "../Indicator/Indicator.h" #include "Price/Indi_Price.h" -#ifndef __MQL4__ -// Forward declaration. -class Indi_ADX; - -// Defines global functions (for MQL4 backward compability). -double iADX(string _symbol, int _tf, int _period, int _ap, int _mode, int _shift) { - ResetLastError(); - return Indi_ADX::iADX(_symbol, (ENUM_TIMEFRAMES)_tf, _period, (ENUM_APPLIED_PRICE)_ap, (ENUM_INDI_ADX_LINE)_mode, - _shift); -} -#endif - // Structs. struct IndiADXParams : IndicatorParams { unsigned int period; @@ -179,3 +167,12 @@ class Indi_ADX : public Indicator { iparams.applied_price = _applied_price; } }; + +#ifndef __MQL4__ +// Defines global functions (for MQL4 backward compability). +double iADX(string _symbol, int _tf, int _period, int _ap, int _mode, int _shift) { + ResetLastError(); + return Indi_ADX::iADX(_symbol, (ENUM_TIMEFRAMES)_tf, _period, (ENUM_APPLIED_PRICE)_ap, (ENUM_INDI_ADX_LINE)_mode, + _shift); +} +#endif diff --git a/Indicators/Indi_AO.mqh b/Indicators/Indi_AO.mqh index bfff08ce4..ecc2be6dc 100644 --- a/Indicators/Indi_AO.mqh +++ b/Indicators/Indi_AO.mqh @@ -23,17 +23,6 @@ // Includes. #include "../Indicator/Indicator.h" -#ifndef __MQL4__ -// Forward declaration. -class Indi_AO; - -// Defines global functions (for MQL4 backward compability). -double iAO(string _symbol, int _tf, int _shift) { - ResetLastError(); - return Indi_AO::iAO(_symbol, (ENUM_TIMEFRAMES)_tf, _shift); -} -#endif - // Structs. struct IndiAOParams : IndicatorParams { // Struct constructor. @@ -153,3 +142,11 @@ class Indi_AO : public Indicator { */ bool IsValidEntry(IndicatorDataEntry &_entry) override { return _entry.values[0].Get() != EMPTY_VALUE; } }; + +#ifndef __MQL4__ +// Defines global functions (for MQL4 backward compability). +double iAO(string _symbol, int _tf, int _shift) { + ResetLastError(); + return Indi_AO::iAO(_symbol, (ENUM_TIMEFRAMES)_tf, _shift); +} +#endif diff --git a/Indicators/Indi_ATR.mqh b/Indicators/Indi_ATR.mqh index 19113ce3f..73009cc0b 100644 --- a/Indicators/Indi_ATR.mqh +++ b/Indicators/Indi_ATR.mqh @@ -23,17 +23,6 @@ // Includes. #include "../Indicator/Indicator.h" -#ifndef __MQL4__ -// Forward declaration. -class Indi_ATR; - -// Defines global functions (for MQL4 backward compability). -double iATR(string _symbol, int _tf, int _period, int _shift) { - ResetLastError(); - return Indi_ATR::iATR(_symbol, (ENUM_TIMEFRAMES)_tf, _period, _shift); -} -#endif - // Structs. struct IndiATRParams : IndicatorParams { unsigned int period; @@ -150,3 +139,11 @@ class Indi_ATR : public Indicator { iparams.period = _period; } }; + +#ifndef __MQL4__ +// Defines global functions (for MQL4 backward compability). +double iATR(string _symbol, int _tf, int _period, int _shift) { + ResetLastError(); + return Indi_ATR::iATR(_symbol, (ENUM_TIMEFRAMES)_tf, _period, _shift); +} +#endif diff --git a/Indicators/Indi_BWMFI.mqh b/Indicators/Indi_BWMFI.mqh index 13ca86bc0..2582c2eec 100644 --- a/Indicators/Indi_BWMFI.mqh +++ b/Indicators/Indi_BWMFI.mqh @@ -23,17 +23,6 @@ // Includes. #include "../Indicator/Indicator.h" -#ifndef __MQL4__ -// Forward declaration. -class Indi_BWMFI; - -// Defines global functions (for MQL4 backward compability). -double iBWMFI(string _symbol, int _tf, int _shift) { - ResetLastError(); - return Indi_BWMFI::iBWMFI(_symbol, (ENUM_TIMEFRAMES)_tf, _shift); -} -#endif - // Enumerations. // Indicator line identifiers used in BWMFI indicators. enum ENUM_BWMFI_BUFFER { BWMFI_BUFFER = 0, BWMFI_HISTCOLOR = 1, FINAL_BWMFI_BUFFER_ENTRY }; @@ -199,3 +188,11 @@ class Indi_BWMFI : public Indicator { !_entry.HasValue(DBL_MAX); } }; + +#ifndef __MQL4__ +// Defines global functions (for MQL4 backward compability). +double iBWMFI(string _symbol, int _tf, int _shift) { + ResetLastError(); + return Indi_BWMFI::iBWMFI(_symbol, (ENUM_TIMEFRAMES)_tf, _shift); +} +#endif diff --git a/Indicators/Indi_BearsPower.mqh b/Indicators/Indi_BearsPower.mqh index 6dea2d286..475ce9b97 100644 --- a/Indicators/Indi_BearsPower.mqh +++ b/Indicators/Indi_BearsPower.mqh @@ -23,17 +23,6 @@ // Includes. #include "../Indicator/Indicator.h" -#ifndef __MQL4__ -// Forward declaration. -class Indi_BearsPower; - -// Defines global functions (for MQL4 backward compability). -double iBearsPower(string _symbol, int _tf, int _period, int _ap, int _shift) { - ResetLastError(); - return Indi_BearsPower::iBearsPower(_symbol, (ENUM_TIMEFRAMES)_tf, _period, (ENUM_APPLIED_PRICE)_ap, _shift); -} -#endif - // Structs. struct IndiBearsPowerParams : IndicatorParams { unsigned int period; @@ -153,3 +142,11 @@ class Indi_BearsPower : public Indicator { iparams.applied_price = _applied_price; } }; + +#ifndef __MQL4__ +// Defines global functions (for MQL4 backward compability). +double iBearsPower(string _symbol, int _tf, int _period, int _ap, int _shift) { + ResetLastError(); + return Indi_BearsPower::iBearsPower(_symbol, (ENUM_TIMEFRAMES)_tf, _period, (ENUM_APPLIED_PRICE)_ap, _shift); +} +#endif diff --git a/Indicators/Indi_BullsPower.mqh b/Indicators/Indi_BullsPower.mqh index 16ad2b2d6..737b0bf7e 100644 --- a/Indicators/Indi_BullsPower.mqh +++ b/Indicators/Indi_BullsPower.mqh @@ -23,17 +23,6 @@ // Includes. #include "../Indicator/Indicator.h" -#ifndef __MQL4__ -// Forward declaration. -class Indi_BullsPower; - -// Defines global functions (for MQL4 backward compability). -double iBullsPower(string _symbol, int _tf, int _period, int _ap, int _shift) { - ResetLastError(); - return Indi_BullsPower::iBullsPower(_symbol, (ENUM_TIMEFRAMES)_tf, _period, (ENUM_APPLIED_PRICE)_ap, _shift); -} -#endif - // Structs. struct IndiBullsPowerParams : IndicatorParams { unsigned int period; @@ -152,3 +141,11 @@ class Indi_BullsPower : public Indicator { iparams.applied_price = _applied_price; } }; + +#ifndef __MQL4__ +// Defines global functions (for MQL4 backward compability). +double iBullsPower(string _symbol, int _tf, int _period, int _ap, int _shift) { + ResetLastError(); + return Indi_BullsPower::iBullsPower(_symbol, (ENUM_TIMEFRAMES)_tf, _period, (ENUM_APPLIED_PRICE)_ap, _shift); +} +#endif diff --git a/Indicators/Indi_CCI.mqh b/Indicators/Indi_CCI.mqh index 6584925db..fa69935b2 100644 --- a/Indicators/Indi_CCI.mqh +++ b/Indicators/Indi_CCI.mqh @@ -26,21 +26,6 @@ #include "Price/Indi_MA.h" #include "Price/Indi_Price.h" -#ifndef __MQL4__ -// Forward declaration. -class Indi_CCI; - -// Defines global functions (for MQL4 backward compability). -double iCCI(string _symbol, int _tf, int _period, int _ap, int _shift) { - ResetLastError(); - return Indi_CCI::iCCI(_symbol, (ENUM_TIMEFRAMES)_tf, _period, (ENUM_APPLIED_PRICE)_ap, _shift); -} -double iCCIOnArray(double &_arr[], int _total, int _period, int _abs_shift) { - ResetLastError(); - return Indi_CCI::iCCIOnArray(_arr, _total, _period, _abs_shift); -} -#endif - // Structs. struct IndiCCIParams : IndicatorParams { unsigned int period; @@ -232,3 +217,15 @@ class Indi_CCI : public Indicator { iparams.applied_price = _applied_price; } }; + +#ifndef __MQL4__ +// Defines global functions (for MQL4 backward compability). +double iCCI(string _symbol, int _tf, int _period, int _ap, int _shift) { + ResetLastError(); + return Indi_CCI::iCCI(_symbol, (ENUM_TIMEFRAMES)_tf, _period, (ENUM_APPLIED_PRICE)_ap, _shift); +} +double iCCIOnArray(double &_arr[], int _total, int _period, int _abs_shift) { + ResetLastError(); + return Indi_CCI::iCCIOnArray(_arr, _total, _period, _abs_shift); +} +#endif diff --git a/Indicators/Indi_DeMarker.mqh b/Indicators/Indi_DeMarker.mqh index dad279880..e3b7bb9aa 100644 --- a/Indicators/Indi_DeMarker.mqh +++ b/Indicators/Indi_DeMarker.mqh @@ -23,17 +23,6 @@ // Includes. #include "../Indicator/Indicator.h" -#ifndef __MQL4__ -// Forward declaration. -class Indi_DeMarker; - -// Defines global functions (for MQL4 backward compability). -double iDeMarker(string _symbol, int _tf, int _period, int _shift) { - ResetLastError(); - return Indi_DeMarker::iDeMarker(_symbol, (ENUM_TIMEFRAMES)_tf, _period, _shift); -} -#endif - // Structs. struct IndiDeMarkerParams : IndicatorParams { unsigned int period; @@ -132,3 +121,11 @@ class Indi_DeMarker : public Indicator { iparams.period = _period; } }; + +#ifndef __MQL4__ +// Defines global functions (for MQL4 backward compability). +double iDeMarker(string _symbol, int _tf, int _period, int _shift) { + ResetLastError(); + return Indi_DeMarker::iDeMarker(_symbol, (ENUM_TIMEFRAMES)_tf, _period, _shift); +} +#endif diff --git a/Indicators/Indi_Force.mqh b/Indicators/Indi_Force.mqh index 9c599a1d7..e04c4cf1d 100644 --- a/Indicators/Indi_Force.mqh +++ b/Indicators/Indi_Force.mqh @@ -34,18 +34,6 @@ // Includes. #include "../Indicator/Indicator.h" -#ifndef __MQL4__ -// Forward declaration. -class Indi_Force; - -// Defines global functions (for MQL4 backward compability). -double iForce(string _symbol, int _tf, int _period, int _ma_method, int _ap, int _shift) { - ResetLastError(); - return Indi_Force::iForce(_symbol, (ENUM_TIMEFRAMES)_tf, _period, (ENUM_MA_METHOD)_ma_method, (ENUM_APPLIED_PRICE)_ap, - _shift); -} -#endif - // Structs. struct IndiForceParams : IndicatorParams { unsigned int period; @@ -176,3 +164,12 @@ class Indi_Force : public Indicator { iparams.applied_price = _applied_price; } }; + +#ifndef __MQL4__ +// Defines global functions (for MQL4 backward compability). +double iForce(string _symbol, int _tf, int _period, int _ma_method, int _ap, int _shift) { + ResetLastError(); + return Indi_Force::iForce(_symbol, (ENUM_TIMEFRAMES)_tf, _period, (ENUM_MA_METHOD)_ma_method, (ENUM_APPLIED_PRICE)_ap, + _shift); +} +#endif diff --git a/Indicators/Indi_Fractals.mqh b/Indicators/Indi_Fractals.mqh index 4eb4a0f27..d9ccf5f6c 100644 --- a/Indicators/Indi_Fractals.mqh +++ b/Indicators/Indi_Fractals.mqh @@ -23,17 +23,6 @@ // Includes. #include "../Indicator/Indicator.h" -#ifndef __MQL4__ -// Forward declaration. -class Indi_Fractals; - -// Defines global functions (for MQL4 backward compability). -double iFractals(string _symbol, int _tf, int _mode, int _shift) { - ResetLastError(); - return Indi_Fractals::iFractals(_symbol, (ENUM_TIMEFRAMES)_tf, (ENUM_LO_UP_LINE)_mode, _shift); -} -#endif - // Structs. struct IndiFractalsParams : IndicatorParams { // Struct constructors. @@ -156,3 +145,11 @@ class Indi_Fractals : public Indicator { return !_entry.HasValue(_wrong_value); } }; + +#ifndef __MQL4__ +// Defines global functions (for MQL4 backward compability). +double iFractals(string _symbol, int _tf, int _mode, int _shift) { + ResetLastError(); + return Indi_Fractals::iFractals(_symbol, (ENUM_TIMEFRAMES)_tf, (ENUM_LO_UP_LINE)_mode, _shift); +} +#endif diff --git a/Indicators/Indi_Gator.mqh b/Indicators/Indi_Gator.mqh index a3088f23b..61430807c 100644 --- a/Indicators/Indi_Gator.mqh +++ b/Indicators/Indi_Gator.mqh @@ -30,19 +30,6 @@ // Includes. #include "../Indicator/Indicator.h" -#ifndef __MQL4__ -// Forward declaration. -class Indi_Gator; - -// Defines global functions (for MQL4 backward compability). -double iGator(string _symbol, int _tf, int _jp, int _js, int _tp, int _ts, int _lp, int _ls, int _ma_method, int _ap, - int _mode, int _shift) { - ResetLastError(); - return Indi_Gator::iGator(_symbol, (ENUM_TIMEFRAMES)_tf, _jp, _js, _tp, _ts, _lp, _ls, (ENUM_MA_METHOD)_ma_method, - (ENUM_APPLIED_PRICE)_ap, (ENUM_GATOR_HISTOGRAM)_mode, _shift); -} -#endif - #ifndef __MQLBUILD__ // Indicator constants. // @docs @@ -338,3 +325,13 @@ class Indi_Gator : public Indicator { iparams.applied_price = _applied_price; } }; + +#ifndef __MQL4__ +// Defines global functions (for MQL4 backward compability). +double iGator(string _symbol, int _tf, int _jp, int _js, int _tp, int _ts, int _lp, int _ls, int _ma_method, int _ap, + int _mode, int _shift) { + ResetLastError(); + return Indi_Gator::iGator(_symbol, (ENUM_TIMEFRAMES)_tf, _jp, _js, _tp, _ts, _lp, _ls, (ENUM_MA_METHOD)_ma_method, + (ENUM_APPLIED_PRICE)_ap, (ENUM_GATOR_HISTOGRAM)_mode, _shift); +} +#endif diff --git a/Indicators/Indi_Ichimoku.mqh b/Indicators/Indi_Ichimoku.mqh index 8541d85a6..fa568fad7 100644 --- a/Indicators/Indi_Ichimoku.mqh +++ b/Indicators/Indi_Ichimoku.mqh @@ -23,17 +23,6 @@ // Includes. #include "../Indicator/Indicator.h" -#ifndef __MQL4__ -// Forward declaration. -class Indi_Ichimoku; - -// Defines global functions (for MQL4 backward compability). -double iIchimoku(string _symbol, int _tf, int _ts, int _ks, int _ssb, int _mode, int _shift) { - ResetLastError(); - return Indi_Ichimoku::iIchimoku(_symbol, (ENUM_TIMEFRAMES)_tf, _ts, _ks, _ssb, _mode, _shift); -} -#endif - #ifndef __MQLBUILD__ // Indicator constants. // @docs @@ -238,3 +227,11 @@ class Indi_Ichimoku : public Indicator { iparams.senkou_span_b = _senkou_span_b; } }; + +#ifndef __MQL4__ +// Defines global functions (for MQL4 backward compability). +double iIchimoku(string _symbol, int _tf, int _ts, int _ks, int _ssb, int _mode, int _shift) { + ResetLastError(); + return Indi_Ichimoku::iIchimoku(_symbol, (ENUM_TIMEFRAMES)_tf, _ts, _ks, _ssb, _mode, _shift); +} +#endif diff --git a/Indicators/Indi_MFI.mqh b/Indicators/Indi_MFI.mqh index c38cf4d72..be35d5e77 100644 --- a/Indicators/Indi_MFI.mqh +++ b/Indicators/Indi_MFI.mqh @@ -23,17 +23,6 @@ // Includes. #include "../Indicator/Indicator.h" -#ifndef __MQL4__ -// Forward declaration. -class Indi_MFI; - -// Defines global functions (for MQL4 backward compability). -double iMFI(string _symbol, int _tf, int _period, int _shift) { - ResetLastError(); - return Indi_MFI::iMFI(_symbol, (ENUM_TIMEFRAMES)_tf, _period, _shift); -} -#endif - // Structs. struct IndiMFIParams : IndicatorParams { unsigned int ma_period; @@ -180,3 +169,11 @@ class Indi_MFI : public Indicator { iparams.applied_volume = _applied_volume; } }; + +#ifndef __MQL4__ +// Defines global functions (for MQL4 backward compability). +double iMFI(string _symbol, int _tf, int _period, int _shift) { + ResetLastError(); + return Indi_MFI::iMFI(_symbol, (ENUM_TIMEFRAMES)_tf, _period, _shift); +} +#endif diff --git a/Indicators/Indi_Momentum.mqh b/Indicators/Indi_Momentum.mqh index 953d63d0f..f10cb04be 100644 --- a/Indicators/Indi_Momentum.mqh +++ b/Indicators/Indi_Momentum.mqh @@ -33,17 +33,6 @@ #include "../Indicator/Indicator.h" #include "Indi_PriceFeeder.mqh" -#ifndef __MQL4__ -// Forward declaration. -class Indi_Momentum; - -// Defines global functions (for MQL4 backward compability). -double iMomentum(string _symbol, int _tf, int _period, int _ap, int _shift) { - ResetLastError(); - return Indi_Momentum::iMomentum(_symbol, (ENUM_TIMEFRAMES)_tf, _period, (ENUM_APPLIED_PRICE)_ap, _shift); -} -#endif - // Structs. struct IndiMomentumParams : IndicatorParams { unsigned int period; @@ -222,3 +211,11 @@ class Indi_Momentum : public Indicator { iparams.applied_price = _ap; } }; + +#ifndef __MQL4__ +// Defines global functions (for MQL4 backward compability). +double iMomentum(string _symbol, int _tf, int _period, int _ap, int _shift) { + ResetLastError(); + return Indi_Momentum::iMomentum(_symbol, (ENUM_TIMEFRAMES)_tf, _period, (ENUM_APPLIED_PRICE)_ap, _shift); +} +#endif diff --git a/Indicators/Indi_OBV.mqh b/Indicators/Indi_OBV.mqh index b9128b1f2..cd9378bf3 100644 --- a/Indicators/Indi_OBV.mqh +++ b/Indicators/Indi_OBV.mqh @@ -23,17 +23,6 @@ // Includes. #include "../Indicator/Indicator.h" -#ifndef __MQL4__ -// Forward declaration. -class Indi_OBV; - -// Defines global functions (for MQL4 backward compability). -double iOBV(string _symbol, int _tf, int _av, int _shift) { - ResetLastError(); - return Indi_OBV::iOBV(_symbol, (ENUM_TIMEFRAMES)_tf, (ENUM_APPLIED_VOLUME)_av, _shift); -} -#endif - // Structs. struct IndiOBVParams : IndicatorParams { ENUM_APPLIED_PRICE applied_price; // MT4 only. @@ -185,3 +174,11 @@ class Indi_OBV : public Indicator { iparams.applied_volume = _applied_volume; } }; + +#ifndef __MQL4__ +// Defines global functions (for MQL4 backward compability). +double iOBV(string _symbol, int _tf, int _av, int _shift) { + ResetLastError(); + return Indi_OBV::iOBV(_symbol, (ENUM_TIMEFRAMES)_tf, (ENUM_APPLIED_VOLUME)_av, _shift); +} +#endif diff --git a/Indicators/Indi_OsMA.mqh b/Indicators/Indi_OsMA.mqh index 60587bda7..697d06d7c 100644 --- a/Indicators/Indi_OsMA.mqh +++ b/Indicators/Indi_OsMA.mqh @@ -23,18 +23,6 @@ // Includes. #include "../Indicator/Indicator.h" -#ifndef __MQL4__ -// Forward declaration. -class Indi_OsMA; - -// Defines global functions (for MQL4 backward compability). -double iOsMA(string _symbol, int _tf, int _ema_fp, int _ema_sp, int _signal_period, int _ap, int _shift) { - ResetLastError(); - return Indi_OsMA::iOsMA(_symbol, (ENUM_TIMEFRAMES)_tf, _ema_fp, _ema_sp, _signal_period, (ENUM_APPLIED_PRICE)_ap, - _shift); -} -#endif - // Structs. struct IndiOsMAParams : IndicatorParams { int ema_fast_period; @@ -203,3 +191,12 @@ class Indi_OsMA : public Indicator { iparams.applied_price = _applied_price; } }; + +#ifndef __MQL4__ +// Defines global functions (for MQL4 backward compability). +double iOsMA(string _symbol, int _tf, int _ema_fp, int _ema_sp, int _signal_period, int _ap, int _shift) { + ResetLastError(); + return Indi_OsMA::iOsMA(_symbol, (ENUM_TIMEFRAMES)_tf, _ema_fp, _ema_sp, _signal_period, (ENUM_APPLIED_PRICE)_ap, + _shift); +} +#endif diff --git a/Indicators/Indi_RVI.mqh b/Indicators/Indi_RVI.mqh index 07a0a5bb1..6d5337720 100644 --- a/Indicators/Indi_RVI.mqh +++ b/Indicators/Indi_RVI.mqh @@ -23,17 +23,6 @@ // Includes. #include "../Indicator/Indicator.h" -#ifndef __MQL4__ -// Forward declaration. -class Indi_RVI; - -// Defines global functions (for MQL4 backward compability). -double iRVI(string _symbol, int _tf, int _period, int _mode, int _shift) { - ResetLastError(); - return Indi_RVI::iRVI(_symbol, (ENUM_TIMEFRAMES)_tf, _period, (ENUM_SIGNAL_LINE)_mode, _shift); -} -#endif - // Structs. struct IndiRVIParams : IndicatorParams { unsigned int period; @@ -146,3 +135,11 @@ class Indi_RVI : public Indicator { iparams.period = _period; } }; + +#ifndef __MQL4__ +// Defines global functions (for MQL4 backward compability). +double iRVI(string _symbol, int _tf, int _period, int _mode, int _shift) { + ResetLastError(); + return Indi_RVI::iRVI(_symbol, (ENUM_TIMEFRAMES)_tf, _period, (ENUM_SIGNAL_LINE)_mode, _shift); +} +#endif diff --git a/Indicators/Indi_StdDev.mqh b/Indicators/Indi_StdDev.mqh index 53078a1e4..f62d96fa8 100644 --- a/Indicators/Indi_StdDev.mqh +++ b/Indicators/Indi_StdDev.mqh @@ -33,22 +33,6 @@ #include "Indi_PriceFeeder.mqh" #include "Price/Indi_MA.h" -#ifndef __MQL4__ -// Forward declaration. -class Indi_StdDev; - -// Defines global functions (for MQL4 backward compability). -double iStdDev(string _symbol, int _tf, int _ma_period, int _ma_shift, int _ma_method, int _ap, int _shift) { - ResetLastError(); - return Indi_StdDev::iStdDev(_symbol, (ENUM_TIMEFRAMES)_tf, _ma_period, _ma_shift, (ENUM_MA_METHOD)_ma_method, - (ENUM_APPLIED_PRICE)_ap, _shift); -} -double iStdDevOnArray(double &_arr[], int _total, int _ma_period, int _ma_shift, int _ma_method, int _abs_shift) { - ResetLastError(); - return Indi_StdDev::iStdDevOnArray(_arr, _total, _ma_period, _ma_shift, (ENUM_MA_METHOD)_ma_method, _abs_shift); -} -#endif - // Structs. struct IndiStdDevParams : IndicatorParams { int ma_period; @@ -332,3 +316,16 @@ class Indi_StdDev : public Indicator { iparams.applied_price = _applied_price; } }; + +#ifndef __MQL4__ +// Defines global functions (for MQL4 backward compability). +double iStdDev(string _symbol, int _tf, int _ma_period, int _ma_shift, int _ma_method, int _ap, int _shift) { + ResetLastError(); + return Indi_StdDev::iStdDev(_symbol, (ENUM_TIMEFRAMES)_tf, _ma_period, _ma_shift, (ENUM_MA_METHOD)_ma_method, + (ENUM_APPLIED_PRICE)_ap, _shift); +} +double iStdDevOnArray(double &_arr[], int _total, int _ma_period, int _ma_shift, int _ma_method, int _abs_shift) { + ResetLastError(); + return Indi_StdDev::iStdDevOnArray(_arr, _total, _ma_period, _ma_shift, (ENUM_MA_METHOD)_ma_method, _abs_shift); +} +#endif diff --git a/Indicators/Oscillator/Indi_MACD.h b/Indicators/Oscillator/Indi_MACD.h index bdf3a2992..b50ea0736 100644 --- a/Indicators/Oscillator/Indi_MACD.h +++ b/Indicators/Oscillator/Indi_MACD.h @@ -23,18 +23,6 @@ // Includes. #include "../../Indicator/Indicator.h" -#ifndef __MQL4__ -// Forward declaration. -class Indi_MACD; - -// Defines global functions (for MQL4 backward compability). -double iMACD(string _symbol, int _tf, int _ema_fp, int _ema_sp, int _signal_period, int _ap, int _mode, int _shift) { - ResetLastError(); - return Indi_MACD::iMACD(_symbol, (ENUM_TIMEFRAMES)_tf, _ema_fp, _ema_sp, _signal_period, (ENUM_APPLIED_PRICE)_ap, - (ENUM_SIGNAL_LINE)_mode, _shift); -} -#endif - // Structs. struct IndiMACDParams : IndicatorParams { unsigned int ema_fast_period; @@ -214,3 +202,12 @@ class Indi_MACD : public Indicator { iparams.applied_price = _applied_price; } }; + +#ifndef __MQL4__ +// Defines global functions (for MQL4 backward compability). +double iMACD(string _symbol, int _tf, int _ema_fp, int _ema_sp, int _signal_period, int _ap, int _mode, int _shift) { + ResetLastError(); + return Indi_MACD::iMACD(_symbol, (ENUM_TIMEFRAMES)_tf, _ema_fp, _ema_sp, _signal_period, (ENUM_APPLIED_PRICE)_ap, + (ENUM_SIGNAL_LINE)_mode, _shift); +} +#endif diff --git a/Indicators/Oscillator/Indi_Stochastic.h b/Indicators/Oscillator/Indi_Stochastic.h index d8eb72b4c..b1e2add7f 100644 --- a/Indicators/Oscillator/Indi_Stochastic.h +++ b/Indicators/Oscillator/Indi_Stochastic.h @@ -33,19 +33,6 @@ enum ENUM_STO_PRICE { }; #endif -#ifndef __MQL4__ -// Forward declaration. -class Indi_Stochastic; - -// Defines global functions (for MQL4 backward compability). -double iStochastic(string _symbol, int _tf, int _kperiod, int _dperiod, int _slowing, int _ma_method, int _pf, - int _mode, int _shift) { - ResetLastError(); - return Indi_Stochastic::iStochastic(_symbol, (ENUM_TIMEFRAMES)_tf, _kperiod, _dperiod, _slowing, - (ENUM_MA_METHOD)_ma_method, (ENUM_STO_PRICE)_pf, _mode, _shift); -} -#endif - // Structs. struct IndiStochParams : IndicatorParams { int kperiod; @@ -222,3 +209,13 @@ class Indi_Stochastic : public Indicator { iparams.price_field = _price_field; } }; + +#ifndef __MQL4__ +// Defines global functions (for MQL4 backward compability). +double iStochastic(string _symbol, int _tf, int _kperiod, int _dperiod, int _slowing, int _ma_method, int _pf, + int _mode, int _shift) { + ResetLastError(); + return Indi_Stochastic::iStochastic(_symbol, (ENUM_TIMEFRAMES)_tf, _kperiod, _dperiod, _slowing, + (ENUM_MA_METHOD)_ma_method, (ENUM_STO_PRICE)_pf, _mode, _shift); +} +#endif diff --git a/Indicators/Oscillator/Indi_WPR.h b/Indicators/Oscillator/Indi_WPR.h index 7240eaa12..41498c5c7 100644 --- a/Indicators/Oscillator/Indi_WPR.h +++ b/Indicators/Oscillator/Indi_WPR.h @@ -24,17 +24,6 @@ #include "../../Indicator/Indicator.h" #include "../../Platform/Terminal.h" -#ifndef __MQL4__ -// Forward declaration. -class Indi_WPR; - -// Defines global functions (for MQL4 backward compability). -double iWPR(string _symbol, int _tf, int _period, int _shift) { - ResetLastError(); - return Indi_WPR::iWPR(_symbol, (ENUM_TIMEFRAMES)_tf, _period, _shift); -} -#endif - // Structs. struct IndiWPRParams : IndicatorParams { unsigned int period; @@ -162,3 +151,11 @@ class Indi_WPR : public Indicator { iparams.period = _period; } }; + +#ifndef __MQL4__ +// Defines global functions (for MQL4 backward compability). +double iWPR(string _symbol, int _tf, int _period, int _shift) { + ResetLastError(); + return Indi_WPR::iWPR(_symbol, (ENUM_TIMEFRAMES)_tf, _period, _shift); +} +#endif diff --git a/Indicators/Price/Indi_MA.h b/Indicators/Price/Indi_MA.h index ad744a073..de095993f 100644 --- a/Indicators/Price/Indi_MA.h +++ b/Indicators/Price/Indi_MA.h @@ -44,23 +44,6 @@ enum ENUM_MA_METHOD { }; #endif -#ifndef __MQL4__ -// Forward declaration. -class Indi_MA; - -// Defines global functions (for MQL4 backward compability). -double iMA(string _symbol, int _tf, int _ma_period, int _ma_shift, int _ma_method, int _ap, int _shift) { - ResetLastError(); - return Indi_MA::iMA(_symbol, (ENUM_TIMEFRAMES)_tf, _ma_period, _ma_shift, (ENUM_MA_METHOD)_ma_method, - (ENUM_APPLIED_PRICE)_ap, _shift); -} -double iMAOnArray(ARRAY_REF(double, _arr), int _total, int _period, int _ma_shift, int _ma_method, int _abs_shift, - IndiBufferCache *_cache = NULL) { - ResetLastError(); - return Indi_MA::iMAOnArray(_arr, _total, _period, _ma_shift, _ma_method, _abs_shift, _cache); -} -#endif - // Structs. struct IndiMAParams : IndicatorParams { unsigned int period; @@ -803,4 +786,19 @@ class Indi_MA : public Indicator { iparams.applied_array = _applied_price; } }; + +#ifndef __MQL4__ +// Defines global functions (for MQL4 backward compability). +double iMA(string _symbol, int _tf, int _ma_period, int _ma_shift, int _ma_method, int _ap, int _shift) { + ResetLastError(); + return Indi_MA::iMA(_symbol, (ENUM_TIMEFRAMES)_tf, _ma_period, _ma_shift, (ENUM_MA_METHOD)_ma_method, + (ENUM_APPLIED_PRICE)_ap, _shift); +} +double iMAOnArray(ARRAY_REF(double, _arr), int _total, int _period, int _ma_shift, int _ma_method, int _abs_shift, + IndiBufferCache *_cache = NULL) { + ResetLastError(); + return Indi_MA::iMAOnArray(_arr, _total, _period, _ma_shift, _ma_method, _abs_shift, _cache); +} +#endif + #endif // INDI_MA_H diff --git a/Indicators/PriceMulti/Indi_Alligator.h b/Indicators/PriceMulti/Indi_Alligator.h index a70b4d727..426cbcf70 100644 --- a/Indicators/PriceMulti/Indi_Alligator.h +++ b/Indicators/PriceMulti/Indi_Alligator.h @@ -24,20 +24,6 @@ #include "../../Indicator/Indicator.h" #include "../Price/Indi_MA.h" -#ifndef __MQL4__ -// Forward declaration. -class Indi_Alligator; - -// Defines global functions (for MQL4 backward compability). -double iAlligator(string _symbol, int _tf, int _jp, int _js, int _tp, int _ts, int _lp, int _ls, int _ma_method, - int _ap, int _mode, int _shift) { - ResetLastError(); - return Indi_Alligator::iAlligator(_symbol, (ENUM_TIMEFRAMES)_tf, _jp, _js, _tp, _ts, _lp, _ls, - (ENUM_MA_METHOD)_ma_method, (ENUM_APPLIED_PRICE)_ap, (ENUM_ALLIGATOR_LINE)_mode, - _shift); -} -#endif - #ifndef __MQLBUILD__ // Defines. // Indicator constants. @@ -308,3 +294,14 @@ class Indi_Alligator : public Indicator { iparams.applied_price = _applied_price; } }; + +#ifndef __MQL4__ +// Defines global functions (for MQL4 backward compability). +double iAlligator(string _symbol, int _tf, int _jp, int _js, int _tp, int _ts, int _lp, int _ls, int _ma_method, + int _ap, int _mode, int _shift) { + ResetLastError(); + return Indi_Alligator::iAlligator(_symbol, (ENUM_TIMEFRAMES)_tf, _jp, _js, _tp, _ts, _lp, _ls, + (ENUM_MA_METHOD)_ma_method, (ENUM_APPLIED_PRICE)_ap, (ENUM_ALLIGATOR_LINE)_mode, + _shift); +} +#endif diff --git a/Indicators/PriceRange/Indi_Bands.h b/Indicators/PriceRange/Indi_Bands.h index caf00ed0f..75965bf4a 100644 --- a/Indicators/PriceRange/Indi_Bands.h +++ b/Indicators/PriceRange/Indi_Bands.h @@ -30,19 +30,6 @@ #include "../Price/Indi_Price.h" #include "Indi_Envelopes.h" -#ifndef __MQL4__ -// Forward declaration. -class Indi_Bands; - -// Defines global functions (for MQL4 backward compability). -double iBands(string _symbol, int _tf, int _period, double _deviation, int _bands_shift, int _ap, int _mode, - int _shift) { - ResetLastError(); - return Indi_Bands::iBands(_symbol, (ENUM_TIMEFRAMES)_tf, _period, _deviation, _bands_shift, (ENUM_APPLIED_PRICE)_ap, - (ENUM_BANDS_LINE)_mode, _shift); -} -#endif - // Indicator line identifiers used in Bands. enum ENUM_BANDS_LINE { #ifdef __MQL4__ @@ -392,3 +379,13 @@ class Indi_Bands : public Indicator { iparams.applied_price = _applied_price; } }; + +#ifndef __MQL4__ +// Defines global functions (for MQL4 backward compability). +double iBands(string _symbol, int _tf, int _period, double _deviation, int _bands_shift, int _ap, int _mode, + int _shift) { + ResetLastError(); + return Indi_Bands::iBands(_symbol, (ENUM_TIMEFRAMES)_tf, _period, _deviation, _bands_shift, (ENUM_APPLIED_PRICE)_ap, + (ENUM_BANDS_LINE)_mode, _shift); +} +#endif diff --git a/Indicators/PriceRange/Indi_Envelopes.h b/Indicators/PriceRange/Indi_Envelopes.h index 8a16962ea..eb039e3e2 100644 --- a/Indicators/PriceRange/Indi_Envelopes.h +++ b/Indicators/PriceRange/Indi_Envelopes.h @@ -27,25 +27,6 @@ #include "../Price/Indi_MA.h" #include "../Price/Indi_Price.h" -#ifndef __MQL4__ -// Forward declaration. -class Indi_Envelopes; - -// Defines global functions (for MQL4 backward compability). -double iEnvelopes(string _symbol, int _tf, int _period, int _ma_method, int _ma_shift, int _ap, double _deviation, - int _mode, int _shift) { - ResetLastError(); - return Indi_Envelopes::iEnvelopes(_symbol, (ENUM_TIMEFRAMES)_tf, _period, (ENUM_MA_METHOD)_ma_method, _ma_shift, - (ENUM_APPLIED_PRICE)_ap, _deviation, _mode, _shift); -} -double iEnvelopesOnArray(double &_arr[], int _total, int _ma_period, int _ma_method, int _ma_shift, double _deviation, - int _mode, int _shift) { - ResetLastError(); - return Indi_Envelopes::iEnvelopesOnArray(_arr, _total, _ma_period, (ENUM_MA_METHOD)_ma_method, _ma_shift, _deviation, - _mode, _shift); -} -#endif - // Structs. struct IndiEnvelopesParams : IndicatorParams { int ma_period; @@ -334,3 +315,19 @@ class Indi_Envelopes : public Indicator { iparams.deviation = _deviation; } }; + +#ifndef __MQL4__ +// Defines global functions (for MQL4 backward compability). +double iEnvelopes(string _symbol, int _tf, int _period, int _ma_method, int _ma_shift, int _ap, double _deviation, + int _mode, int _shift) { + ResetLastError(); + return Indi_Envelopes::iEnvelopes(_symbol, (ENUM_TIMEFRAMES)_tf, _period, (ENUM_MA_METHOD)_ma_method, _ma_shift, + (ENUM_APPLIED_PRICE)_ap, _deviation, _mode, _shift); +} +double iEnvelopesOnArray(double &_arr[], int _total, int _ma_period, int _ma_method, int _ma_shift, double _deviation, + int _mode, int _shift) { + ResetLastError(); + return Indi_Envelopes::iEnvelopesOnArray(_arr, _total, _ma_period, (ENUM_MA_METHOD)_ma_method, _ma_shift, _deviation, + _mode, _shift); +} +#endif diff --git a/Indicators/PriceRange/Indi_SAR.h b/Indicators/PriceRange/Indi_SAR.h index 910ed7e3d..8f12916b3 100644 --- a/Indicators/PriceRange/Indi_SAR.h +++ b/Indicators/PriceRange/Indi_SAR.h @@ -23,17 +23,6 @@ // Includes. #include "../../Indicator/Indicator.h" -#ifndef __MQL4__ -// Forward declaration. -class Indi_SAR; - -// Defines global functions (for MQL4 backward compability). -double iSAR(string _symbol, int _tf, double _step, double _max, int _shift) { - ResetLastError(); - return Indi_SAR::iSAR(_symbol, (ENUM_TIMEFRAMES)_tf, _step, _max, _shift); -} -#endif - // Structs. struct IndiSARParams : IndicatorParams { double step; @@ -147,3 +136,11 @@ class Indi_SAR : public Indicator { iparams.max = _max; } }; + +#ifndef __MQL4__ +// Defines global functions (for MQL4 backward compability). +double iSAR(string _symbol, int _tf, double _step, double _max, int _shift) { + ResetLastError(); + return Indi_SAR::iSAR(_symbol, (ENUM_TIMEFRAMES)_tf, _step, _max, _shift); +} +#endif From 4a1b3d6ae555852bbd238daf6ba163b77f30e654 Mon Sep 17 00:00:00 2001 From: kenorb Date: Thu, 22 Jun 2023 23:30:04 +0100 Subject: [PATCH 17/26] Adds PriceRange/tests/Makefile --- Indicators/PriceRange/tests/Makefile | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Indicators/PriceRange/tests/Makefile diff --git a/Indicators/PriceRange/tests/Makefile b/Indicators/PriceRange/tests/Makefile new file mode 100644 index 000000000..e792364f0 --- /dev/null +++ b/Indicators/PriceRange/tests/Makefile @@ -0,0 +1,12 @@ +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 + +all: $(OBJS) + +%.o: %.cpp + $(CC) $(CFLAGS) -c $< -o $@ + +clean: + rm -v $(OBJS) From 8cacb42e1029cf357f384d6790c225f304310995 Mon Sep 17 00:00:00 2001 From: Adrian Kierzkowski Date: Thu, 29 Jun 2023 19:16:36 +0200 Subject: [PATCH 18/26] WIP. Fixing C++ errors. Stuck on ValueStorage's macros. --- Indicators/Indi_ADX.mqh | 5 ++ Indicators/Indi_ADXW.mqh | 22 +++--- Indicators/Indi_CCI.mqh | 12 +-- Indicators/Indi_Momentum.mqh | 8 +- Indicators/Indi_PriceFeeder.mqh | 18 +++-- Indicators/Indi_StdDev.mqh | 22 +++--- Indicators/Price/Indi_AppliedPrice.h | 4 +- Indicators/Price/Indi_MA.h | 24 +++--- Indicators/Price/Indi_Price.h | 5 ++ Indicators/PriceRange/Indi_Bands.h | 35 +++++---- Indicators/PriceRange/Indi_Envelopes.h | 25 +++--- Indicators/PriceRange/Indi_Pivot.h | 8 +- Indicators/Special/Indi_Custom.mqh | 4 +- Math/Math.extern.h | 4 + Pattern.struct.h | 56 +++++++++++++- Platform/Order.struct.h | 6 +- Std.h | 16 +++- Storage/Array.extern.h | 4 +- Storage/Cache/IndiBufferCache.h | 19 +++-- Storage/Cache/ObjectsCache.h | 8 +- Storage/ValueStorage.h | 103 +++++++++++++++++++------ Storage/ValueStorage.native.h | 4 +- Storage/ValueStorage.spread.h | 5 ++ Storage/ValueStorage.tick_volume.h | 5 ++ Storage/ValueStorage.time.h | 5 ++ Storage/ValueStorage.volume.h | 5 ++ 26 files changed, 303 insertions(+), 129 deletions(-) diff --git a/Indicators/Indi_ADX.mqh b/Indicators/Indi_ADX.mqh index 2d0a81e4a..4c5ddf08f 100644 --- a/Indicators/Indi_ADX.mqh +++ b/Indicators/Indi_ADX.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Indicator/Indicator.h" #include "Price/Indi_Price.h" diff --git a/Indicators/Indi_ADXW.mqh b/Indicators/Indi_ADXW.mqh index 5f37980dc..01ca8329c 100644 --- a/Indicators/Indi_ADXW.mqh +++ b/Indicators/Indi_ADXW.mqh @@ -132,25 +132,27 @@ class Indi_ADXW : public Indicator { */ static double iADXWilderOnArray(INDICATOR_CALCULATE_PARAMS_LONG, int _period, int _mode, int _abs_shift, IndiBufferCache *_cache, bool _recalculate = false) { - _cache.SetPriceBuffer(_open, _high, _low, _close); + _cache PTR_DEREF SetPriceBuffer(_open, _high, _low, _close); - if (!_cache.HasBuffers()) { - _cache.AddBuffer>(3 + 7); + if (!_cache PTR_DEREF HasBuffers()) { + _cache PTR_DEREF AddBuffer>(3 + 7); } if (_recalculate) { - _cache.ResetPrevCalculated(); + _cache PTR_DEREF ResetPrevCalculated(); } - _cache.SetPrevCalculated(Indi_ADXW::Calculate( - INDICATOR_CALCULATE_GET_PARAMS_LONG, _cache.GetBuffer(0), _cache.GetBuffer(1), - _cache.GetBuffer(2), _cache.GetBuffer(3), _cache.GetBuffer(4), - _cache.GetBuffer(5), _cache.GetBuffer(6), _cache.GetBuffer(7), - _cache.GetBuffer(8), _cache.GetBuffer(9), _period)); + _cache PTR_DEREF SetPrevCalculated( + Indi_ADXW::Calculate(INDICATOR_CALCULATE_GET_PARAMS_LONG, _cache PTR_DEREF GetBuffer(0), + _cache PTR_DEREF GetBuffer(1), _cache PTR_DEREF GetBuffer(2), + _cache PTR_DEREF GetBuffer(3), _cache PTR_DEREF GetBuffer(4), + _cache PTR_DEREF GetBuffer(5), _cache PTR_DEREF GetBuffer(6), + _cache PTR_DEREF GetBuffer(7), _cache PTR_DEREF GetBuffer(8), + _cache PTR_DEREF GetBuffer(9), _period)); // Returns value from the first calculation buffer. // Returns first value for as-series array or last value for non-as-series array. - return _cache.GetTailValue(_mode, _abs_shift); + return _cache PTR_DEREF GetTailValue(_mode, _abs_shift); } /** diff --git a/Indicators/Indi_CCI.mqh b/Indicators/Indi_CCI.mqh index fa69935b2..418a229f4 100644 --- a/Indicators/Indi_CCI.mqh +++ b/Indicators/Indi_CCI.mqh @@ -98,10 +98,10 @@ class Indi_CCI : public Indicator { int _mode, int _shift = 0) { INDI_REQUIRE_BARS_OR_RETURN_EMPTY(_indi, _period); - _indi.ValidateDataSourceMode(_mode); + _indi PTR_DEREF ValidateDataSourceMode(_mode); - double _indi_value_buffer[]; - IndicatorDataEntry _entry(_indi.GetModeCount()); + ARRAY(double, _indi_value_buffer); + IndicatorDataEntry _entry(_indi PTR_DEREF GetModeCount()); ArrayResize(_indi_value_buffer, _period); @@ -136,12 +136,12 @@ class Indi_CCI : public Indicator { /** * CCI on array. */ - static double iCCIOnArray(double &array[], int total, int period, int shift) { + static double iCCIOnArray(CONST_ARRAY_REF(double, array), int total, int period, int shift) { #ifdef __MQL4__ return ::iCCIOnArray(array, total, period, shift); #else Indi_PriceFeeder indi_price_feeder(array); - return iCCIOnIndicator(&indi_price_feeder, NULL, NULL, period, /*unused*/ PRICE_OPEN, shift); + return iCCIOnIndicator(&indi_price_feeder, NULL, PERIOD_CURRENT, period, /*unused*/ PRICE_OPEN, shift); #endif } @@ -224,7 +224,7 @@ double iCCI(string _symbol, int _tf, int _period, int _ap, int _shift) { ResetLastError(); return Indi_CCI::iCCI(_symbol, (ENUM_TIMEFRAMES)_tf, _period, (ENUM_APPLIED_PRICE)_ap, _shift); } -double iCCIOnArray(double &_arr[], int _total, int _period, int _abs_shift) { +double iCCIOnArray(CONST_ARRAY_REF(double, _arr), int _total, int _period, int _abs_shift) { ResetLastError(); return Indi_CCI::iCCIOnArray(_arr, _total, _period, _abs_shift); } diff --git a/Indicators/Indi_Momentum.mqh b/Indicators/Indi_Momentum.mqh index f10cb04be..d23b4b57d 100644 --- a/Indicators/Indi_Momentum.mqh +++ b/Indicators/Indi_Momentum.mqh @@ -106,8 +106,8 @@ class Indi_Momentum : public Indicator { int _mode, int _shift = 0) { INDI_REQUIRE_BARS_OR_RETURN_EMPTY(_indi, _period); - double _indi_value_buffer[]; - IndicatorDataEntry _entry(_indi.GetModeCount()); + ARRAY(double, _indi_value_buffer); + IndicatorDataEntry _entry(_indi PTR_DEREF GetModeCount()); ArrayResize(_indi_value_buffer, _period); @@ -122,12 +122,12 @@ class Indi_Momentum : public Indicator { return momentum; } - static double iMomentumOnArray(double &array[], int total, int period, int shift) { + static double iMomentumOnArray(CONST_ARRAY_REF(double, array), int total, int period, int shift) { #ifdef __MQL4__ return ::iMomentumOnArray(array, total, period, shift); #else Indi_PriceFeeder indi_price_feeder(array); - return iMomentumOnIndicator(&indi_price_feeder, NULL, NULL, period, /*unused*/ PRICE_OPEN, shift); + return iMomentumOnIndicator(&indi_price_feeder, NULL, PERIOD_CURRENT, period, /*unused*/ PRICE_OPEN, shift); #endif } diff --git a/Indicators/Indi_PriceFeeder.mqh b/Indicators/Indi_PriceFeeder.mqh index aa6f683b0..481f8654c 100644 --- a/Indicators/Indi_PriceFeeder.mqh +++ b/Indicators/Indi_PriceFeeder.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Indicator/Indicator.h" #include "../Storage/Dict/Buffer/BufferStruct.h" @@ -27,7 +32,7 @@ // Structs. struct IndiPriceFeederParams : IndicatorParams { ENUM_APPLIED_PRICE applied_price; - double price_data[]; + ARRAY(double, price_data); /** * Struct constructor. @@ -39,7 +44,7 @@ struct IndiPriceFeederParams : IndicatorParams { * * @todo Use more modes (full OHCL). */ - IndiPriceFeederParams(const double& _price_data[], int _total = 0) : IndicatorParams(INDI_PRICE_FEEDER) { + IndiPriceFeederParams(CONST_ARRAY_REF(double, _price_data), int _total = 0) : IndicatorParams(INDI_PRICE_FEEDER) { ArrayCopy(price_data, _price_data, 0, 0, _total == 0 ? WHOLE_ARRAY : _total); }; IndiPriceFeederParams(IndiPriceFeederParams& _params) { THIS_REF = _params; }; @@ -57,8 +62,9 @@ class Indi_PriceFeeder : public Indicator { IndicatorData* _indi_src = NULL, int _indi_src_mode = 0) : Indicator(_p, IndicatorDataParams::GetInstance(1, TYPE_DOUBLE, _idstype, IDATA_RANGE_PRICE, _indi_src_mode), _indi_src){}; - Indi_PriceFeeder(const double& _price_data[], int _total = 0, ENUM_IDATA_SOURCE_TYPE _idstype = IDATA_BUILTIN, - IndicatorData* _indi_src = NULL, int _indi_src_mode = 0) + Indi_PriceFeeder(CONST_ARRAY_REF(double, _price_data), int _total = 0, + ENUM_IDATA_SOURCE_TYPE _idstype = IDATA_BUILTIN, IndicatorData* _indi_src = NULL, + int _indi_src_mode = 0) : Indicator(IndiPriceFeederParams(), IndicatorDataParams::GetInstance(1, TYPE_DOUBLE, _idstype, IDATA_RANGE_PRICE, _indi_src_mode), _indi_src) {} @@ -78,7 +84,9 @@ class Indi_PriceFeeder : public Indicator { */ unsigned int GetPossibleDataModes() override { return IDATA_BUILTIN; } - void SetPrices(const double& _price_data[], int _total = 0) { iparams = IndiPriceFeederParams(_price_data, _total); } + void SetPrices(CONST_ARRAY_REF(double, _price_data), int _total = 0) { + iparams = IndiPriceFeederParams(_price_data, _total); + } /** * Checks whether indicator has a valid value for a given shift. diff --git a/Indicators/Indi_StdDev.mqh b/Indicators/Indi_StdDev.mqh index f62d96fa8..5ba32d176 100644 --- a/Indicators/Indi_StdDev.mqh +++ b/Indicators/Indi_StdDev.mqh @@ -115,7 +115,7 @@ class Indi_StdDev : public Indicator { Indi_StdDev *_obj = NULL) { INDI_REQUIRE_BARS_OR_RETURN_EMPTY(_source, _ma_period + _ma_shift + _shift) - double _indi_value_buffer[]; + ARRAY(double, _indi_value_buffer); double _std_dev; int i; @@ -137,16 +137,17 @@ class Indi_StdDev : public Indicator { return _std_dev; } - static double iStdDevOnArray(const double &price[], double MAprice, int period) { + static double iStdDevOnArray(CONST_ARRAY_REF(double, price), double MAprice, int period) { double std_dev = 0; int i; - for (i = 0; i < period; ++i) std_dev += MathPow(price[i] - MAprice, 2); + for (i = 0; i < period; ++i) std_dev += MathPow(price[i] - MAprice, (double)2); return MathSqrt(std_dev / period); } - static double iStdDevOnArray(double &array[], int total, int ma_period, int ma_shift, int ma_method, int shift) { + static double iStdDevOnArray(ARRAY_REF(double, array), int total, int ma_period, int ma_shift, + ENUM_MA_METHOD ma_method, int shift) { #ifdef __MQL4__ return ::iStdDevOnArray(array, total, ma_period, ma_shift, ma_method, shift); #endif @@ -189,17 +190,17 @@ class Indi_StdDev : public Indicator { /** * Standard Deviation On Array is just a normal standard deviation over MA with a selected method. */ - static double iStdDevOnArray(const double &price[], int period, ENUM_MA_METHOD ma_method = MODE_SMA) { + static double iStdDevOnArray(CONST_ARRAY_REF(double, price), int period, ENUM_MA_METHOD ma_method = MODE_SMA) { string _key = "Indi_PriceFeeder"; Indi_PriceFeeder *_indi_price_feeder; if (!ObjectsCache::TryGet(_key, _indi_price_feeder)) { - IndiPriceFeederParams _params(); - IndicatorData *_indi_pf = new Indi_PriceFeeder(_params); + IndiPriceFeederParams _params; + Indi_PriceFeeder *_indi_pf = new Indi_PriceFeeder(_params); _indi_price_feeder = ObjectsCache::Set(_key, _indi_pf); } // Filling reused price feeder. - _indi_price_feeder.SetPrices(price); + _indi_price_feeder PTR_DEREF SetPrices(price); IndiMAParams ma_params(period, 0, ma_method, PRICE_OPEN); @@ -214,7 +215,7 @@ class Indi_StdDev : public Indicator { return _result; */ - Print(__FUNCTION__ + " must be refactored!"); + Print(string(__FUNCTION__) + " must be refactored!"); DebugBreak(); return 0; } @@ -324,7 +325,8 @@ double iStdDev(string _symbol, int _tf, int _ma_period, int _ma_shift, int _ma_m return Indi_StdDev::iStdDev(_symbol, (ENUM_TIMEFRAMES)_tf, _ma_period, _ma_shift, (ENUM_MA_METHOD)_ma_method, (ENUM_APPLIED_PRICE)_ap, _shift); } -double iStdDevOnArray(double &_arr[], int _total, int _ma_period, int _ma_shift, int _ma_method, int _abs_shift) { +double iStdDevOnArray(ARRAY_REF(double, _arr), int _total, int _ma_period, int _ma_shift, int _ma_method, + int _abs_shift) { ResetLastError(); return Indi_StdDev::iStdDevOnArray(_arr, _total, _ma_period, _ma_shift, (ENUM_MA_METHOD)_ma_method, _abs_shift); } diff --git a/Indicators/Price/Indi_AppliedPrice.h b/Indicators/Price/Indi_AppliedPrice.h index 834ea938f..df5249d28 100644 --- a/Indicators/Price/Indi_AppliedPrice.h +++ b/Indicators/Price/Indi_AppliedPrice.h @@ -79,8 +79,8 @@ class Indi_AppliedPrice : public Indicator { unsigned int GetPossibleDataModes() override { return IDATA_INDICATOR; } static double iAppliedPriceOnIndicator(IndicatorData *_indi, ENUM_APPLIED_PRICE _applied_price, int _shift = 0) { - double _ohlc[4]; - _indi[_shift].GetArray(_ohlc, 4); + ARRAY(double, _ohlc); + PTR_TO_REF(_indi)[_shift].GetArray(_ohlc, 4); return BarOHLC::GetAppliedPrice(_applied_price, _ohlc[0], _ohlc[1], _ohlc[2], _ohlc[3]); } diff --git a/Indicators/Price/Indi_MA.h b/Indicators/Price/Indi_MA.h index de095993f..9a41ecf8a 100644 --- a/Indicators/Price/Indi_MA.h +++ b/Indicators/Price/Indi_MA.h @@ -149,8 +149,8 @@ class Indi_MA : public Indicator { /** * Calculates MA on the array of values. Cache is optional. */ - static double iMAOnArray(ARRAY_REF(double, price), int total, int ma_period, int ma_shift, int ma_method, int shift, - IndiBufferCache *cache = NULL) { + static double iMAOnArray(ARRAY_REF(double, price), int total, int ma_period, int ma_shift, ENUM_MA_METHOD ma_method, + int shift, IndiBufferCache *cache = NULL) { #ifdef __MQL4__ return ::iMAOnArray(price, total, ma_period, ma_shift, ma_method, shift); #else @@ -166,8 +166,9 @@ class Indi_MA : public Indicator { /** * Calculates MA on the array of values. */ - static double iMAOnArray(ValueStorage &price, int total, int ma_period, int ma_shift, int ma_method, - int shift, IndiBufferCache *_cache = NULL, bool recalculate = false) { + static double iMAOnArray(ValueStorage &price, int total, int ma_period, int ma_shift, + ENUM_MA_METHOD ma_method, int shift, IndiBufferCache *_cache = NULL, + bool recalculate = false) { if (_cache != NULL) { _cache PTR_DEREF SetPriceBuffer(price); @@ -179,9 +180,8 @@ class Indi_MA : public Indicator { _cache PTR_DEREF ResetPrevCalculated(); } - _cache PTR_DEREF SetPrevCalculated(Indi_MA::Calculate(INDICATOR_CALCULATE_GET_PARAMS_SHORT, - PTR_TO_REF(_cache PTR_DEREF GetBuffer(0)), - ma_method, ma_period)); + _cache PTR_DEREF SetPrevCalculated(Indi_MA::Calculate( + INDICATOR_CALCULATE_GET_PARAMS_SHORT, _cache PTR_DEREF GetBuffer(0), ma_method, ma_period)); // Returns value from the first calculation buffer. // Returns first value for as-series array or last value for non-as-series array. @@ -789,13 +789,13 @@ class Indi_MA : public Indicator { #ifndef __MQL4__ // Defines global functions (for MQL4 backward compability). -double iMA(string _symbol, int _tf, int _ma_period, int _ma_shift, int _ma_method, int _ap, int _shift) { +double iMA(string _symbol, int _tf, int _ma_period, int _ma_shift, ENUM_MA_METHOD _ma_method, int _ap, int _shift) { ResetLastError(); - return Indi_MA::iMA(_symbol, (ENUM_TIMEFRAMES)_tf, _ma_period, _ma_shift, (ENUM_MA_METHOD)_ma_method, - (ENUM_APPLIED_PRICE)_ap, _shift); + return Indi_MA::iMA(_symbol, (ENUM_TIMEFRAMES)_tf, _ma_period, _ma_shift, _ma_method, (ENUM_APPLIED_PRICE)_ap, + _shift); } -double iMAOnArray(ARRAY_REF(double, _arr), int _total, int _period, int _ma_shift, int _ma_method, int _abs_shift, - IndiBufferCache *_cache = NULL) { +double iMAOnArray(ARRAY_REF(double, _arr), int _total, int _period, int _ma_shift, ENUM_MA_METHOD _ma_method, + int _abs_shift, IndiBufferCache *_cache = NULL) { ResetLastError(); return Indi_MA::iMAOnArray(_arr, _total, _period, _ma_shift, _ma_method, _abs_shift, _cache); } diff --git a/Indicators/Price/Indi_Price.h b/Indicators/Price/Indi_Price.h index 35db3ed59..0e2c1d67f 100644 --- a/Indicators/Price/Indi_Price.h +++ b/Indicators/Price/Indi_Price.h @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../../Indicator/Indicator.h" #include "../../Platform/Platform.h" diff --git a/Indicators/PriceRange/Indi_Bands.h b/Indicators/PriceRange/Indi_Bands.h index 75965bf4a..6b9612347 100644 --- a/Indicators/PriceRange/Indi_Bands.h +++ b/Indicators/PriceRange/Indi_Bands.h @@ -153,21 +153,22 @@ class Indi_Bands : public Indicator { static double iBandsOnArray(INDICATOR_CALCULATE_PARAMS_SHORT, int _period, double _deviation, int _bands_shift, int _mode, int _abs_shift, IndiBufferCache *_cache, bool _recalculate = false) { - _cache.SetPriceBuffer(_price); + _cache PTR_DEREF SetPriceBuffer(_price); - if (!_cache.HasBuffers()) { - _cache.AddBuffer>(4); + if (!_cache PTR_DEREF HasBuffers()) { + _cache PTR_DEREF AddBuffer>(4); } if (_recalculate) { - _cache.ResetPrevCalculated(); + _cache PTR_DEREF ResetPrevCalculated(); } - _cache.SetPrevCalculated(Indi_Bands::Calculate(INDICATOR_CALCULATE_GET_PARAMS_SHORT, _cache.GetBuffer(0), - _cache.GetBuffer(1), _cache.GetBuffer(2), - _cache.GetBuffer(3), _period, _bands_shift, _deviation)); + _cache PTR_DEREF SetPrevCalculated( + Indi_Bands::Calculate(INDICATOR_CALCULATE_GET_PARAMS_SHORT, _cache PTR_DEREF GetBuffer(0), + _cache PTR_DEREF GetBuffer(1), _cache PTR_DEREF GetBuffer(2), + _cache PTR_DEREF GetBuffer(3), _period, _bands_shift, _deviation)); - return _cache.GetTailValue(_mode, _abs_shift); + return _cache PTR_DEREF GetTailValue(_mode, _abs_shift); } /** @@ -293,30 +294,30 @@ class Indi_Bands : public Indicator { virtual IndicatorData *FetchDataSource(ENUM_INDICATOR_TYPE _id) { IndicatorData *_result = NULL; if (_id == INDI_BANDS) { - IndiBandsParams bands_params(); - _result = Indi_Bands(bands_params); + IndiBandsParams bands_params; + _result = new Indi_Bands(bands_params); } else if (_id == INDI_CCI) { - IndiCCIParams cci_params(); + IndiCCIParams cci_params; _result = new Indi_CCI(cci_params); } else if (_id == INDI_ENVELOPES) { - IndiEnvelopesParams env_params(); + IndiEnvelopesParams env_params; _result = new Indi_Envelopes(env_params); } else if (_id == INDI_MOMENTUM) { - IndiMomentumParams mom_params(); + IndiMomentumParams mom_params; _result = new Indi_Momentum(mom_params); } else if (_id == INDI_MA) { - IndiMAParams ma_params(); + IndiMAParams ma_params; _result = new Indi_MA(ma_params); } else if (_id == INDI_RSI) { - IndiRSIParams _rsi_params(); + IndiRSIParams _rsi_params; _result = new Indi_RSI(_rsi_params); } else if (_id == INDI_STDDEV) { - IndiStdDevParams stddev_params(); + IndiStdDevParams stddev_params; _result = new Indi_StdDev(stddev_params); } if (_result != nullptr) { - _result.SetDataSource(GetCandle()); + _result PTR_DEREF SetDataSource(GetCandle()); return _result; } diff --git a/Indicators/PriceRange/Indi_Envelopes.h b/Indicators/PriceRange/Indi_Envelopes.h index eb039e3e2..197fce0aa 100644 --- a/Indicators/PriceRange/Indi_Envelopes.h +++ b/Indicators/PriceRange/Indi_Envelopes.h @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../../Indicator/Indicator.h" #include "../../Storage/Singleton.h" @@ -142,18 +147,19 @@ class Indi_Envelopes : public Indicator { int _mode, // (MT4 _mode): 0 - MODE_MAIN, 1 - MODE_UPPER, 2 - MODE_LOWER; (MT5 // _mode): 0 - UPPER_LINE, 1 - LOWER_LINE int _shift = 0) { - return iEnvelopesOnArray(_source.GetSpecificAppliedPriceValueStorage(_ap, _target), 0, _ma_period, _ma_method, - _ma_shift, _deviation, _mode, _shift, _target PTR_DEREF GetCache()); + return iEnvelopesOnArray(_source PTR_DEREF GetSpecificAppliedPriceValueStorage(_ap, _target), 0, _ma_period, + _ma_method, _ma_shift, _deviation, _mode, _shift, _target PTR_DEREF GetCache()); } - static double iEnvelopesOnArray(double &price[], int total, int ma_period, ENUM_MA_METHOD ma_method, int ma_shift, - double deviation, int mode, int shift, IndiBufferCache *_cache = NULL) { + static double iEnvelopesOnArray(CONST_ARRAY_REF(double, price), int total, int ma_period, ENUM_MA_METHOD ma_method, + int ma_shift, double deviation, int mode, int shift, + IndiBufferCache *_cache = NULL) { #ifdef __MQL4__ return iEnvelopesOnArray(price, total, ma_period, ma_method, ma_shift, deviation, mode, shift); #else // We're reusing the same native array for each consecutive calculation. NativeValueStorage *_price = Singleton >::Get(); - _price.SetData(price); + _price PTR_DEREF SetData(price); return iEnvelopesOnArray(_price, total, ma_period, ma_method, ma_shift, deviation, mode, shift); #endif @@ -167,13 +173,14 @@ class Indi_Envelopes : public Indicator { return DBL_MIN; } - double _indi_value_buffer[]; + ARRAY(double, _indi_value_buffer); double _result; ArrayResize(_indi_value_buffer, _ma_period); // MA will use sub-cache of the given one. - _result = Indi_MA::iMAOnArray(_price, 0, _ma_period, _ma_shift, _ma_method, _shift, _cache.GetSubCache(0)); + _result = Indi_MA::iMAOnArray(PTR_TO_REF(_price), 0, _ma_period, _ma_shift, _ma_method, _shift, + _cache PTR_DEREF GetSubCache(0)); switch (_mode) { case LINE_UPPER: @@ -324,8 +331,8 @@ double iEnvelopes(string _symbol, int _tf, int _period, int _ma_method, int _ma_ return Indi_Envelopes::iEnvelopes(_symbol, (ENUM_TIMEFRAMES)_tf, _period, (ENUM_MA_METHOD)_ma_method, _ma_shift, (ENUM_APPLIED_PRICE)_ap, _deviation, _mode, _shift); } -double iEnvelopesOnArray(double &_arr[], int _total, int _ma_period, int _ma_method, int _ma_shift, double _deviation, - int _mode, int _shift) { +double iEnvelopesOnArray(CONST_ARRAY_REF(double, _arr), int _total, int _ma_period, int _ma_method, int _ma_shift, + double _deviation, int _mode, int _shift) { ResetLastError(); return Indi_Envelopes::iEnvelopesOnArray(_arr, _total, _ma_period, (ENUM_MA_METHOD)_ma_method, _ma_shift, _deviation, _mode, _shift); diff --git a/Indicators/PriceRange/Indi_Pivot.h b/Indicators/PriceRange/Indi_Pivot.h index f19c7fa4a..427fd5382 100644 --- a/Indicators/PriceRange/Indi_Pivot.h +++ b/Indicators/PriceRange/Indi_Pivot.h @@ -157,10 +157,10 @@ class Indi_Pivot : public Indicator { // must have at least 4 buffers and define OHLC in the first 4 buffers. // Indi_Price is an example of such indicator. if (HasDataSource()) { - _ohlc.open = GetDataSource().GetValue(PRICE_OPEN, _shift); - _ohlc.high = GetDataSource().GetValue(PRICE_HIGH, _shift); - _ohlc.low = GetDataSource().GetValue(PRICE_LOW, _shift); - _ohlc.close = GetDataSource().GetValue(PRICE_CLOSE, _shift); + _ohlc.open = GetDataSource() PTR_DEREF GetValue(PRICE_OPEN, _shift); + _ohlc.high = GetDataSource() PTR_DEREF GetValue(PRICE_HIGH, _shift); + _ohlc.low = GetDataSource() PTR_DEREF GetValue(PRICE_LOW, _shift); + _ohlc.close = GetDataSource() PTR_DEREF GetValue(PRICE_CLOSE, _shift); } break; default: diff --git a/Indicators/Special/Indi_Custom.mqh b/Indicators/Special/Indi_Custom.mqh index c12f5390a..4d8984f44 100644 --- a/Indicators/Special/Indi_Custom.mqh +++ b/Indicators/Special/Indi_Custom.mqh @@ -40,7 +40,7 @@ // Defines struct to store indicator parameter values. struct IndiCustomParams : public IndicatorParams { - DataParamEntry iargs[]; + ARRAY(DataParamEntry, iargs); // Struct constructors. IndiCustomParams(string _filepath = INDI_CUSTOM_PATH, int _shift = 0) : IndicatorParams(INDI_CUSTOM) { custom_indi_name = _filepath; @@ -61,7 +61,7 @@ struct IndiCustomParams : public IndicatorParams { } iargs[_index + 1] = _entry; } - void SetParams(DataParamEntry &_entries[]) { + void SetParams(CONST_ARRAY_REF(DataParamEntry, _entries)) { for (int i = 0; i < ArraySize(_entries); i++) { iargs[i] = _entries[i]; } diff --git a/Math/Math.extern.h b/Math/Math.extern.h index cfe6d3b32..da468d94e 100644 --- a/Math/Math.extern.h +++ b/Math/Math.extern.h @@ -44,6 +44,10 @@ T MathPow(T base, T exponent) { return std::pow(base, exponent); } template +T MathSqrt(T value) { + return std::sqrt(value); +} +template T round(T value) { return std::round(value); } diff --git a/Pattern.struct.h b/Pattern.struct.h index b304263cb..97c756d28 100644 --- a/Pattern.struct.h +++ b/Pattern.struct.h @@ -302,6 +302,12 @@ struct PatternCandle2 : PatternCandle { SetPattern(_enum, CheckPattern(_enum, _c)); } } + PatternCandle2(CONST_FIXED_ARRAY_REF(BarOHLC, _c, 8)) : PatternCandle(PATTERN_2CANDLE_NONE) { + for (int i = 0; i < sizeof(int) * 8; i++) { + ENUM_PATTERN_2CANDLE _enum = (ENUM_PATTERN_2CANDLE)(1 << i); + SetPattern(_enum, CheckPattern(_enum, _c)); + } + } // Calculation methods. static bool CheckPattern(ENUM_PATTERN_2CANDLE _enum, CONST_ARRAY_REF(BarOHLC, _c)) { switch (_enum) { @@ -411,6 +417,12 @@ struct PatternCandle3 : PatternCandle { SetPattern(_enum, CheckPattern(_enum, _c)); } } + PatternCandle3(CONST_FIXED_ARRAY_REF(BarOHLC, _c, 8)) : PatternCandle(PATTERN_3CANDLE_NONE) { + for (int i = 0; i < sizeof(int) * 8; i++) { + ENUM_PATTERN_3CANDLE _enum = (ENUM_PATTERN_3CANDLE)(1 << i); + SetPattern(_enum, CheckPattern(_enum, _c)); + } + } // Calculation methods. static bool CheckPattern(ENUM_PATTERN_3CANDLE _enum, CONST_ARRAY_REF(BarOHLC, _c)) { switch (_enum) { @@ -527,6 +539,12 @@ struct PatternCandle4 : PatternCandle { SetPattern(_enum, CheckPattern(_enum, _c)); } } + PatternCandle4(CONST_FIXED_ARRAY_REF(BarOHLC, _c, 8)) : PatternCandle(PATTERN_4CANDLE_NONE) { + for (int i = 0; i < sizeof(int) * 8; i++) { + ENUM_PATTERN_4CANDLE _enum = (ENUM_PATTERN_4CANDLE)(1 << i); + SetPattern(_enum, CheckPattern(_enum, _c)); + } + } // Calculation methods. static bool CheckPattern(ENUM_PATTERN_4CANDLE _enum, CONST_ARRAY_REF(BarOHLC, _c)) { PatternCandle3 _c3(_c); @@ -693,6 +711,12 @@ struct PatternCandle5 : PatternCandle { SetPattern(_enum, CheckPattern(_enum, _c)); } } + PatternCandle5(CONST_FIXED_ARRAY_REF(BarOHLC, _c, 8)) : PatternCandle(PATTERN_5CANDLE_NONE) { + for (int i = 0; i < sizeof(int) * 8; i++) { + ENUM_PATTERN_5CANDLE _enum = (ENUM_PATTERN_5CANDLE)(1 << i); + SetPattern(_enum, CheckPattern(_enum, _c)); + } + } // Calculation methods. static bool CheckPattern(ENUM_PATTERN_5CANDLE _enum, CONST_ARRAY_REF(BarOHLC, _c)) { switch (_enum) { @@ -844,6 +868,12 @@ struct PatternCandle6 : PatternCandle { SetPattern(_enum, CheckPattern(_enum, _c)); } } + PatternCandle6(CONST_FIXED_ARRAY_REF(BarOHLC, _c, 8)) : PatternCandle(PATTERN_6CANDLE_NONE) { + for (int i = 0; i < sizeof(int) * 8; i++) { + ENUM_PATTERN_6CANDLE _enum = (ENUM_PATTERN_6CANDLE)(1 << i); + SetPattern(_enum, CheckPattern(_enum, _c)); + } + } // Calculation methods. static bool CheckPattern(ENUM_PATTERN_6CANDLE _enum, CONST_ARRAY_REF(BarOHLC, _c)) { switch (_enum) { @@ -863,6 +893,12 @@ struct PatternCandle7 : PatternCandle { SetPattern(_enum, CheckPattern(_enum, _c)); } } + PatternCandle7(CONST_FIXED_ARRAY_REF(BarOHLC, _c, 8)) : PatternCandle(PATTERN_7CANDLE_NONE) { + for (int i = 0; i < sizeof(int) * 8; i++) { + ENUM_PATTERN_7CANDLE _enum = (ENUM_PATTERN_7CANDLE)(1 << i); + SetPattern(_enum, CheckPattern(_enum, _c)); + } + } // Calculation methods. static bool CheckPattern(ENUM_PATTERN_7CANDLE _enum, CONST_ARRAY_REF(BarOHLC, _c)) { switch (_enum) { @@ -882,6 +918,12 @@ struct PatternCandle8 : PatternCandle { SetPattern(_enum, CheckPattern(_enum, _c)); } } + PatternCandle8(CONST_FIXED_ARRAY_REF(BarOHLC, _c, 8)) : PatternCandle(PATTERN_8CANDLE_NONE) { + for (int i = 0; i < sizeof(int) * 8; i++) { + ENUM_PATTERN_8CANDLE _enum = (ENUM_PATTERN_8CANDLE)(1 << i); + SetPattern(_enum, CheckPattern(_enum, _c)); + } + } // Calculation methods. static bool CheckPattern(ENUM_PATTERN_8CANDLE _enum, CONST_ARRAY_REF(BarOHLC, _c)) { switch (_enum) { @@ -901,6 +943,12 @@ struct PatternCandle9 : PatternCandle { SetPattern(_enum, CheckPattern(_enum, _c)); } } + PatternCandle9(CONST_FIXED_ARRAY_REF(BarOHLC, _c, 8)) : PatternCandle(PATTERN_9CANDLE_NONE) { + for (int i = 0; i < sizeof(int) * 8; i++) { + ENUM_PATTERN_9CANDLE _enum = (ENUM_PATTERN_9CANDLE)(1 << i); + SetPattern(_enum, CheckPattern(_enum, _c)); + } + } // Calculation methods. static bool CheckPattern(ENUM_PATTERN_9CANDLE _enum, CONST_ARRAY_REF(BarOHLC, _c)) { switch (_enum) { @@ -920,6 +968,12 @@ struct PatternCandle10 : PatternCandle { SetPattern(_enum, CheckPattern(_enum, _c)); } } + PatternCandle10(CONST_FIXED_ARRAY_REF(BarOHLC, _c, 8)) : PatternCandle(PATTERN_10CANDLE_NONE) { + for (int i = 0; i < sizeof(int) * 8; i++) { + ENUM_PATTERN_10CANDLE _enum = (ENUM_PATTERN_10CANDLE)(1 << i); + SetPattern(_enum, CheckPattern(_enum, _c)); + } + } // Calculation methods. static bool CheckPattern(ENUM_PATTERN_10CANDLE _enum, CONST_ARRAY_REF(BarOHLC, _c)) { switch (_enum) { @@ -965,7 +1019,7 @@ struct PatternEntry { pattern8(_c), pattern9(_c), pattern10(_c) {} - PatternEntry(ARRAY_REF(BarOHLC, _c)) + PatternEntry(FIXED_ARRAY_REF(BarOHLC, _c, 8)) : pattern1(_c[0]), pattern2(_c), pattern3(_c), diff --git a/Platform/Order.struct.h b/Platform/Order.struct.h index be4d53b2b..a1773c1bb 100644 --- a/Platform/Order.struct.h +++ b/Platform/Order.struct.h @@ -31,11 +31,11 @@ #endif // Includes. +#include "../Exchange/SymbolInfo/SymbolInfo.struct.static.h" +#include "../Serializer/Serializer.h" #include "../Storage/Data.struct.h" #include "Order.enum.h" #include "Platform.extern.h" -#include "../Serializer/Serializer.h" -#include "../Exchange/SymbolInfo/SymbolInfo.struct.static.h" #include "Terminal.h" #ifndef __MQL5__ @@ -130,7 +130,7 @@ struct OrderParams { bool _result = true; int _size = ArraySize(_cond_close); if (_size <= _index) { - _result &= ArrayResize(_cond_close, _size + 1); + _result &= ArrayResize(_cond_close, _size + 1) == _size + 1; } return _result; } diff --git a/Std.h b/Std.h index 5a0813afc..181592c58 100644 --- a/Std.h +++ b/Std.h @@ -56,6 +56,7 @@ #define PTR_ATTRIB(O, A) O.A #define PTR_ATTRIB2(O, A, B) O.A.B #define PTR_TO_REF(PTR) PTR +#define REF_TO_PTR(PTR) PTR #define MAKE_REF_FROM_PTR(TYPE, NAME, PTR) TYPE* NAME = PTR #define nullptr NULL #define REF_DEREF .Ptr(). @@ -69,6 +70,7 @@ #define PTR_ATTRIB(O, A) O->A #define PTR_ATTRIB2(O, A, B) O->A->B #define PTR_TO_REF(PTR) (*PTR) +#define REF_TO_PTR(PTR) (&PTR) #define MAKE_REF_FROM_PTR(TYPE, NAME, PTR) TYPE& NAME = PTR #define REF_DEREF .Ptr()-> #define int64 long long @@ -95,7 +97,10 @@ /** * Reference to object. */ -#define CONST_REF_TO(T) const T + +#define REF_TO(T) T* +#define CONST_REF_TO(T) const REF_TO(T) +#define REF_CAST(T) (T*) /** * Reference to the array. @@ -118,11 +123,15 @@ #define ARRAY(T, N) T N[] #define FIXED_ARRAY(T, N, SIZE) T N[SIZE] +#define CONST_FIXED_ARRAY_REF(T, N, S) const FIXED_ARRAY_REF(T, N, S) + #else /** * Reference to object. */ -#define CONST_REF_TO(T) const T& +#define REF_TO(T) T& +#define CONST_REF_TO(T) const REF_TO(T) +#define REF_CAST(T) (T&) /** @@ -136,6 +145,7 @@ #define FIXED_ARRAY_REF(T, N, S) T(&N)[S] #define CONST_ARRAY_REF(T, N) const _cpp_array& N +#define CONST_FIXED_ARRAY_REF(T, N, S) const FIXED_ARRAY_REF(T, N, S) /** * Array definition. @@ -169,7 +179,7 @@ class _cpp_array { _cpp_array() {} template - _cpp_array(const T REF(_arr)[size]) { + _cpp_array(CONST_FIXED_ARRAY_REF(T, _arr, size)) { for (const auto& _item : _arr) m_data.push_back(_item); } diff --git a/Storage/Array.extern.h b/Storage/Array.extern.h index 6d546c059..976004818 100644 --- a/Storage/Array.extern.h +++ b/Storage/Array.extern.h @@ -34,7 +34,7 @@ int ArraySize(const ARRAY_REF(T, _array)) { } template -constexpr int ArraySize(const T REF(_array)[size]) { +constexpr int ArraySize(CONST_FIXED_ARRAY_REF(T, _array, size)) { return size; } @@ -51,7 +51,7 @@ bool ArraySetAsSeries(ARRAY_REF(T, _array), bool _flag) { } template -bool ArrayGetAsSeries(ARRAY_REF(T, _array)) { +bool ArrayGetAsSeries(CONST_ARRAY_REF(T, _array)) { return _array.getIsSeries(); } diff --git a/Storage/Cache/IndiBufferCache.h b/Storage/Cache/IndiBufferCache.h index 99831d74c..09cad345a 100644 --- a/Storage/Cache/IndiBufferCache.h +++ b/Storage/Cache/IndiBufferCache.h @@ -102,7 +102,9 @@ class IndiBufferCache : public Dynamic { /** * Returns size of the current price buffer. */ - int GetTotal() { return price_buffer != NULL ? ArraySize(price_buffer) : ArraySize(price_open_buffer); } + int GetTotal() { + return price_buffer != NULL ? ArraySize(PTR_TO_REF(price_buffer)) : ArraySize(PTR_TO_REF(price_open_buffer)); + } /** * Returns number of already calculated prices (bars). @@ -154,19 +156,20 @@ class IndiBufferCache : public Dynamic { * Returns given calculation buffer. */ template - ValueStorage *GetBuffer(int _index) { - return (ValueStorage *)buffers[_index]; + REF_TO(ValueStorage) + GetBuffer(int _index) { + return PTR_TO_REF((ValueStorage *)buffers[_index]); } /** * Returns main price buffer. */ - ValueStorage *GetPriceBuffer() { return price_buffer; } + REF_TO(ValueStorage) GetPriceBuffer() { return PTR_TO_REF(price_buffer); } /** * Returns given price buffer. */ - ValueStorage *GetPriceBuffer(ENUM_APPLIED_PRICE _applied_price) { + REF_TO(ValueStorage) GetPriceBuffer(ENUM_APPLIED_PRICE _applied_price) { switch (_applied_price) { case PRICE_OPEN: return price_open_buffer; @@ -242,9 +245,9 @@ class IndiBufferCache : public Dynamic { */ template D GetTailValue(int _buffer_index, int _shift) { - ValueStorage *_buff = GetBuffer(_buffer_index); - int _index = _buff PTR_DEREF IsSeries() ? _shift : (ArraySize(_buff) - _shift - 1); - return _buff[_index] PTR_DEREF Get(); + ValueStorage *_buff = REF_TO_PTR(GetBuffer(_buffer_index)); + int _index = _buff PTR_DEREF IsSeries() ? _shift : (ArraySize(PTR_TO_REF(_buff)) - _shift - 1); + return PTR_TO_REF(_buff)[_index].Get(); } /** diff --git a/Storage/Cache/ObjectsCache.h b/Storage/Cache/ObjectsCache.h index 05f1ce2eb..dc43c872a 100644 --- a/Storage/Cache/ObjectsCache.h +++ b/Storage/Cache/ObjectsCache.h @@ -64,12 +64,12 @@ class ObjectsCache { * Tries to retrieve pointer to object for a given key. Returns true if object did exist. */ static bool TryGet(string& key, C*& out_ptr) { - int position; - if (!GetObjects().KeyExists(key, position)) { + unsigned int position; + if (!GetObjects() PTR_DEREF KeyExists(key, position)) { out_ptr = NULL; return false; } else { - out_ptr = GetObjects().GetByPos(position); + out_ptr = GetObjects() PTR_DEREF GetByPos(position); return true; } } @@ -78,7 +78,7 @@ class ObjectsCache { * Stores object pointer with a given key. */ static C* Set(string& key, C* ptr) { - GetObjects().Set(key, ptr); + GetObjects() PTR_DEREF Set(key, ptr); return ptr; } }; diff --git a/Storage/ValueStorage.h b/Storage/ValueStorage.h index aff953856..ab43f81e5 100644 --- a/Storage/ValueStorage.h +++ b/Storage/ValueStorage.h @@ -60,13 +60,14 @@ enum ENUM_IPEAK { IPEAK_LOWEST, IPEAK_HIGHEST }; #define INDICATOR_CALCULATE_METHOD_PARAMS_SHORT \ const int rates_total, const int prev_calculated, const int begin, ValueStorage &price -#define INDICATOR_CALCULATE_GET_PARAMS_LONG \ - _cache.GetTotal(), _cache.GetPrevCalculated(), _time, _cache.GetPriceBuffer(PRICE_OPEN), \ - _cache.GetPriceBuffer(PRICE_HIGH), _cache.GetPriceBuffer(PRICE_LOW), _cache.GetPriceBuffer(PRICE_CLOSE), \ - _tick_volume, _volume, _spread +#define INDICATOR_CALCULATE_GET_PARAMS_LONG \ + _cache PTR_DEREF GetTotal(), _cache PTR_DEREF GetPrevCalculated(), _time, \ + _cache PTR_DEREF GetPriceBuffer(PRICE_OPEN), _cache PTR_DEREF GetPriceBuffer(PRICE_HIGH), \ + _cache PTR_DEREF GetPriceBuffer(PRICE_LOW), _cache PTR_DEREF GetPriceBuffer(PRICE_CLOSE), _tick_volume, _volume, \ + _spread #define INDICATOR_CALCULATE_GET_PARAMS_SHORT \ - _cache PTR_DEREF GetTotal(), _cache PTR_DEREF GetPrevCalculated(), 0, PTR_TO_REF(_cache PTR_DEREF GetPriceBuffer()) + _cache PTR_DEREF GetTotal(), _cache PTR_DEREF GetPrevCalculated(), 0, _cache PTR_DEREF GetPriceBuffer() #define INDICATOR_CALCULATE_POPULATE_CACHE(INDI, KEY) \ IndiBufferCache *_cache; \ @@ -82,9 +83,9 @@ enum ENUM_IPEAK { IPEAK_LOWEST, IPEAK_HIGHEST }; * (the one that doesn't exist in the hierarchy). */ #define INDICATOR_CALCULATE_POPULATE_PARAMS_AND_CACHE_SHORT(INDI, APPLIED_PRICE, KEY) \ - ValueStorage *_price; \ + ValueStorage *_price_ptr; \ if (INDI PTR_DEREF GetSuitableDataSource() PTR_DEREF HasSpecificAppliedPriceValueStorage(APPLIED_PRICE, INDI)) { \ - _price = \ + _price_ptr = \ INDI PTR_DEREF GetSuitableDataSource() PTR_DEREF GetSpecificAppliedPriceValueStorage(APPLIED_PRICE, INDI); \ } else { \ Print("Source indicator ", INDI PTR_DEREF GetFullName(), \ @@ -94,26 +95,32 @@ enum ENUM_IPEAK { IPEAK_LOWEST, IPEAK_HIGHEST }; ", AP overriden: ", EnumToString(INDI PTR_DEREF GetDataSourceAppliedType())); \ DebugBreak(); \ } \ + REF_TO(ValueStorage) _price = PTR_TO_REF(_price_ptr); \ INDICATOR_CALCULATE_POPULATE_CACHE(INDI, KEY) -#define INDICATOR_CALCULATE_POPULATE_PARAMS_AND_CACHE_LONG(INDI, KEY) \ - IndicatorData *_suitable_ds = INDI PTR_DEREF GetSuitableDataSource(); \ - ValueStorage *_time = \ - (ValueStorage *)_suitable_ds PTR_DEREF GetSpecificValueStorage(INDI_DATA_VS_TYPE_TIME); \ - ValueStorage *_tick_volume = \ - (ValueStorage *)_suitable_ds PTR_DEREF GetSpecificValueStorage(INDI_DATA_VS_TYPE_TICK_VOLUME); \ - ValueStorage *_volume = \ - (ValueStorage *)_suitable_ds PTR_DEREF GetSpecificValueStorage(INDI_DATA_VS_TYPE_VOLUME); \ - ValueStorage *_spread = \ - (ValueStorage *)_suitable_ds PTR_DEREF GetSpecificValueStorage(INDI_DATA_VS_TYPE_SPREAD); \ - ValueStorage *_price_open = \ - (ValueStorage *)_suitable_ds PTR_DEREF GetSpecificValueStorage(INDI_DATA_VS_TYPE_PRICE_OPEN); \ - ValueStorage *_price_high = \ - (ValueStorage *)_suitable_ds PTR_DEREF GetSpecificValueStorage(INDI_DATA_VS_TYPE_PRICE_HIGH); \ - ValueStorage *_price_low = \ - (ValueStorage *)_suitable_ds PTR_DEREF GetSpecificValueStorage(INDI_DATA_VS_TYPE_PRICE_LOW); \ - ValueStorage *_price_close = \ - (ValueStorage *)_suitable_ds PTR_DEREF GetSpecificValueStorage(INDI_DATA_VS_TYPE_PRICE_CLOSE); \ +#define INDICATOR_CALCULATE_POPULATE_PARAMS_AND_CACHE_LONG(INDI, KEY) \ + IndicatorData *_suitable_ds = INDI PTR_DEREF GetSuitableDataSource(); \ + ValueStorage &_time = \ + (ValueStorage &)(_suitable_ds PTR_DEREF GetSpecificValueStorage(INDI_DATA_VS_TYPE_TIME)); \ + REF_TO(ValueStorage) \ + _tick_volume = \ + REF_CAST(ValueStorage)(_suitable_ds PTR_DEREF GetSpecificValueStorage(INDI_DATA_VS_TYPE_TICK_VOLUME)); \ + REF_TO(ValueStorage) \ + _volume = REF_CAST(ValueStorage)(_suitable_ds PTR_DEREF GetSpecificValueStorage(INDI_DATA_VS_TYPE_VOLUME)); \ + REF_TO(ValueStorage) \ + _spread = REF_CAST(ValueStorage)(_suitable_ds PTR_DEREF GetSpecificValueStorage(INDI_DATA_VS_TYPE_SPREAD)); \ + REF_TO(ValueStorage) \ + _price_open = \ + REF_CAST(ValueStorage)(_suitable_ds PTR_DEREF GetSpecificValueStorage(INDI_DATA_VS_TYPE_PRICE_OPEN)); \ + REF_TO(ValueStorage) \ + _price_high = \ + REF_CAST(ValueStorage)(_suitable_ds PTR_DEREF GetSpecificValueStorage(INDI_DATA_VS_TYPE_PRICE_HIGH)); \ + REF_TO(ValueStorage) \ + _price_low = \ + REF_CAST(ValueStorage)(_suitable_ds PTR_DEREF GetSpecificValueStorage(INDI_DATA_VS_TYPE_PRICE_LOW)); \ + REF_TO(ValueStorage) \ + _price_close = \ + REF_CAST(ValueStorage)(_suitable_ds PTR_DEREF GetSpecificValueStorage(INDI_DATA_VS_TYPE_PRICE_CLOSE)); \ INDICATOR_CALCULATE_POPULATE_CACHE(INDI, KEY) #define INDICATOR_CALCULATE_POPULATED_PARAMS_LONG \ @@ -254,6 +261,52 @@ int ArrayCopy(ARRAY_REF(D, _target), ValueStorage &_source, int _dst_start = return _num_copied; } +/** + * Array-Array wrapper for ArrayCopy. + * @note It's a copy-past of the above ArrayCopy. + */ +template +int ArrayCopy(ARRAY_REF(C, _target), CONST_ARRAY_REF(C, _source), int _dst_start = 0, int _src_start = 0, + int count = WHOLE_ARRAY) { + if (count == WHOLE_ARRAY) { + count = ArraySize(_source); + } + + if (ArrayGetAsSeries(_target)) { + if ((ArraySize(_target) == 0 && _dst_start != 0) || + (ArraySize(_target) != 0 && ArraySize(_target) < _dst_start + count)) { + // The receiving array is declared as AS_SERIES, and it is of insufficient size. + SetUserError(ERR_SMALL_ASSERIES_ARRAY); + ArrayResize(_target, 0); + return 0; + } + } + + count = MathMin(count, ArraySize(_source) - _src_start); + + int _dst_required_size = _dst_start + count; + + if (ArraySize(_target) < _dst_required_size) { + ArrayResize(_target, _dst_required_size, 32); + } + + int _num_copied, t, s; + + for (_num_copied = 0, t = _dst_start, s = _src_start; _num_copied < count; ++_num_copied, ++t, ++s) { + if (s >= ArraySize(_source)) { + // No more data to copy. + break; + } + + bool _reverse = ArrayGetAsSeries(_target) != ArrayGetAsSeries(_source); + + int _source_idx = _reverse ? (ArraySize(_source) - s - 1 + _src_start) : s; + + _target[t] = _source[_source_idx]; + } + + return _num_copied; +} /** * iLowest() version working on ValueStorage. diff --git a/Storage/ValueStorage.native.h b/Storage/ValueStorage.native.h index 95f8e351c..048d82fcb 100644 --- a/Storage/ValueStorage.native.h +++ b/Storage/ValueStorage.native.h @@ -33,7 +33,7 @@ template class NativeValueStorage : public ValueStorage { // Dynamic native array. - C _values[]; + ARRAY(C, _values); public: /** @@ -49,7 +49,7 @@ class NativeValueStorage : public ValueStorage { /** * Initializes array with given one. */ - void SetData(ARRAY_REF(C, _arr)) { ArrayCopy(_values, _arr); } + void SetData(CONST_ARRAY_REF(C, _arr)) { ArrayCopy(_values, _arr); } /** * Initializes storage with given value. diff --git a/Storage/ValueStorage.spread.h b/Storage/ValueStorage.spread.h index dfab07af5..4b18fe614 100644 --- a/Storage/ValueStorage.spread.h +++ b/Storage/ValueStorage.spread.h @@ -24,6 +24,11 @@ * Spread getter version of ValueStorage. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "Cache/ObjectsCache.h" #include "ValueStorage.history.h" diff --git a/Storage/ValueStorage.tick_volume.h b/Storage/ValueStorage.tick_volume.h index 6c015ca7f..61e9845e4 100644 --- a/Storage/ValueStorage.tick_volume.h +++ b/Storage/ValueStorage.tick_volume.h @@ -24,6 +24,11 @@ * Tick volume getter version of ValueStorage. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "Cache/ObjectsCache.h" #include "ValueStorage.history.h" diff --git a/Storage/ValueStorage.time.h b/Storage/ValueStorage.time.h index b8670c40b..7756953fa 100644 --- a/Storage/ValueStorage.time.h +++ b/Storage/ValueStorage.time.h @@ -24,6 +24,11 @@ * Time getter version of ValueStorage. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Util.h" #include "Cache/ObjectsCache.h" diff --git a/Storage/ValueStorage.volume.h b/Storage/ValueStorage.volume.h index ee5f867b8..dc3d07690 100644 --- a/Storage/ValueStorage.volume.h +++ b/Storage/ValueStorage.volume.h @@ -24,6 +24,11 @@ * Volume getter version of ValueStorage. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "Cache/ObjectsCache.h" #include "ValueStorage.history.h" From 1296e80f97bf692ffb917e12a4f6f6b6a1a353ce Mon Sep 17 00:00:00 2001 From: Adrian Kierzkowski Date: Fri, 30 Jun 2023 20:13:52 +0200 Subject: [PATCH 19/26] WIP. Fixing C++ errors. Closer to the end. --- Indicators/Indi_AMA.mqh | 17 +++++---- Indicators/Indi_AO.mqh | 7 +++- Indicators/Indi_ASI.mqh | 17 +++++---- Indicators/Indi_ATR.mqh | 7 +++- Indicators/Indi_BWZT.mqh | 26 +++++++------ Indicators/Indi_CHO.mqh | 17 +++++---- Indicators/Indi_CHV.mqh | 17 +++++---- Indicators/Indi_ColorBars.mqh | 17 +++++---- Indicators/Indi_ColorCandlesDaily.mqh | 17 +++++---- Indicators/Indi_ColorLine.mqh | 17 +++++---- Indicators/Indi_CustomMovingAverage.mqh | 6 +++ Indicators/Indi_DEMA.mqh | 16 ++++---- Indicators/Indi_DetrendedPrice.mqh | 17 +++++---- Indicators/Indi_Drawer.mqh | 6 +-- Indicators/Indi_Force.mqh | 1 + Indicators/Indi_FractalAdaptiveMA.mqh | 14 +++---- Indicators/Indi_HeikenAshi.mqh | 17 +++++---- Indicators/Indi_MassIndex.mqh | 17 +++++---- Indicators/Indi_PriceChannel.mqh | 16 ++++---- Indicators/Indi_PriceVolumeTrend.mqh | 14 +++---- Indicators/Indi_RateOfChange.mqh | 14 +++---- Indicators/Indi_TEMA.mqh | 17 +++++---- Indicators/Indi_TRIX.mqh | 17 +++++---- Indicators/Indi_UltimateOscillator.mqh | 19 +++++----- Indicators/Indi_VIDYA.mqh | 15 ++++---- Indicators/Indi_VROC.mqh | 14 +++---- Indicators/Indi_Volumes.mqh | 15 ++++---- Indicators/Indi_WilliamsAD.mqh | 14 +++---- Indicators/Indi_ZigZag.mqh | 16 ++++---- Indicators/Indi_ZigZagColor.mqh | 18 ++++----- Math/Math.extern.h | 8 ++++ Platform/Platform.h | 38 +++++++++++++++++++ Platform/Terminal.define.h | 1 + Std.h | 4 +- Storage/Cache/IndiBufferCache.h | 10 ++--- Storage/ValueStorage.applied_price.h | 5 +++ Storage/ValueStorage.h | 49 +++++++++++++------------ Storage/ValueStorage.native.h | 5 +++ 38 files changed, 329 insertions(+), 233 deletions(-) diff --git a/Indicators/Indi_AMA.mqh b/Indicators/Indi_AMA.mqh index 38e9dda16..88bc711c6 100644 --- a/Indicators/Indi_AMA.mqh +++ b/Indicators/Indi_AMA.mqh @@ -122,20 +122,21 @@ class Indi_AMA : public Indicator { static double iAMAOnArray(INDICATOR_CALCULATE_PARAMS_SHORT, int _ama_period, int _fast_ema_period, int _slow_ema_period, int _ama_shift, int _mode, int _abs_shift, IndiBufferCache *_cache, bool _recalculate = false) { - _cache.SetPriceBuffer(_price); + _cache PTR_DEREF SetPriceBuffer(_price); - if (!_cache.HasBuffers()) { - _cache.AddBuffer>(1); + if (!_cache PTR_DEREF HasBuffers()) { + _cache PTR_DEREF AddBuffer>(1); } if (_recalculate) { - _cache.ResetPrevCalculated(); + _cache PTR_DEREF ResetPrevCalculated(); } - _cache.SetPrevCalculated(Indi_AMA::Calculate(INDICATOR_CALCULATE_GET_PARAMS_SHORT, _cache.GetBuffer(0), - _ama_period, _fast_ema_period, _slow_ema_period, _ama_shift)); + _cache PTR_DEREF SetPrevCalculated(Indi_AMA::Calculate(INDICATOR_CALCULATE_GET_PARAMS_SHORT, + _cache PTR_DEREF GetBuffer(0), _ama_period, + _fast_ema_period, _slow_ema_period, _ama_shift)); - return _cache.GetTailValue(_mode, _abs_shift); + return _cache PTR_DEREF GetTailValue(_mode, _abs_shift); } /** @@ -218,7 +219,7 @@ class Indi_AMA : public Indicator { // Calculate AMA. double prevAMA = ExtAMABuffer[i - 1].Get(); - ExtAMABuffer[i] = MathPow(currentSSC, 2) * (price[i] - prevAMA) + prevAMA; + ExtAMABuffer[i] = MathPow(currentSSC, 2.0) * (price[i] - prevAMA) + prevAMA; } // Return value of prev_calculated for next call. return (rates_total); diff --git a/Indicators/Indi_AO.mqh b/Indicators/Indi_AO.mqh index ecc2be6dc..b2bf9f1f6 100644 --- a/Indicators/Indi_AO.mqh +++ b/Indicators/Indi_AO.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Indicator/Indicator.h" @@ -133,7 +138,7 @@ class Indi_AO : public Indicator { if (!Objects::TryGet(_key, _ptr)) { _ptr = Objects::Set(_key, new Indi_AO()); // Assigning the same candle indicator for AO as in _indi. - _ptr.SetDataSource(_indi PTR_DEREF GetCandle()); + _ptr PTR_DEREF SetDataSource(_indi PTR_DEREF GetCandle()); } return _ptr; } diff --git a/Indicators/Indi_ASI.mqh b/Indicators/Indi_ASI.mqh index 0919c855d..8d73f734d 100644 --- a/Indicators/Indi_ASI.mqh +++ b/Indicators/Indi_ASI.mqh @@ -22,6 +22,7 @@ // Includes. #include "../Indicator/Indicator.h" +#include "../Platform/Platform.h" #include "../Storage/Dict/Buffer/BufferStruct.h" #include "../Storage/ValueStorage.all.h" @@ -116,20 +117,21 @@ class Indi_ASI : public Indicator { */ static double iASIOnArray(INDICATOR_CALCULATE_PARAMS_LONG, double _mpc, int _mode, int _abs_shift, IndiBufferCache *_cache, bool _recalculate = false) { - _cache.SetPriceBuffer(_open, _high, _low, _close); + _cache PTR_DEREF SetPriceBuffer(_open, _high, _low, _close); - if (!_cache.HasBuffers()) { - _cache.AddBuffer>(3); + if (!_cache PTR_DEREF HasBuffers()) { + _cache PTR_DEREF AddBuffer>(3); } if (_recalculate) { - _cache.ResetPrevCalculated(); + _cache PTR_DEREF ResetPrevCalculated(); } - _cache.SetPrevCalculated(Indi_ASI::Calculate(INDICATOR_CALCULATE_GET_PARAMS_LONG, _cache.GetBuffer(0), - _cache.GetBuffer(1), _cache.GetBuffer(2), _mpc)); + _cache PTR_DEREF SetPrevCalculated( + Indi_ASI::Calculate(INDICATOR_CALCULATE_GET_PARAMS_LONG, _cache PTR_DEREF GetBuffer(0), + _cache PTR_DEREF GetBuffer(1), _cache PTR_DEREF GetBuffer(2), _mpc)); - return _cache.GetTailValue(_mode, _abs_shift); + return _cache PTR_DEREF GetTailValue(_mode, _abs_shift); } /** @@ -143,6 +145,7 @@ class Indi_ASI : public Indicator { ExtT = 300.0; PrintFormat("Input parameter T has wrong value. Indicator will use T = %f.", ExtT); } + // Calculate ExtTpoints value. if (_Point > 1e-7) ExtTpoints = ExtT * _Point; diff --git a/Indicators/Indi_ATR.mqh b/Indicators/Indi_ATR.mqh index 73009cc0b..13dcfcd4c 100644 --- a/Indicators/Indi_ATR.mqh +++ b/Indicators/Indi_ATR.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Indicator/Indicator.h" @@ -117,7 +122,7 @@ class Indi_ATR : public Indicator { IndiATRParams _params(_period); _ptr = Objects::Set(_key, new Indi_ATR(_params)); // Assigning the same candle indicator for ATR as in _indi. - _ptr.SetDataSource(_indi PTR_DEREF GetCandle()); + _ptr PTR_DEREF SetDataSource(_indi PTR_DEREF GetCandle()); } return _ptr; } diff --git a/Indicators/Indi_BWZT.mqh b/Indicators/Indi_BWZT.mqh index 15c5dbf8d..0b20a06cb 100644 --- a/Indicators/Indi_BWZT.mqh +++ b/Indicators/Indi_BWZT.mqh @@ -141,22 +141,23 @@ class Indi_BWZT : public Indicator { static double iBWZTOnArray(INDICATOR_CALCULATE_PARAMS_LONG, int _mode, int _abs_shift, int _data_limit, IndiBufferCache *_cache, Indi_AC *_indi_ac, Indi_AO *_indi_ao, bool _recalculate = false) { - _cache.SetPriceBuffer(_open, _high, _low, _close); + _cache PTR_DEREF SetPriceBuffer(_open, _high, _low, _close); - if (!_cache.HasBuffers()) { - _cache.AddBuffer>(4 + 1 + 2); + if (!_cache PTR_DEREF HasBuffers()) { + _cache PTR_DEREF AddBuffer>(4 + 1 + 2); } if (_recalculate) { - _cache.ResetPrevCalculated(); + _cache PTR_DEREF ResetPrevCalculated(); } - _cache.SetPrevCalculated(Indi_BWZT::Calculate( - INDICATOR_CALCULATE_GET_PARAMS_LONG, _cache.GetBuffer(0), _cache.GetBuffer(1), - _cache.GetBuffer(2), _cache.GetBuffer(3), _cache.GetBuffer(4), - _cache.GetBuffer(5), _cache.GetBuffer(6), _data_limit, _indi_ac, _indi_ao)); + _cache PTR_DEREF SetPrevCalculated(Indi_BWZT::Calculate( + INDICATOR_CALCULATE_GET_PARAMS_LONG, _cache PTR_DEREF GetBuffer(0), + _cache PTR_DEREF GetBuffer(1), _cache PTR_DEREF GetBuffer(2), + _cache PTR_DEREF GetBuffer(3), _cache PTR_DEREF GetBuffer(4), + _cache PTR_DEREF GetBuffer(5), _cache PTR_DEREF GetBuffer(6), _data_limit, _indi_ac, _indi_ao)); - return _cache.GetTailValue(_mode, _abs_shift); + return _cache PTR_DEREF GetTailValue(_mode, _abs_shift); } /** @@ -165,10 +166,11 @@ class Indi_BWZT : public Indicator { static double iBWZTOnIndicator(IndicatorData *_indi, string _symbol, ENUM_TIMEFRAMES _tf, int _mode, int _rel_shift, int _data_limit, IndicatorData *_obj) { INDI_REQUIRE_BARS_OR_RETURN_EMPTY(_indi, _data_limit); - INDICATOR_CALCULATE_POPULATE_PARAMS_AND_CACHE_LONG(_indi, Util::MakeKey("Indi_BWZT_ON_" + _indi.GetFullName())); + INDICATOR_CALCULATE_POPULATE_PARAMS_AND_CACHE_LONG(_indi, + Util::MakeKey("Indi_BWZT_ON_" + _indi PTR_DEREF GetFullName())); - Indi_AC *_indi_ac = _obj.GetDataSource(INDI_AC); - Indi_AO *_indi_ao = _obj.GetDataSource(INDI_AO); + Indi_AC *_indi_ac = (Indi_AC *)_obj PTR_DEREF GetDataSource(INDI_AC); + Indi_AO *_indi_ao = (Indi_AO *)_obj PTR_DEREF GetDataSource(INDI_AO); return iBWZTOnArray(INDICATOR_CALCULATE_POPULATED_PARAMS_LONG, _mode, _indi PTR_DEREF ToAbsShift(_rel_shift), _data_limit, _cache, _indi_ac, _indi_ao); diff --git a/Indicators/Indi_CHO.mqh b/Indicators/Indi_CHO.mqh index 6fff098c3..16d7221b7 100644 --- a/Indicators/Indi_CHO.mqh +++ b/Indicators/Indi_CHO.mqh @@ -119,21 +119,22 @@ class Indi_CHO : public Indicator { static double iChaikinOnArray(INDICATOR_CALCULATE_PARAMS_LONG, int _fast_ma_period, int _slow_ma_period, ENUM_MA_METHOD _ma_method, ENUM_APPLIED_VOLUME _av, int _mode, int _abs_shift, IndiBufferCache *_cache, bool _recalculate = false) { - _cache.SetPriceBuffer(_open, _high, _low, _close); + _cache PTR_DEREF SetPriceBuffer(_open, _high, _low, _close); - if (!_cache.HasBuffers()) { - _cache.AddBuffer>(4); + if (!_cache PTR_DEREF HasBuffers()) { + _cache PTR_DEREF AddBuffer>(4); } if (_recalculate) { - _cache.ResetPrevCalculated(); + _cache PTR_DEREF ResetPrevCalculated(); } - _cache.SetPrevCalculated(Indi_CHO::Calculate( - INDICATOR_CALCULATE_GET_PARAMS_LONG, _cache.GetBuffer(0), _cache.GetBuffer(1), - _cache.GetBuffer(2), _cache.GetBuffer(3), _fast_ma_period, _slow_ma_period, _ma_method, _av)); + _cache PTR_DEREF SetPrevCalculated( + Indi_CHO::Calculate(INDICATOR_CALCULATE_GET_PARAMS_LONG, _cache PTR_DEREF GetBuffer(0), + _cache PTR_DEREF GetBuffer(1), _cache PTR_DEREF GetBuffer(2), + _cache PTR_DEREF GetBuffer(3), _fast_ma_period, _slow_ma_period, _ma_method, _av)); - return _cache.GetTailValue(_mode, _abs_shift); + return _cache PTR_DEREF GetTailValue(_mode, _abs_shift); } /** diff --git a/Indicators/Indi_CHV.mqh b/Indicators/Indi_CHV.mqh index bfcd1847f..3119985f0 100644 --- a/Indicators/Indi_CHV.mqh +++ b/Indicators/Indi_CHV.mqh @@ -108,23 +108,24 @@ class Indi_CHV : public Indicator { static double iCHVOnArray(INDICATOR_CALCULATE_PARAMS_LONG, int _smooth_period, int _chv_period, ENUM_CHV_SMOOTH_METHOD _smooth_method, int _mode, int _abs_shift, IndiBufferCache *_cache, bool _recalculate = false) { - _cache.SetPriceBuffer(_open, _high, _low, _close); + _cache PTR_DEREF SetPriceBuffer(_open, _high, _low, _close); - if (!_cache.HasBuffers()) { - _cache.AddBuffer>(3); + if (!_cache PTR_DEREF HasBuffers()) { + _cache PTR_DEREF AddBuffer>(3); } if (_recalculate) { - _cache.ResetPrevCalculated(); + _cache PTR_DEREF ResetPrevCalculated(); } - _cache.SetPrevCalculated(Indi_CHV::Calculate(INDICATOR_CALCULATE_GET_PARAMS_LONG, _cache.GetBuffer(0), - _cache.GetBuffer(1), _cache.GetBuffer(2), - _smooth_period, _chv_period, _smooth_method)); + _cache PTR_DEREF SetPrevCalculated( + Indi_CHV::Calculate(INDICATOR_CALCULATE_GET_PARAMS_LONG, _cache PTR_DEREF GetBuffer(0), + _cache PTR_DEREF GetBuffer(1), _cache PTR_DEREF GetBuffer(2), + _smooth_period, _chv_period, _smooth_method)); // Returns value from the first calculation buffer. // Returns first value for as-series array or last value for non-as-series array. - return _cache.GetTailValue(_mode, _abs_shift); + return _cache PTR_DEREF GetTailValue(_mode, _abs_shift); } /** diff --git a/Indicators/Indi_ColorBars.mqh b/Indicators/Indi_ColorBars.mqh index 6721eed7c..8ece4900b 100644 --- a/Indicators/Indi_ColorBars.mqh +++ b/Indicators/Indi_ColorBars.mqh @@ -78,21 +78,22 @@ class Indi_ColorBars : public Indicator { */ static double iColorBarsOnArray(INDICATOR_CALCULATE_PARAMS_LONG, int _mode, int _abs_shift, IndiBufferCache *_cache, bool _recalculate = false) { - _cache.SetPriceBuffer(_open, _high, _low, _close); + _cache PTR_DEREF SetPriceBuffer(_open, _high, _low, _close); - if (!_cache.HasBuffers()) { - _cache.AddBuffer>(4 + 1); + if (!_cache PTR_DEREF HasBuffers()) { + _cache PTR_DEREF AddBuffer>(4 + 1); } if (_recalculate) { - _cache.ResetPrevCalculated(); + _cache PTR_DEREF ResetPrevCalculated(); } - _cache.SetPrevCalculated(Indi_ColorBars::Calculate(INDICATOR_CALCULATE_GET_PARAMS_LONG, _cache.GetBuffer(0), - _cache.GetBuffer(1), _cache.GetBuffer(2), - _cache.GetBuffer(3), _cache.GetBuffer(4))); + _cache PTR_DEREF SetPrevCalculated( + Indi_ColorBars::Calculate(INDICATOR_CALCULATE_GET_PARAMS_LONG, _cache PTR_DEREF GetBuffer(0), + _cache PTR_DEREF GetBuffer(1), _cache PTR_DEREF GetBuffer(2), + _cache PTR_DEREF GetBuffer(3), _cache PTR_DEREF GetBuffer(4))); - return _cache.GetTailValue(_mode, _abs_shift); + return _cache PTR_DEREF GetTailValue(_mode, _abs_shift); } /** diff --git a/Indicators/Indi_ColorCandlesDaily.mqh b/Indicators/Indi_ColorCandlesDaily.mqh index 9c5f2a545..6041fbd82 100644 --- a/Indicators/Indi_ColorCandlesDaily.mqh +++ b/Indicators/Indi_ColorCandlesDaily.mqh @@ -91,21 +91,22 @@ class Indi_ColorCandlesDaily : public Indicator { */ static double iCCDOnArray(INDICATOR_CALCULATE_PARAMS_LONG, int _mode, int _abs_shift, IndiBufferCache *_cache, bool _recalculate = false) { - _cache.SetPriceBuffer(_open, _high, _low, _close); + _cache PTR_DEREF SetPriceBuffer(_open, _high, _low, _close); - if (!_cache.HasBuffers()) { - _cache.AddBuffer>(4 + 1); + if (!_cache PTR_DEREF HasBuffers()) { + _cache PTR_DEREF AddBuffer>(4 + 1); } if (_recalculate) { - _cache.ResetPrevCalculated(); + _cache PTR_DEREF ResetPrevCalculated(); } - _cache.SetPrevCalculated(Indi_ColorCandlesDaily::Calculate( - INDICATOR_CALCULATE_GET_PARAMS_LONG, _cache.GetBuffer(0), _cache.GetBuffer(1), - _cache.GetBuffer(2), _cache.GetBuffer(3), _cache.GetBuffer(4))); + _cache PTR_DEREF SetPrevCalculated(Indi_ColorCandlesDaily::Calculate( + INDICATOR_CALCULATE_GET_PARAMS_LONG, _cache PTR_DEREF GetBuffer(0), + _cache PTR_DEREF GetBuffer(1), _cache PTR_DEREF GetBuffer(2), + _cache PTR_DEREF GetBuffer(3), _cache PTR_DEREF GetBuffer(4))); - return _cache.GetTailValue(_mode, _abs_shift); + return _cache PTR_DEREF GetTailValue(_mode, _abs_shift); } /** diff --git a/Indicators/Indi_ColorLine.mqh b/Indicators/Indi_ColorLine.mqh index e5afbe3a7..e8210a155 100644 --- a/Indicators/Indi_ColorLine.mqh +++ b/Indicators/Indi_ColorLine.mqh @@ -96,20 +96,21 @@ class Indi_ColorLine : public Indicator { */ static double iColorLineOnArray(INDICATOR_CALCULATE_PARAMS_LONG, int _mode, int _abs_shift, IndiBufferCache *_cache, IndicatorData *_indi_ma, bool _recalculate = false) { - _cache.SetPriceBuffer(_open, _high, _low, _close); + _cache PTR_DEREF SetPriceBuffer(_open, _high, _low, _close); - if (!_cache.HasBuffers()) { - _cache.AddBuffer>(1 + 1); + if (!_cache PTR_DEREF HasBuffers()) { + _cache PTR_DEREF AddBuffer>(1 + 1); } if (_recalculate) { - _cache.ResetPrevCalculated(); + _cache PTR_DEREF ResetPrevCalculated(); } - _cache.SetPrevCalculated(Indi_ColorLine::Calculate(INDICATOR_CALCULATE_GET_PARAMS_LONG, _cache.GetBuffer(0), - _cache.GetBuffer(1), _indi_ma)); + _cache PTR_DEREF SetPrevCalculated(Indi_ColorLine::Calculate(INDICATOR_CALCULATE_GET_PARAMS_LONG, + _cache PTR_DEREF GetBuffer(0), + _cache PTR_DEREF GetBuffer(1), _indi_ma)); - return _cache.GetTailValue(_mode, _abs_shift); + return _cache PTR_DEREF GetTailValue(_mode, _abs_shift); } /** @@ -117,7 +118,7 @@ class Indi_ColorLine : public Indicator { */ static double iColorLineOnIndicator(IndicatorData *_indi, int _mode, int _rel_shift, IndicatorData *_obj) { INDICATOR_CALCULATE_POPULATE_PARAMS_AND_CACHE_LONG(_indi, ""); - Indi_MA *_indi_ma = _obj.GetDataSource(INDI_MA); + Indi_MA *_indi_ma = (Indi_MA *)_obj PTR_DEREF GetDataSource(INDI_MA); return iColorLineOnArray(INDICATOR_CALCULATE_POPULATED_PARAMS_LONG, _mode, _indi PTR_DEREF ToAbsShift(_rel_shift), _cache, _indi_ma); } diff --git a/Indicators/Indi_CustomMovingAverage.mqh b/Indicators/Indi_CustomMovingAverage.mqh index b0cc0fb4e..fee017284 100644 --- a/Indicators/Indi_CustomMovingAverage.mqh +++ b/Indicators/Indi_CustomMovingAverage.mqh @@ -20,8 +20,14 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Indicator/Indicator.h" +#include "../Indicators/Price/Indi_MA.h" #include "../Storage/Dict/Buffer/BufferStruct.h" // Structs. diff --git a/Indicators/Indi_DEMA.mqh b/Indicators/Indi_DEMA.mqh index d78d7736c..922bc7ffd 100644 --- a/Indicators/Indi_DEMA.mqh +++ b/Indicators/Indi_DEMA.mqh @@ -134,22 +134,22 @@ class Indi_DEMA : public Indicator { return 0.0f; } - _cache.SetPriceBuffer(_price); + _cache PTR_DEREF SetPriceBuffer(_price); - if (!_cache.HasBuffers()) { - _cache.AddBuffer>(3); // 3 buffers. + if (!_cache PTR_DEREF HasBuffers()) { + _cache PTR_DEREF AddBuffer>(3); // 3 buffers. } if (_recalculate) { // We don't want to continue calculations, but to recalculate previous one. - _cache.ResetPrevCalculated(); + _cache PTR_DEREF ResetPrevCalculated(); } - _cache.SetPrevCalculated(Indi_DEMA::Calculate(INDICATOR_CALCULATE_GET_PARAMS_SHORT, _cache.GetBuffer(0), - _cache.GetBuffer(1), _cache.GetBuffer(2), - _ma_period)); + _cache PTR_DEREF SetPrevCalculated( + Indi_DEMA::Calculate(INDICATOR_CALCULATE_GET_PARAMS_SHORT, _cache PTR_DEREF GetBuffer(0), + _cache PTR_DEREF GetBuffer(1), _cache PTR_DEREF GetBuffer(2), _ma_period)); - return _cache.GetTailValue(0, _ma_shift + _shift); + return _cache PTR_DEREF GetTailValue(0, _ma_shift + _shift); } /** diff --git a/Indicators/Indi_DetrendedPrice.mqh b/Indicators/Indi_DetrendedPrice.mqh index 7e23d9b49..75e57be62 100644 --- a/Indicators/Indi_DetrendedPrice.mqh +++ b/Indicators/Indi_DetrendedPrice.mqh @@ -84,7 +84,7 @@ class Indi_DetrendedPrice : public Indicator { */ static double iDPO(IndicatorData *_indi, int _period, ENUM_APPLIED_PRICE _ap, int _mode = 0, int _rel_shift = 0) { INDI_REQUIRE_BARS_OR_RETURN_EMPTY(_indi, _period + _rel_shift); - INDICATOR_CALCULATE_POPULATE_PARAMS_AND_CACHE_SHORT(_indi, _ap, Util::MakeKey(_indi.GetId())); + INDICATOR_CALCULATE_POPULATE_PARAMS_AND_CACHE_SHORT(_indi, _ap, Util::MakeKey(_indi PTR_DEREF GetId())); return iDPOOnArray(INDICATOR_CALCULATE_POPULATED_PARAMS_SHORT, _period, _ap, _mode, _indi PTR_DEREF ToAbsShift(_rel_shift), _cache); } @@ -94,20 +94,21 @@ class Indi_DetrendedPrice : public Indicator { */ static double iDPOOnArray(INDICATOR_CALCULATE_PARAMS_SHORT, int _period, ENUM_APPLIED_PRICE _ap, int _mode, int _abs_shift, IndiBufferCache *_cache, bool _recalculate = false) { - _cache.SetPriceBuffer(_price); + _cache PTR_DEREF SetPriceBuffer(_price); - if (!_cache.HasBuffers()) { - _cache.AddBuffer>(1 + 1); + if (!_cache PTR_DEREF HasBuffers()) { + _cache PTR_DEREF AddBuffer>(1 + 1); } if (_recalculate) { - _cache.ResetPrevCalculated(); + _cache PTR_DEREF ResetPrevCalculated(); } - _cache.SetPrevCalculated(Indi_DetrendedPrice::Calculate( - INDICATOR_CALCULATE_GET_PARAMS_SHORT, _cache.GetBuffer(0), _cache.GetBuffer(1), _period)); + _cache PTR_DEREF SetPrevCalculated(Indi_DetrendedPrice::Calculate(INDICATOR_CALCULATE_GET_PARAMS_SHORT, + _cache PTR_DEREF GetBuffer(0), + _cache PTR_DEREF GetBuffer(1), _period)); - return _cache.GetTailValue(_mode, _abs_shift); + return _cache PTR_DEREF GetTailValue(_mode, _abs_shift); } /** diff --git a/Indicators/Indi_Drawer.mqh b/Indicators/Indi_Drawer.mqh index 4c4b63f5b..e551fd9b7 100644 --- a/Indicators/Indi_Drawer.mqh +++ b/Indicators/Indi_Drawer.mqh @@ -83,7 +83,7 @@ class Indi_Drawer : public Indicator { */ } - virtual bool ExecuteAction(ENUM_INDICATOR_ACTION _action, DataParamEntry &_args[]) { + virtual bool ExecuteAction(ENUM_INDICATOR_ACTION _action, CONST_ARRAY_REF(DataParamEntry, _args)) { int num_args = ArraySize(_args), i; int _max_modes = Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_MAX_MODES)); @@ -93,7 +93,7 @@ class Indi_Drawer : public Indicator { Set(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_MAX_MODES), num_args - 1); if (num_args - 1 > _max_modes) { - GetLogger().Error( + GetLogger() PTR_DEREF Error( StringFormat("Too many data for buffers for action %s!", EnumToString(_action), __FUNCTION_LINE__)); return false; } @@ -187,7 +187,7 @@ class Indi_Drawer : public Indicator { /** * Performs drawing from data in array. */ - static double iDrawerOnArray(double &array[], int total, int period, int shift) { return 0; } + static double iDrawerOnArray(CONST_ARRAY_REF(double, array), int total, int period, int shift) { return 0; } /* Getters */ diff --git a/Indicators/Indi_Force.mqh b/Indicators/Indi_Force.mqh index e04c4cf1d..31b617982 100644 --- a/Indicators/Indi_Force.mqh +++ b/Indicators/Indi_Force.mqh @@ -33,6 +33,7 @@ // Includes. #include "../Indicator/Indicator.h" +#include "../Indicators/Price/Indi_MA.h" // Structs. struct IndiForceParams : IndicatorParams { diff --git a/Indicators/Indi_FractalAdaptiveMA.mqh b/Indicators/Indi_FractalAdaptiveMA.mqh index ce6682374..4d421d072 100644 --- a/Indicators/Indi_FractalAdaptiveMA.mqh +++ b/Indicators/Indi_FractalAdaptiveMA.mqh @@ -123,20 +123,20 @@ class Indi_FrAMA : public Indicator { */ static double iFrAMAOnArray(INDICATOR_CALCULATE_PARAMS_LONG, int _ma_period, int _ma_shift, ENUM_APPLIED_PRICE _ap, int _mode, int _abs_shift, IndiBufferCache *_cache, bool _recalculate = false) { - _cache.SetPriceBuffer(_open, _high, _low, _close); + _cache PTR_DEREF SetPriceBuffer(_open, _high, _low, _close); - if (!_cache.HasBuffers()) { - _cache.AddBuffer>(1); + if (!_cache PTR_DEREF HasBuffers()) { + _cache PTR_DEREF AddBuffer>(1); } if (_recalculate) { - _cache.ResetPrevCalculated(); + _cache PTR_DEREF ResetPrevCalculated(); } - _cache.SetPrevCalculated(Indi_FrAMA::Calculate(INDICATOR_CALCULATE_GET_PARAMS_LONG, _cache.GetBuffer(0), - _ma_period, _ma_shift, _ap)); + _cache PTR_DEREF SetPrevCalculated(Indi_FrAMA::Calculate( + INDICATOR_CALCULATE_GET_PARAMS_LONG, _cache PTR_DEREF GetBuffer(0), _ma_period, _ma_shift, _ap)); - return _cache.GetTailValue(_mode, _abs_shift); + return _cache PTR_DEREF GetTailValue(_mode, _abs_shift); } /** diff --git a/Indicators/Indi_HeikenAshi.mqh b/Indicators/Indi_HeikenAshi.mqh index 6fddda9d1..e1b19d96f 100644 --- a/Indicators/Indi_HeikenAshi.mqh +++ b/Indicators/Indi_HeikenAshi.mqh @@ -169,21 +169,22 @@ class Indi_HeikenAshi : public Indicator { */ static double iHeikenAshiOnArray(INDICATOR_CALCULATE_PARAMS_LONG, int _mode, int _abs_shift, IndiBufferCache *_cache, bool _recalculate = false) { - _cache.SetPriceBuffer(_open, _high, _low, _close); + _cache PTR_DEREF SetPriceBuffer(_open, _high, _low, _close); - if (!_cache.HasBuffers()) { - _cache.AddBuffer>(1 + 4); + if (!_cache PTR_DEREF HasBuffers()) { + _cache PTR_DEREF AddBuffer>(1 + 4); } if (_recalculate) { - _cache.ResetPrevCalculated(); + _cache PTR_DEREF ResetPrevCalculated(); } - _cache.SetPrevCalculated(Indi_HeikenAshi::Calculate( - INDICATOR_CALCULATE_GET_PARAMS_LONG, _cache.GetBuffer(0), _cache.GetBuffer(1), - _cache.GetBuffer(2), _cache.GetBuffer(3), _cache.GetBuffer(4))); + _cache PTR_DEREF SetPrevCalculated( + Indi_HeikenAshi::Calculate(INDICATOR_CALCULATE_GET_PARAMS_LONG, _cache PTR_DEREF GetBuffer(0), + _cache PTR_DEREF GetBuffer(1), _cache PTR_DEREF GetBuffer(2), + _cache PTR_DEREF GetBuffer(3), _cache PTR_DEREF GetBuffer(4))); - return _cache.GetTailValue(_mode, _abs_shift); + return _cache PTR_DEREF GetTailValue(_mode, _abs_shift); } /** diff --git a/Indicators/Indi_MassIndex.mqh b/Indicators/Indi_MassIndex.mqh index da802dc18..7d1013fe7 100644 --- a/Indicators/Indi_MassIndex.mqh +++ b/Indicators/Indi_MassIndex.mqh @@ -99,21 +99,22 @@ class Indi_MassIndex : public Indicator { */ static double iMIOnArray(INDICATOR_CALCULATE_PARAMS_LONG, int _period, int _second_period, int _sum_period, int _mode, int _abs_shift, IndiBufferCache *_cache, bool _recalculate = false) { - _cache.SetPriceBuffer(_open, _high, _low, _close); + _cache PTR_DEREF SetPriceBuffer(_open, _high, _low, _close); - if (!_cache.HasBuffers()) { - _cache.AddBuffer>(1 + 3); + if (!_cache PTR_DEREF HasBuffers()) { + _cache PTR_DEREF AddBuffer>(1 + 3); } if (_recalculate) { - _cache.ResetPrevCalculated(); + _cache PTR_DEREF ResetPrevCalculated(); } - _cache.SetPrevCalculated(Indi_MassIndex::Calculate( - INDICATOR_CALCULATE_GET_PARAMS_LONG, _cache.GetBuffer(0), _cache.GetBuffer(1), - _cache.GetBuffer(2), _cache.GetBuffer(3), _period, _second_period, _sum_period)); + _cache PTR_DEREF SetPrevCalculated( + Indi_MassIndex::Calculate(INDICATOR_CALCULATE_GET_PARAMS_LONG, _cache PTR_DEREF GetBuffer(0), + _cache PTR_DEREF GetBuffer(1), _cache PTR_DEREF GetBuffer(2), + _cache PTR_DEREF GetBuffer(3), _period, _second_period, _sum_period)); - return _cache.GetTailValue(_mode, _abs_shift); + return _cache PTR_DEREF GetTailValue(_mode, _abs_shift); } /** diff --git a/Indicators/Indi_PriceChannel.mqh b/Indicators/Indi_PriceChannel.mqh index c3cb344fc..bacd96f43 100644 --- a/Indicators/Indi_PriceChannel.mqh +++ b/Indicators/Indi_PriceChannel.mqh @@ -91,21 +91,21 @@ class Indi_PriceChannel : public Indicator { */ static double iPriceChannelOnArray(INDICATOR_CALCULATE_PARAMS_LONG, int _period, int _mode, int _abs_shift, IndiBufferCache *_cache, bool _recalculate = false) { - _cache.SetPriceBuffer(_open, _high, _low, _close); + _cache PTR_DEREF SetPriceBuffer(_open, _high, _low, _close); - if (!_cache.HasBuffers()) { - _cache.AddBuffer>(3); + if (!_cache PTR_DEREF HasBuffers()) { + _cache PTR_DEREF AddBuffer>(3); } if (_recalculate) { - _cache.ResetPrevCalculated(); + _cache PTR_DEREF ResetPrevCalculated(); } - _cache.SetPrevCalculated(Indi_PriceChannel::Calculate(INDICATOR_CALCULATE_GET_PARAMS_LONG, - _cache.GetBuffer(0), _cache.GetBuffer(1), - _cache.GetBuffer(2), _period)); + _cache PTR_DEREF SetPrevCalculated(Indi_PriceChannel::Calculate( + INDICATOR_CALCULATE_GET_PARAMS_LONG, _cache PTR_DEREF GetBuffer(0), + _cache PTR_DEREF GetBuffer(1), _cache PTR_DEREF GetBuffer(2), _period)); - return _cache.GetTailValue(_mode, _abs_shift); + return _cache PTR_DEREF GetTailValue(_mode, _abs_shift); } /** diff --git a/Indicators/Indi_PriceVolumeTrend.mqh b/Indicators/Indi_PriceVolumeTrend.mqh index 0e6daf990..d9a12ed71 100644 --- a/Indicators/Indi_PriceVolumeTrend.mqh +++ b/Indicators/Indi_PriceVolumeTrend.mqh @@ -86,20 +86,20 @@ class Indi_PriceVolumeTrend : public Indicator { */ static double iPVTOnArray(INDICATOR_CALCULATE_PARAMS_LONG, ENUM_APPLIED_VOLUME _av, int _mode, int _abs_shift, IndiBufferCache *_cache, bool _recalculate = false) { - _cache.SetPriceBuffer(_open, _high, _low, _close); + _cache PTR_DEREF SetPriceBuffer(_open, _high, _low, _close); - if (!_cache.HasBuffers()) { - _cache.AddBuffer>(1); + if (!_cache PTR_DEREF HasBuffers()) { + _cache PTR_DEREF AddBuffer>(1); } if (_recalculate) { - _cache.ResetPrevCalculated(); + _cache PTR_DEREF ResetPrevCalculated(); } - _cache.SetPrevCalculated( - Indi_PriceVolumeTrend::Calculate(INDICATOR_CALCULATE_GET_PARAMS_LONG, _cache.GetBuffer(0), _av)); + _cache PTR_DEREF SetPrevCalculated(Indi_PriceVolumeTrend::Calculate(INDICATOR_CALCULATE_GET_PARAMS_LONG, + _cache PTR_DEREF GetBuffer(0), _av)); - return _cache.GetTailValue(_mode, _abs_shift); + return _cache PTR_DEREF GetTailValue(_mode, _abs_shift); } /** diff --git a/Indicators/Indi_RateOfChange.mqh b/Indicators/Indi_RateOfChange.mqh index 9691edb63..fe9ebebfa 100644 --- a/Indicators/Indi_RateOfChange.mqh +++ b/Indicators/Indi_RateOfChange.mqh @@ -80,20 +80,20 @@ class Indi_RateOfChange : public Indicator { */ static double iROCOnArray(INDICATOR_CALCULATE_PARAMS_SHORT, int _period, int _mode, int _abs_shift, IndiBufferCache *_cache, bool _recalculate = false) { - _cache.SetPriceBuffer(_price); + _cache PTR_DEREF SetPriceBuffer(_price); - if (!_cache.HasBuffers()) { - _cache.AddBuffer>(1); + if (!_cache PTR_DEREF HasBuffers()) { + _cache PTR_DEREF AddBuffer>(1); } if (_recalculate) { - _cache.ResetPrevCalculated(); + _cache PTR_DEREF ResetPrevCalculated(); } - _cache.SetPrevCalculated( - Indi_RateOfChange::Calculate(INDICATOR_CALCULATE_GET_PARAMS_SHORT, _cache.GetBuffer(0), _period)); + _cache PTR_DEREF SetPrevCalculated(Indi_RateOfChange::Calculate(INDICATOR_CALCULATE_GET_PARAMS_SHORT, + _cache PTR_DEREF GetBuffer(0), _period)); - return _cache.GetTailValue(_mode, _abs_shift); + return _cache PTR_DEREF GetTailValue(_mode, _abs_shift); } /** diff --git a/Indicators/Indi_TEMA.mqh b/Indicators/Indi_TEMA.mqh index 3529aa46f..14d98a012 100644 --- a/Indicators/Indi_TEMA.mqh +++ b/Indicators/Indi_TEMA.mqh @@ -104,21 +104,22 @@ class Indi_TEMA : public Indicator { */ static double iTEMAOnArray(INDICATOR_CALCULATE_PARAMS_SHORT, int _ma_period, int _ma_shift, int _mode, int _abs_shift, IndiBufferCache *_cache, bool _recalculate = false) { - _cache.SetPriceBuffer(_price); + _cache PTR_DEREF SetPriceBuffer(_price); - if (!_cache.HasBuffers()) { - _cache.AddBuffer>(4); + if (!_cache PTR_DEREF HasBuffers()) { + _cache PTR_DEREF AddBuffer>(4); } if (_recalculate) { - _cache.ResetPrevCalculated(); + _cache PTR_DEREF ResetPrevCalculated(); } - _cache.SetPrevCalculated(Indi_TEMA::Calculate(INDICATOR_CALCULATE_GET_PARAMS_SHORT, _cache.GetBuffer(0), - _cache.GetBuffer(1), _cache.GetBuffer(2), - _cache.GetBuffer(3), _ma_period, _ma_shift)); + _cache PTR_DEREF SetPrevCalculated( + Indi_TEMA::Calculate(INDICATOR_CALCULATE_GET_PARAMS_SHORT, _cache PTR_DEREF GetBuffer(0), + _cache PTR_DEREF GetBuffer(1), _cache PTR_DEREF GetBuffer(2), + _cache PTR_DEREF GetBuffer(3), _ma_period, _ma_shift)); - return _cache.GetTailValue(_mode, _abs_shift); + return _cache PTR_DEREF GetTailValue(_mode, _abs_shift); } /** diff --git a/Indicators/Indi_TRIX.mqh b/Indicators/Indi_TRIX.mqh index 31c7cd3c4..880b5a7d9 100644 --- a/Indicators/Indi_TRIX.mqh +++ b/Indicators/Indi_TRIX.mqh @@ -102,21 +102,22 @@ class Indi_TRIX : public Indicator { */ static double iTriXOnArray(INDICATOR_CALCULATE_PARAMS_SHORT, int _ma_period, int _mode, int _abs_shift, IndiBufferCache *_cache, bool _recalculate = false) { - _cache.SetPriceBuffer(_price); + _cache PTR_DEREF SetPriceBuffer(_price); - if (!_cache.HasBuffers()) { - _cache.AddBuffer>(4); + if (!_cache PTR_DEREF HasBuffers()) { + _cache PTR_DEREF AddBuffer>(4); } if (_recalculate) { - _cache.ResetPrevCalculated(); + _cache PTR_DEREF ResetPrevCalculated(); } - _cache.SetPrevCalculated(Indi_TRIX::Calculate(INDICATOR_CALCULATE_GET_PARAMS_SHORT, _cache.GetBuffer(0), - _cache.GetBuffer(1), _cache.GetBuffer(2), - _cache.GetBuffer(3), _ma_period)); + _cache PTR_DEREF SetPrevCalculated( + Indi_TRIX::Calculate(INDICATOR_CALCULATE_GET_PARAMS_SHORT, _cache PTR_DEREF GetBuffer(0), + _cache PTR_DEREF GetBuffer(1), _cache PTR_DEREF GetBuffer(2), + _cache PTR_DEREF GetBuffer(3), _ma_period)); - return _cache.GetTailValue(_mode, _abs_shift); + return _cache PTR_DEREF GetTailValue(_mode, _abs_shift); } /** diff --git a/Indicators/Indi_UltimateOscillator.mqh b/Indicators/Indi_UltimateOscillator.mqh index 8c5bb3481..a3b31deab 100644 --- a/Indicators/Indi_UltimateOscillator.mqh +++ b/Indicators/Indi_UltimateOscillator.mqh @@ -122,22 +122,23 @@ class Indi_UltimateOscillator : public Indicator { int _fast_k, int _middle_k, int _slow_k, int _mode, int _abs_shift, IndiBufferCache *_cache, IndicatorData *_indi_atr_fast, IndicatorData *_indi_atr_middle, IndicatorData *_indi_atr_slow, bool _recalculate = false) { - _cache.SetPriceBuffer(_open, _high, _low, _close); + _cache PTR_DEREF SetPriceBuffer(_open, _high, _low, _close); - if (!_cache.HasBuffers()) { - _cache.AddBuffer>(1 + 4); + if (!_cache PTR_DEREF HasBuffers()) { + _cache PTR_DEREF AddBuffer>(1 + 4); } if (_recalculate) { - _cache.ResetPrevCalculated(); + _cache PTR_DEREF ResetPrevCalculated(); } - _cache.SetPrevCalculated(Indi_UltimateOscillator::Calculate( - INDICATOR_CALCULATE_GET_PARAMS_LONG, _cache.GetBuffer(0), _cache.GetBuffer(1), - _cache.GetBuffer(2), _cache.GetBuffer(3), _cache.GetBuffer(4), _fast_period, - _middle_period, _slow_period, _fast_k, _middle_k, _slow_k, _indi_atr_fast, _indi_atr_middle, _indi_atr_slow)); + _cache PTR_DEREF SetPrevCalculated(Indi_UltimateOscillator::Calculate( + INDICATOR_CALCULATE_GET_PARAMS_LONG, _cache PTR_DEREF GetBuffer(0), + _cache PTR_DEREF GetBuffer(1), _cache PTR_DEREF GetBuffer(2), + _cache PTR_DEREF GetBuffer(3), _cache PTR_DEREF GetBuffer(4), _fast_period, _middle_period, + _slow_period, _fast_k, _middle_k, _slow_k, _indi_atr_fast, _indi_atr_middle, _indi_atr_slow)); - return _cache.GetTailValue(_mode, _abs_shift); + return _cache PTR_DEREF GetTailValue(_mode, _abs_shift); } /** diff --git a/Indicators/Indi_VIDYA.mqh b/Indicators/Indi_VIDYA.mqh index 25238207a..e6a29adb5 100644 --- a/Indicators/Indi_VIDYA.mqh +++ b/Indicators/Indi_VIDYA.mqh @@ -107,20 +107,21 @@ class Indi_VIDYA : public Indicator { */ static double iVIDyAOnArray(INDICATOR_CALCULATE_PARAMS_SHORT, int _cmo_period, int _ema_period, int _ma_shift, int _mode, int _abs_shift, IndiBufferCache *_cache, bool _recalculate = false) { - _cache.SetPriceBuffer(_price); + _cache PTR_DEREF SetPriceBuffer(_price); - if (!_cache.HasBuffers()) { - _cache.AddBuffer>(1); + if (!_cache PTR_DEREF HasBuffers()) { + _cache PTR_DEREF AddBuffer>(1); } if (_recalculate) { - _cache.ResetPrevCalculated(); + _cache PTR_DEREF ResetPrevCalculated(); } - _cache.SetPrevCalculated(Indi_VIDYA::Calculate(INDICATOR_CALCULATE_GET_PARAMS_SHORT, _cache.GetBuffer(0), - _cmo_period, _ema_period, _ma_shift)); + _cache PTR_DEREF SetPrevCalculated(Indi_VIDYA::Calculate(INDICATOR_CALCULATE_GET_PARAMS_SHORT, + _cache PTR_DEREF GetBuffer(0), _cmo_period, + _ema_period, _ma_shift)); - return _cache.GetTailValue(_mode, _abs_shift); + return _cache PTR_DEREF GetTailValue(_mode, _abs_shift); } /** diff --git a/Indicators/Indi_VROC.mqh b/Indicators/Indi_VROC.mqh index b7e869aac..49d36f112 100644 --- a/Indicators/Indi_VROC.mqh +++ b/Indicators/Indi_VROC.mqh @@ -94,20 +94,20 @@ class Indi_VROC : public Indicator { */ static double iVROCOnArray(INDICATOR_CALCULATE_PARAMS_LONG, int _period, ENUM_APPLIED_VOLUME _av, int _mode, int _abs_shift, IndiBufferCache *_cache, bool _recalculate = false) { - _cache.SetPriceBuffer(_open, _high, _low, _close); + _cache PTR_DEREF SetPriceBuffer(_open, _high, _low, _close); - if (!_cache.HasBuffers()) { - _cache.AddBuffer>(1); + if (!_cache PTR_DEREF HasBuffers()) { + _cache PTR_DEREF AddBuffer>(1); } if (_recalculate) { - _cache.ResetPrevCalculated(); + _cache PTR_DEREF ResetPrevCalculated(); } - _cache.SetPrevCalculated( - Indi_VROC::Calculate(INDICATOR_CALCULATE_GET_PARAMS_LONG, _cache.GetBuffer(0), _period, _av)); + _cache PTR_DEREF SetPrevCalculated( + Indi_VROC::Calculate(INDICATOR_CALCULATE_GET_PARAMS_LONG, _cache PTR_DEREF GetBuffer(0), _period, _av)); - return _cache.GetTailValue(_mode, _abs_shift); + return _cache PTR_DEREF GetTailValue(_mode, _abs_shift); } /** diff --git a/Indicators/Indi_Volumes.mqh b/Indicators/Indi_Volumes.mqh index 8ae7f687f..a2a44227e 100644 --- a/Indicators/Indi_Volumes.mqh +++ b/Indicators/Indi_Volumes.mqh @@ -97,20 +97,21 @@ class Indi_Volumes : public Indicator { */ static double iVolumesOnArray(INDICATOR_CALCULATE_PARAMS_LONG, ENUM_APPLIED_VOLUME _av, int _mode, int _abs_shift, IndiBufferCache *_cache, bool _recalculate = false) { - _cache.SetPriceBuffer(_open, _high, _low, _close); + _cache PTR_DEREF SetPriceBuffer(_open, _high, _low, _close); - if (!_cache.HasBuffers()) { - _cache.AddBuffer>(1 + 1); + if (!_cache PTR_DEREF HasBuffers()) { + _cache PTR_DEREF AddBuffer>(1 + 1); } if (_recalculate) { - _cache.ResetPrevCalculated(); + _cache PTR_DEREF ResetPrevCalculated(); } - _cache.SetPrevCalculated(Indi_Volumes::Calculate(INDICATOR_CALCULATE_GET_PARAMS_LONG, _cache.GetBuffer(0), - _cache.GetBuffer(1), _av)); + _cache PTR_DEREF SetPrevCalculated(Indi_Volumes::Calculate(INDICATOR_CALCULATE_GET_PARAMS_LONG, + _cache PTR_DEREF GetBuffer(0), + _cache PTR_DEREF GetBuffer(1), _av)); - return _cache.GetTailValue(_mode, _abs_shift); + return _cache PTR_DEREF GetTailValue(_mode, _abs_shift); } /** diff --git a/Indicators/Indi_WilliamsAD.mqh b/Indicators/Indi_WilliamsAD.mqh index b828039aa..39ae47871 100644 --- a/Indicators/Indi_WilliamsAD.mqh +++ b/Indicators/Indi_WilliamsAD.mqh @@ -95,20 +95,20 @@ class Indi_WilliamsAD : public Indicator { */ static double iWADOnArray(INDICATOR_CALCULATE_PARAMS_LONG, int _mode, int _abs_shift, IndiBufferCache *_cache, bool _recalculate = false) { - _cache.SetPriceBuffer(_open, _high, _low, _close); + _cache PTR_DEREF SetPriceBuffer(_open, _high, _low, _close); - if (!_cache.HasBuffers()) { - _cache.AddBuffer>(1); + if (!_cache PTR_DEREF HasBuffers()) { + _cache PTR_DEREF AddBuffer>(1); } if (_recalculate) { - _cache.ResetPrevCalculated(); + _cache PTR_DEREF ResetPrevCalculated(); } - _cache.SetPrevCalculated( - Indi_WilliamsAD::Calculate(INDICATOR_CALCULATE_GET_PARAMS_LONG, _cache.GetBuffer(0))); + _cache PTR_DEREF SetPrevCalculated( + Indi_WilliamsAD::Calculate(INDICATOR_CALCULATE_GET_PARAMS_LONG, _cache PTR_DEREF GetBuffer(0))); - return _cache.GetTailValue(_mode, _abs_shift); + return _cache PTR_DEREF GetTailValue(_mode, _abs_shift); } /** diff --git a/Indicators/Indi_ZigZag.mqh b/Indicators/Indi_ZigZag.mqh index 38886a9ea..97efecc53 100644 --- a/Indicators/Indi_ZigZag.mqh +++ b/Indicators/Indi_ZigZag.mqh @@ -163,21 +163,21 @@ class Indi_ZigZag : public Indicator { */ static double iZigZagOnArray(INDICATOR_CALCULATE_PARAMS_LONG, int _depth, int _deviation, int _backstep, int _mode, int _abs_shift, IndiBufferCache *_cache, bool _recalculate = false) { - _cache.SetPriceBuffer(_open, _high, _low, _close); + _cache PTR_DEREF SetPriceBuffer(_open, _high, _low, _close); - if (!_cache.HasBuffers()) { - _cache.AddBuffer>(1 + 2); + if (!_cache PTR_DEREF HasBuffers()) { + _cache PTR_DEREF AddBuffer>(1 + 2); } if (_recalculate) { - _cache.ResetPrevCalculated(); + _cache PTR_DEREF ResetPrevCalculated(); } - _cache.SetPrevCalculated(Indi_ZigZag::Calculate(INDICATOR_CALCULATE_GET_PARAMS_LONG, _cache.GetBuffer(0), - _cache.GetBuffer(1), _cache.GetBuffer(2), _depth, - _deviation, _backstep)); + _cache PTR_DEREF SetPrevCalculated(Indi_ZigZag::Calculate( + INDICATOR_CALCULATE_GET_PARAMS_LONG, _cache PTR_DEREF GetBuffer(0), + _cache PTR_DEREF GetBuffer(1), _cache PTR_DEREF GetBuffer(2), _depth, _deviation, _backstep)); - return _cache.GetTailValue(_mode, _abs_shift); + return _cache PTR_DEREF GetTailValue(_mode, _abs_shift); } /** diff --git a/Indicators/Indi_ZigZagColor.mqh b/Indicators/Indi_ZigZagColor.mqh index c26a08007..5877cb0a1 100644 --- a/Indicators/Indi_ZigZagColor.mqh +++ b/Indicators/Indi_ZigZagColor.mqh @@ -110,22 +110,22 @@ class Indi_ZigZagColor : public Indicator { static double iZigZagColorOnArray(INDICATOR_CALCULATE_PARAMS_LONG, int _depth, int _deviation, int _backstep, int _mode, int _abs_shift, IndiBufferCache *_cache, bool _recalculate = false) { - _cache.SetPriceBuffer(_open, _high, _low, _close); + _cache PTR_DEREF SetPriceBuffer(_open, _high, _low, _close); - if (!_cache.HasBuffers()) { - _cache.AddBuffer>(3 + 2); + if (!_cache PTR_DEREF HasBuffers()) { + _cache PTR_DEREF AddBuffer>(3 + 2); } if (_recalculate) { - _cache.ResetPrevCalculated(); + _cache PTR_DEREF ResetPrevCalculated(); } - _cache.SetPrevCalculated(Indi_ZigZagColor::Calculate(INDICATOR_CALCULATE_GET_PARAMS_LONG, - _cache.GetBuffer(0), _cache.GetBuffer(1), - _cache.GetBuffer(2), _cache.GetBuffer(3), - _cache.GetBuffer(4), _depth, _deviation, _backstep)); + _cache PTR_DEREF SetPrevCalculated(Indi_ZigZagColor::Calculate( + INDICATOR_CALCULATE_GET_PARAMS_LONG, _cache PTR_DEREF GetBuffer(0), + _cache PTR_DEREF GetBuffer(1), _cache PTR_DEREF GetBuffer(2), + _cache PTR_DEREF GetBuffer(3), _cache PTR_DEREF GetBuffer(4), _depth, _deviation, _backstep)); - return _cache.GetTailValue(_mode, _abs_shift); + return _cache PTR_DEREF GetTailValue(_mode, _abs_shift); } /** diff --git a/Math/Math.extern.h b/Math/Math.extern.h index da468d94e..637a790c7 100644 --- a/Math/Math.extern.h +++ b/Math/Math.extern.h @@ -44,6 +44,14 @@ T MathPow(T base, T exponent) { return std::pow(base, exponent); } template +T MathLog(T value) { + return std::log(value); +} +template +T MathExp(T value) { + return std::exp(value); +} +template T MathSqrt(T value) { return std::sqrt(value); } diff --git a/Platform/Platform.h b/Platform/Platform.h index e7b6d9371..67d33153b 100644 --- a/Platform/Platform.h +++ b/Platform/Platform.h @@ -440,6 +440,38 @@ class Platform { return period; } + /** + * Returns the point size of the current symbol in the quote currency. + * @see https://docs.mql4.com/check/point + */ + static double GetPoint() { + if (symbol == PLATFORM_WRONG_SYMBOL) { + RUNTIME_ERROR( + "Retrieving _Point variable or calling Point() outside the OnTick() of the currently ticking indicator is " + "prohibited!"); + } + + Alert("Error: Platform::GetPoint() is not yet implemented! Returning 0.01."); + DebugBreak(); + return 0.01; + } + + /** + * Returns the number of decimal digits determining the accuracy of price of the current chart symbol. + * @see https://docs.mql4.com/check/digits + */ + static int GetDigits() { + if (symbol == PLATFORM_WRONG_SYMBOL) { + RUNTIME_ERROR( + "Retrieving _Digits variable or calling Digits() outside the OnTick() of the currently ticking indicator is " + "prohibited!"); + } + + Alert("Error: Platform::GetDigits() is not yet implemented! Returning 2."); + DebugBreak(); + return 2; + } + private: /** * Sets symbol of the currently ticking indicator. @@ -804,6 +836,12 @@ SymbolGetter::operator string() const { return Platform::GetSymbol(); } ENUM_TIMEFRAMES Period() { return Platform::GetPeriod(); } +double Point() { return Platform::GetPoint(); } +#define _Point (Point()) + +int Digits() { return Platform::GetDigits(); } +#define _Digits (Digits()) + datetime StructToTime(MqlDateTime &dt_struct) { tm ltm; ltm.tm_mday = dt_struct.day; diff --git a/Platform/Terminal.define.h b/Platform/Terminal.define.h index d99fb5c98..fb94241be 100644 --- a/Platform/Terminal.define.h +++ b/Platform/Terminal.define.h @@ -98,6 +98,7 @@ #define clrLightBlue 0x00ADD8E6 #define clrLightCoral 0x00F08080 #define clrLightCyan 0x00E0FFFF +#define clrLightGoldenrod 0x00EEDC82 #define clrLightGoldenrodYellow 0x00FAFAD2 #define clrLightGreen 0x0090EE90 #define clrLightGrey 0x00D3D3D3 diff --git a/Std.h b/Std.h index 181592c58..f5d05f864 100644 --- a/Std.h +++ b/Std.h @@ -69,8 +69,8 @@ #define PTR_DEREF -> #define PTR_ATTRIB(O, A) O->A #define PTR_ATTRIB2(O, A, B) O->A->B -#define PTR_TO_REF(PTR) (*PTR) -#define REF_TO_PTR(PTR) (&PTR) +#define PTR_TO_REF(PTR) (*(PTR)) +#define REF_TO_PTR(PTR) (&(PTR)) #define MAKE_REF_FROM_PTR(TYPE, NAME, PTR) TYPE& NAME = PTR #define REF_DEREF .Ptr()-> #define int64 long long diff --git a/Storage/Cache/IndiBufferCache.h b/Storage/Cache/IndiBufferCache.h index 09cad345a..6c7248796 100644 --- a/Storage/Cache/IndiBufferCache.h +++ b/Storage/Cache/IndiBufferCache.h @@ -172,17 +172,17 @@ class IndiBufferCache : public Dynamic { REF_TO(ValueStorage) GetPriceBuffer(ENUM_APPLIED_PRICE _applied_price) { switch (_applied_price) { case PRICE_OPEN: - return price_open_buffer; + return PTR_TO_REF(price_open_buffer); case PRICE_HIGH: - return price_high_buffer; + return PTR_TO_REF(price_high_buffer); case PRICE_LOW: - return price_low_buffer; + return PTR_TO_REF(price_low_buffer); case PRICE_CLOSE: - return price_close_buffer; + return PTR_TO_REF(price_close_buffer); default: RUNTIME_ERROR("Applied price not supported!"); } - return nullptr; + return PTR_TO_REF((ValueStorage *)nullptr); } /** diff --git a/Storage/ValueStorage.applied_price.h b/Storage/ValueStorage.applied_price.h index 5b513e056..f7fdb91f8 100644 --- a/Storage/ValueStorage.applied_price.h +++ b/Storage/ValueStorage.applied_price.h @@ -24,6 +24,11 @@ * Price getter version of ValueStorage. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Platform/Chart/Chart.struct.h" #include "Cache/ObjectsCache.h" diff --git a/Storage/ValueStorage.h b/Storage/ValueStorage.h index ab43f81e5..07cbbc449 100644 --- a/Storage/ValueStorage.h +++ b/Storage/ValueStorage.h @@ -98,29 +98,32 @@ enum ENUM_IPEAK { IPEAK_LOWEST, IPEAK_HIGHEST }; REF_TO(ValueStorage) _price = PTR_TO_REF(_price_ptr); \ INDICATOR_CALCULATE_POPULATE_CACHE(INDI, KEY) -#define INDICATOR_CALCULATE_POPULATE_PARAMS_AND_CACHE_LONG(INDI, KEY) \ - IndicatorData *_suitable_ds = INDI PTR_DEREF GetSuitableDataSource(); \ - ValueStorage &_time = \ - (ValueStorage &)(_suitable_ds PTR_DEREF GetSpecificValueStorage(INDI_DATA_VS_TYPE_TIME)); \ - REF_TO(ValueStorage) \ - _tick_volume = \ - REF_CAST(ValueStorage)(_suitable_ds PTR_DEREF GetSpecificValueStorage(INDI_DATA_VS_TYPE_TICK_VOLUME)); \ - REF_TO(ValueStorage) \ - _volume = REF_CAST(ValueStorage)(_suitable_ds PTR_DEREF GetSpecificValueStorage(INDI_DATA_VS_TYPE_VOLUME)); \ - REF_TO(ValueStorage) \ - _spread = REF_CAST(ValueStorage)(_suitable_ds PTR_DEREF GetSpecificValueStorage(INDI_DATA_VS_TYPE_SPREAD)); \ - REF_TO(ValueStorage) \ - _price_open = \ - REF_CAST(ValueStorage)(_suitable_ds PTR_DEREF GetSpecificValueStorage(INDI_DATA_VS_TYPE_PRICE_OPEN)); \ - REF_TO(ValueStorage) \ - _price_high = \ - REF_CAST(ValueStorage)(_suitable_ds PTR_DEREF GetSpecificValueStorage(INDI_DATA_VS_TYPE_PRICE_HIGH)); \ - REF_TO(ValueStorage) \ - _price_low = \ - REF_CAST(ValueStorage)(_suitable_ds PTR_DEREF GetSpecificValueStorage(INDI_DATA_VS_TYPE_PRICE_LOW)); \ - REF_TO(ValueStorage) \ - _price_close = \ - REF_CAST(ValueStorage)(_suitable_ds PTR_DEREF GetSpecificValueStorage(INDI_DATA_VS_TYPE_PRICE_CLOSE)); \ +#define INDICATOR_CALCULATE_POPULATE_PARAMS_AND_CACHE_LONG(INDI, KEY) \ + IndicatorData *_suitable_ds = INDI PTR_DEREF GetSuitableDataSource(); \ + REF_TO(ValueStorage) \ + _time = REF_CAST(ValueStorage) \ + PTR_TO_REF(_suitable_ds PTR_DEREF GetSpecificValueStorage(INDI_DATA_VS_TYPE_TIME)); \ + REF_TO(ValueStorage) \ + _tick_volume = REF_CAST(ValueStorage) \ + PTR_TO_REF(_suitable_ds PTR_DEREF GetSpecificValueStorage(INDI_DATA_VS_TYPE_TICK_VOLUME)); \ + REF_TO(ValueStorage) \ + _volume = REF_CAST(ValueStorage) \ + PTR_TO_REF(_suitable_ds PTR_DEREF GetSpecificValueStorage(INDI_DATA_VS_TYPE_VOLUME)); \ + REF_TO(ValueStorage) \ + _spread = REF_CAST(ValueStorage) \ + PTR_TO_REF(_suitable_ds PTR_DEREF GetSpecificValueStorage(INDI_DATA_VS_TYPE_SPREAD)); \ + REF_TO(ValueStorage) \ + _price_open = REF_CAST(ValueStorage) \ + PTR_TO_REF(_suitable_ds PTR_DEREF GetSpecificValueStorage(INDI_DATA_VS_TYPE_PRICE_OPEN)); \ + REF_TO(ValueStorage) \ + _price_high = REF_CAST(ValueStorage) \ + PTR_TO_REF(_suitable_ds PTR_DEREF GetSpecificValueStorage(INDI_DATA_VS_TYPE_PRICE_HIGH)); \ + REF_TO(ValueStorage) \ + _price_low = REF_CAST(ValueStorage) \ + PTR_TO_REF(_suitable_ds PTR_DEREF GetSpecificValueStorage(INDI_DATA_VS_TYPE_PRICE_LOW)); \ + REF_TO(ValueStorage) \ + _price_close = REF_CAST(ValueStorage) \ + PTR_TO_REF(_suitable_ds PTR_DEREF GetSpecificValueStorage(INDI_DATA_VS_TYPE_PRICE_CLOSE)); \ INDICATOR_CALCULATE_POPULATE_CACHE(INDI, KEY) #define INDICATOR_CALCULATE_POPULATED_PARAMS_LONG \ diff --git a/Storage/ValueStorage.native.h b/Storage/ValueStorage.native.h index 048d82fcb..1ce9b13f6 100644 --- a/Storage/ValueStorage.native.h +++ b/Storage/ValueStorage.native.h @@ -24,6 +24,11 @@ * Native array version of ValueStorage. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "ValueStorage.h" From 65a4d6326fa29a052c50077c5c61a1102ab0d81e Mon Sep 17 00:00:00 2001 From: Adrian Kierzkowski Date: Mon, 3 Jul 2023 20:38:11 +0200 Subject: [PATCH 20/26] WIP. Fixing C++ errors. Closer to the end. --- Common.define.h | 4 + Common.extern.h | 4 +- Convert.basic.h | 6 +- Convert.extern.h | 2 +- EA.mqh | 18 +- Exchange/Account/Account.define.h | 5 + Exchange/Account/Account.extern.h | 5 + Exchange/Account/Account.h | 10 +- Exchange/Account/AccountBase.h | 9 +- Exchange/Account/AccountForex.h | 8 +- Exchange/Account/AccountMt.h | 16 +- Exchange/Exchange.h | 14 +- Exchange/SymbolInfo/SymbolInfo.define.h | 5 + Exchange/SymbolInfo/SymbolInfo.extern.h | 10 +- Exchange/SymbolInfo/SymbolInfo.h | 8 +- .../SymbolInfo/SymbolInfo.struct.static.h | 4 +- File.define.h | 1 + File.extern.h | 9 +- Indicator/Indicator.h | 9 +- Indicator/Indicator.struct.serialize.h | 5 + Indicator/IndicatorCandle.h | 6 - Indicator/IndicatorCandle.provider.h | 6 - Indicator/IndicatorData.h | 7 - Indicator/IndicatorData.struct.serialize.h | 5 + Indicator/IndicatorRenko.h | 6 - Indicator/IndicatorTf.h | 6 - Indicator/IndicatorTf.provider.h | 6 - Indicator/IndicatorTick.h | 6 - Indicator/IndicatorTick.provider.h | 9 +- Indicators/Bitwise/Indi_Candle.mqh | 5 + Indicators/Bitwise/Indi_Pattern.mqh | 5 + Indicators/Bitwise/includes.h | 5 + Indicators/DrawIndicator.mqh | 10 +- Indicators/Indi_AC.mqh | 8 +- Indicators/Indi_AD.mqh | 6 +- Indicators/Indi_ADXW.mqh | 5 + Indicators/Indi_AMA.mqh | 5 + Indicators/Indi_ASI.mqh | 5 + Indicators/Indi_BWMFI.mqh | 5 + Indicators/Indi_BWZT.mqh | 5 + Indicators/Indi_BearsPower.mqh | 5 + Indicators/Indi_BullsPower.mqh | 5 + Indicators/Indi_CCI.mqh | 5 + Indicators/Indi_CHO.mqh | 5 + Indicators/Indi_CHV.mqh | 5 + Indicators/Indi_ColorBars.mqh | 5 + Indicators/Indi_ColorCandlesDaily.mqh | 5 + Indicators/Indi_ColorLine.mqh | 5 + Indicators/Indi_DEMA.mqh | 8 +- Indicators/Indi_DeMarker.mqh | 5 + Indicators/Indi_Demo.mqh | 5 + Indicators/Indi_DetrendedPrice.mqh | 5 + Indicators/Indi_Drawer.mqh | 5 + Indicators/Indi_Drawer.struct.h | 5 + Indicators/Indi_Force.mqh | 5 + Indicators/Indi_FractalAdaptiveMA.mqh | 5 + Indicators/Indi_Fractals.mqh | 5 + Indicators/Indi_Gator.mqh | 6 + Indicators/Indi_HeikenAshi.mqh | 5 + Indicators/Indi_Ichimoku.mqh | 5 + Indicators/Indi_Killzones.mqh | 5 + Indicators/Indi_MFI.mqh | 5 + Indicators/Indi_MassIndex.mqh | 5 + Indicators/Indi_Momentum.mqh | 5 + Indicators/Indi_OBV.mqh | 5 + Indicators/Indi_OsMA.mqh | 5 + Indicators/Indi_PriceChannel.mqh | 8 +- Indicators/Indi_PriceVolumeTrend.mqh | 5 + Indicators/Indi_RS.mqh | 7 +- Indicators/Indi_RVI.mqh | 5 + Indicators/Indi_RateOfChange.mqh | 5 + Indicators/Indi_StdDev.mqh | 5 + Indicators/Indi_TEMA.mqh | 5 + Indicators/Indi_TRIX.mqh | 5 + Indicators/Indi_UltimateOscillator.mqh | 15 +- Indicators/Indi_VIDYA.mqh | 5 + Indicators/Indi_VROC.mqh | 5 + Indicators/Indi_Volumes.mqh | 5 + Indicators/Indi_WilliamsAD.mqh | 6 + Indicators/Indi_ZigZag.mqh | 13 +- Indicators/Indi_ZigZagColor.mqh | 7 +- Indicators/OHLC/Indi_OHLC.mqh | 5 + Indicators/OHLC/includes.h | 5 + Indicators/Oscillator/Indi_MACD.h | 5 + Indicators/Oscillator/Indi_RSI.h | 5 + Indicators/Oscillator/Indi_Stochastic.h | 5 + Indicators/Oscillator/Indi_WPR.h | 5 + Indicators/Oscillator/includes.h | 5 + Indicators/Price/Indi_AppliedPrice.h | 5 + Indicators/Price/Indi_MA.h | 9 +- Indicators/Price/includes.h | 5 + Indicators/PriceMulti/Indi_Alligator.h | 5 + Indicators/PriceMulti/includes.h | 5 + Indicators/PriceRange/Indi_Bands.h | 5 + Indicators/PriceRange/Indi_Pivot.h | 5 + Indicators/PriceRange/Indi_SAR.h | 5 + Indicators/PriceRange/includes.h | 5 + Indicators/Special/Indi_Custom.mqh | 9 +- Indicators/Special/Indi_Math.mqh | 5 + Indicators/Special/includes.h | 5 + Indicators/Tick/Indi_TickMt.h | 4 +- Indicators/Tick/includes.h | 5 + Indicators/includes.h | 5 + Log.mqh | 11 +- MD5.mqh | 7 +- Mail.mqh | 12 +- Market.struct.h | 9 +- Math/Math.extern.h | 1 + Math/Matrix.h | 9 +- Math/MatrixMini.h | 9 +- Pattern.mqh | 5 + Platform/Chart/Chart.define.h | 5 + Platform/Chart/Chart.h | 17 +- Platform/Chart/Chart.struct.serialize.h | 5 + Platform/Chart3D/Chart3D.h | 5 + Platform/Chart3D/Chart3DCandles.h | 5 + Platform/Chart3D/Chart3DType.h | 5 + Platform/Chart3D/Cube.h | 5 + Platform/Chart3D/Device.h | 5 + Platform/Chart3D/Devices/MTDX/MTDXDevice.h | 5 + .../Chart3D/Devices/MTDX/MTDXIndexBuffer.h | 5 + Platform/Chart3D/Devices/MTDX/MTDXShader.h | 5 + .../Chart3D/Devices/MTDX/MTDXVertexBuffer.h | 5 + Platform/Chart3D/Face.h | 5 + Platform/Chart3D/Frontend.h | 5 + Platform/Chart3D/Frontends/MT5Frontend.h | 5 + Platform/Chart3D/IndexBuffer.h | 5 + Platform/Chart3D/Interface.h | 5 + Platform/Chart3D/Material.h | 5 + Platform/Chart3D/Math.h | 5 + Platform/Chart3D/Mesh.h | 7 +- Platform/Chart3D/Shader.h | 5 + Platform/Chart3D/ShaderVertexLayout.struct.h | 5 + Platform/Chart3D/TSR.h | 5 + Platform/Chart3D/Vertex.h | 5 + Platform/Chart3D/VertexBuffer.h | 5 + Platform/Order.define.h | 5 + Platform/Order.h | 23 +- Platform/OrderQuery.h | 9 +- Platform/Orders.h | 9 +- Platform/Platform.extern.h | 12 + Platform/PlatformTime.h | 6 +- Platform/Plot.h | 5 + Platform/Terminal.define.h | 5 + Platform/Terminal.h | 13 +- Platform/Web/Web.h | 7 +- Profiler.mqh | 5 + Report.mqh | 59 ++-- Serializer/Serializer.define.h | 5 + Serializer/Serializer.h | 9 +- Serializer/SerializerBinary.h | 9 +- Serializer/SerializerConverter.h | 6 - Serializer/SerializerCsv.h | 13 +- Serializer/SerializerDict.h | 9 +- Serializer/SerializerJson.h | 9 +- Serializer/SerializerNode.h | 9 +- Serializer/SerializerNodeIterator.h | 9 +- Serializer/SerializerNodeParam.h | 11 +- Serializer/SerializerObject.h | 9 +- Serializer/SerializerSqlite.h | 9 +- SetFile.mqh | 281 +++++++++--------- Socket.mqh | 5 + Stats.mqh | 5 + Storage/Array.extern.h | 11 + Storage/Array.h | 22 ++ Storage/Collection.h | 8 +- Storage/Data.define.h | 5 + Storage/Database.extern.h | 7 +- Storage/Database.h | 8 +- Storage/Database.struct.h | 5 + Storage/DateTime.h | 9 +- Storage/Dict/Buffer/Buffer.h | 8 +- Storage/Dict/Buffer/BufferCandle.h | 9 +- Storage/Dict/Buffer/BufferFXT.h | 9 +- Storage/Dict/Buffer/BufferStruct.h | 9 +- Storage/Dict/Buffer/BufferTick.h | 9 +- Storage/Dict/Dict.h | 9 +- Storage/Dict/DictBase.h | 9 +- Storage/Dict/DictSlot.h | 9 +- Storage/Object.enum.h | 2 +- Storage/Object.extern.h | 1 + Storage/Object.h | 8 +- Storage/Redis.h | 6 + Storage/String.extern.h | 2 +- Storage/String.h | 8 +- Storage/ValueStorage.price_median.h | 5 + Storage/ValueStorage.price_typical.h | 5 + Storage/ValueStorage.price_weighted.h | 5 + Strategy.struct.pricestop.h | 4 +- SummaryReport.mqh | 7 +- Test.mqh | 5 + Tester.mqh | 5 + Tests.mqh | 5 + Timer.mqh | 5 + Trade/TradeSignal.h | 5 + Trade/TradeSignal.struct.h | 5 + Trade/TradeSignalManager.h | 5 + Trade/TradeSignalManager.struct.h | 5 + 198 files changed, 1109 insertions(+), 513 deletions(-) diff --git a/Common.define.h b/Common.define.h index 26767d7fb..0cdc7ff9f 100644 --- a/Common.define.h +++ b/Common.define.h @@ -24,7 +24,11 @@ * @file * Defines common defines. */ + #ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once + // Data types. #include typedef std::string string; diff --git a/Common.extern.h b/Common.extern.h index 433e1a994..3b2baddf9 100644 --- a/Common.extern.h +++ b/Common.extern.h @@ -22,13 +22,15 @@ // Define external global functions. #ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. #pragma once + #include #include #include "Platform/Chart/Chart.enum.h" -#include "Storage/DateTime.enum.h" #include "Platform/Terminal.define.h" +#include "Storage/DateTime.enum.h" void DebugBreak() { #ifdef _MSC_VER diff --git a/Convert.basic.h b/Convert.basic.h index 9dd8bc9b4..496e78bee 100644 --- a/Convert.basic.h +++ b/Convert.basic.h @@ -20,16 +20,16 @@ * */ -// Prevents processing this includes file for the second time. #ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. #pragma once #endif // Includes. -#include "Storage/Array.h" #include "Common.extern.h" -#include "Storage/DateTime.h" #include "Std.h" +#include "Storage/Array.h" +#include "Storage/DateTime.h" #include "Storage/String.h" /** diff --git a/Convert.extern.h b/Convert.extern.h index f7a2861fd..7ca60cbe8 100644 --- a/Convert.extern.h +++ b/Convert.extern.h @@ -20,8 +20,8 @@ * */ -// Prevents processing this includes file for the second time. #ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. #pragma once // Includes. diff --git a/EA.mqh b/EA.mqh index b878d774a..c7f8e7e29 100644 --- a/EA.mqh +++ b/EA.mqh @@ -25,29 +25,30 @@ * Implements Expert Advisor class for writing custom trading robots. */ -// Prevents processing this includes file for the second time. -#ifndef EA_MQH -#define EA_MQH +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif // Includes. -#include "Platform/Chart/Chart.h" -#include "Storage/Data.struct.h" -#include "Storage/Dict/Dict.h" -#include "Storage/Dict/DictObject.h" #include "EA.enum.h" #include "EA.struct.h" #include "Market.mqh" +#include "Platform/Chart/Chart.h" #include "Platform/Platform.h" +#include "Platform/Terminal.h" #include "Refs.struct.h" #include "Serializer/SerializerConverter.h" #include "Serializer/SerializerCsv.h" #include "Serializer/SerializerJson.h" #include "Serializer/SerializerSqlite.h" +#include "Storage/Data.struct.h" +#include "Storage/Dict/Dict.h" +#include "Storage/Dict/DictObject.h" #include "Strategy.mqh" #include "SummaryReport.mqh" #include "Task/TaskManager.h" #include "Task/Taskable.h" -#include "Platform/Terminal.h" #include "Trade.mqh" #include "Trade/TradeSignal.h" #include "Trade/TradeSignalManager.h" @@ -1145,4 +1146,3 @@ class EA : public Taskable { return SerializerNodeObject; } }; -#endif // EA_MQH diff --git a/Exchange/Account/Account.define.h b/Exchange/Account/Account.define.h index 165a588b4..db6b52a9d 100644 --- a/Exchange/Account/Account.define.h +++ b/Exchange/Account/Account.define.h @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Defines. #define ACC_OP_BALANCE 6 // Undocumented balance history statement entry. #define ACC_OP_CREDIT 7 // Undocumented credit history statement entry. diff --git a/Exchange/Account/Account.extern.h b/Exchange/Account/Account.extern.h index 678b1f5ed..fd498bf25 100644 --- a/Exchange/Account/Account.extern.h +++ b/Exchange/Account/Account.extern.h @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../../Storage/String.extern.h" #include "Account.enum.h" diff --git a/Exchange/Account/Account.h b/Exchange/Account/Account.h index a787c53c8..0bb89482e 100644 --- a/Exchange/Account/Account.h +++ b/Exchange/Account/Account.h @@ -20,13 +20,14 @@ * */ -// Prevents processing this includes file for the second time. -#ifndef ACCOUNT_H -#define ACCOUNT_H +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif // Includes. -#include "../../Storage/Dict/Buffer/BufferStruct.h" #include "../../Serializer/Serializer.h" +#include "../../Storage/Dict/Buffer/BufferStruct.h" #include "AccountBase.h" /** @@ -56,4 +57,3 @@ class Account : public AccountBase { */ ~Account() {} }; -#endif // ACCOUNT_H diff --git a/Exchange/Account/AccountBase.h b/Exchange/Account/AccountBase.h index f8191256c..4bbb31272 100644 --- a/Exchange/Account/AccountBase.h +++ b/Exchange/Account/AccountBase.h @@ -20,9 +20,10 @@ * */ -// Prevents processing this includes file for the second time. -#ifndef ACCOUNTBASE_H -#define ACCOUNTBASE_H +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif // Includes. #include "../../Refs.mqh" @@ -56,5 +57,3 @@ class AccountBase : public Dynamic { */ ~AccountBase() {} }; - -#endif // ACCOUNTBASE_H diff --git a/Exchange/Account/AccountForex.h b/Exchange/Account/AccountForex.h index e26810b62..28cd30ac0 100644 --- a/Exchange/Account/AccountForex.h +++ b/Exchange/Account/AccountForex.h @@ -20,9 +20,10 @@ * */ -// Prevents processing this includes file for the second time. -#ifndef ACCOUNTFOREX_H -#define ACCOUNTFOREX_H +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif // Includes. #include "../../Serializer/Serializer.h" @@ -53,4 +54,3 @@ class AccountForex : public Account { */ ~AccountForex() {} }; -#endif // ACCOUNTFOREX_H diff --git a/Exchange/Account/AccountMt.h b/Exchange/Account/AccountMt.h index 36f7fa12f..4d18afaec 100644 --- a/Exchange/Account/AccountMt.h +++ b/Exchange/Account/AccountMt.h @@ -20,23 +20,24 @@ * */ -// Prevents processing this includes file for the second time. -#ifndef ACCOUNT_MT_MQH -#define ACCOUNT_MT_MQH +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif // Forward class declaration. class AccountMt; // Includes. -#include "../../Storage/Array.h" -#include "../../Storage/Dict/Buffer/BufferStruct.h" #include "../../Convert.mqh" -#include "../../Storage/Data.struct.h" +#include "../../Exchange/SymbolInfo/SymbolInfo.h" #include "../../Indicator/Indicator.struct.h" #include "../../Platform/Order.struct.h" #include "../../Platform/Orders.h" #include "../../Serializer/Serializer.h" -#include "../../Exchange/SymbolInfo/SymbolInfo.h" +#include "../../Storage/Array.h" +#include "../../Storage/Data.struct.h" +#include "../../Storage/Dict/Buffer/BufferStruct.h" #include "../../Task/TaskCondition.enum.h" #include "../../Trade.struct.h" #include "Account.define.h" @@ -678,4 +679,3 @@ class AccountMt { */ static string AccountInfoString(ENUM_ACCOUNT_INFO_STRING _prop_id) { return ::AccountInfoString(_prop_id); } }; -#endif // ACCOUNT_MT_MQH diff --git a/Exchange/Exchange.h b/Exchange/Exchange.h index cefd5847b..609232c9a 100644 --- a/Exchange/Exchange.h +++ b/Exchange/Exchange.h @@ -20,17 +20,16 @@ * */ -/** - * Exchange class. - */ -#ifndef EXCHANGE_H -#define EXCHANGE_H +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif // Includes. -#include "Account/Account.h" -#include "../Storage/Dict/DictObject.h" #include "../Exchange/SymbolInfo/SymbolInfo.h" +#include "../Storage/Dict/DictObject.h" #include "../Trade.mqh" +#include "Account/Account.h" #include "Exchange.struct.h" class Exchange : public Dynamic { @@ -99,4 +98,3 @@ class Exchange : public Dynamic { */ void TradeRemove(string _name) { trades.Unset(_name); } }; -#endif // EXCHANGE_H diff --git a/Exchange/SymbolInfo/SymbolInfo.define.h b/Exchange/SymbolInfo/SymbolInfo.define.h index 74f19e889..a09cf157a 100644 --- a/Exchange/SymbolInfo/SymbolInfo.define.h +++ b/Exchange/SymbolInfo/SymbolInfo.define.h @@ -25,6 +25,11 @@ * SymbolInfo's defines. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + /* Defines */ #ifdef __MQL5__ diff --git a/Exchange/SymbolInfo/SymbolInfo.extern.h b/Exchange/SymbolInfo/SymbolInfo.extern.h index e6577ec2b..8446ebe7d 100644 --- a/Exchange/SymbolInfo/SymbolInfo.extern.h +++ b/Exchange/SymbolInfo/SymbolInfo.extern.h @@ -20,16 +20,18 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../../Platform/Order.enum.h" -#include "SymbolInfo.enum.h" #include "../../Tick/Tick.struct.h" +#include "SymbolInfo.enum.h" // Define external global functions. #ifndef __MQL__ -// Allows the preprocessor to include a header file when it is needed. -#pragma once - extern long SymbolInfoInteger(string name, ENUM_SYMBOL_INFO_INTEGER prop_id); extern bool SymbolInfoMarginRate(string name, ENUM_ORDER_TYPE order_type, double &initial_margin_rate, double &maintenance_margin_rate); diff --git a/Exchange/SymbolInfo/SymbolInfo.h b/Exchange/SymbolInfo/SymbolInfo.h index f62ed4443..1b8c889df 100644 --- a/Exchange/SymbolInfo/SymbolInfo.h +++ b/Exchange/SymbolInfo/SymbolInfo.h @@ -20,9 +20,10 @@ * */ -// Prevents processing this includes file for the second time. -#ifndef SYMBOLINFO_H -#define SYMBOLINFO_H +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif // Includes symbol defines, enums and structs. #include "SymbolInfo.define.h" @@ -561,4 +562,3 @@ class SymbolInfo : public Object { */ Log *GetLogger() { return GetPointer(logger); } }; -#endif // SYMBOLINFO_H diff --git a/Exchange/SymbolInfo/SymbolInfo.struct.static.h b/Exchange/SymbolInfo/SymbolInfo.struct.static.h index 2ab5f6257..84cc1f4cb 100644 --- a/Exchange/SymbolInfo/SymbolInfo.struct.static.h +++ b/Exchange/SymbolInfo/SymbolInfo.struct.static.h @@ -20,8 +20,8 @@ * */ -// Prevents processing this includes file for the second time. #ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. #pragma once #endif @@ -29,9 +29,9 @@ #include "../../Platform/Order.enum.h" #include "../../Platform/Platform.extern.h" #include "../../Std.h" +#include "../../Tick/Tick.struct.h" #include "SymbolInfo.enum.h" #include "SymbolInfo.extern.h" -#include "../../Tick/Tick.struct.h" /** * Struct to provide symbol information. diff --git a/File.define.h b/File.define.h index 491258389..4dd7e6bf7 100644 --- a/File.define.h +++ b/File.define.h @@ -21,6 +21,7 @@ */ // Defines. #ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. #pragma once // File constants to read the whole value of char, short or int type. diff --git a/File.extern.h b/File.extern.h index 1ba5dbba5..2d8c5f557 100644 --- a/File.extern.h +++ b/File.extern.h @@ -20,16 +20,19 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "File.define.h" +#include "Platform/Terminal.define.h" #include "Storage/MemoryFileSystem.h" #include "Storage/String.extern.h" -#include "Platform/Terminal.define.h" // Define external global functions. #ifndef __MQL__ -#pragma once - MemoryFileSystem _memfs; extern bool FileIsEnding(int file_handle); diff --git a/Indicator/Indicator.h b/Indicator/Indicator.h index cbc963777..b01f0c31a 100644 --- a/Indicator/Indicator.h +++ b/Indicator/Indicator.h @@ -20,9 +20,10 @@ * */ -// Ignore processing of this file if already included. -#ifndef INDICATOR_MQH -#define INDICATOR_MQH +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif // Forward class declaration. struct IndicatorParams; @@ -713,5 +714,3 @@ int IndicatorCounted(int _value = 0) { return prev_calculated; } #endif - -#endif diff --git a/Indicator/Indicator.struct.serialize.h b/Indicator/Indicator.struct.serialize.h index 0a3e2a67d..acb56a671 100644 --- a/Indicator/Indicator.struct.serialize.h +++ b/Indicator/Indicator.struct.serialize.h @@ -25,6 +25,11 @@ * Includes Indicator's struct serializers. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + #include "../Serializer/Serializer.h" #include "../Serializer/SerializerNode.enum.h" #include "Indicator.struct.h" diff --git a/Indicator/IndicatorCandle.h b/Indicator/IndicatorCandle.h index d071c57a1..3f53afd4c 100644 --- a/Indicator/IndicatorCandle.h +++ b/Indicator/IndicatorCandle.h @@ -20,10 +20,6 @@ * */ -// Ignore processing of this file if already included. -#ifndef INDICATOR_CANDLE_H -#define INDICATOR_CANDLE_H - #ifndef __MQL__ // Allows the preprocessor to include a header file when it is needed. #pragma once @@ -409,5 +405,3 @@ class IndicatorCandle : public Indicator { /* Virtual methods */ }; - -#endif diff --git a/Indicator/IndicatorCandle.provider.h b/Indicator/IndicatorCandle.provider.h index d0f12734e..17d46c3f5 100644 --- a/Indicator/IndicatorCandle.provider.h +++ b/Indicator/IndicatorCandle.provider.h @@ -20,10 +20,6 @@ * */ -// Ignore processing of this file if already included. -#ifndef INDICATOR_CANDLE_PROVIDER_H -#define INDICATOR_CANDLE_PROVIDER_H - #ifndef __MQL__ // Allows the preprocessor to include a header file when it is needed. #pragma once @@ -63,5 +59,3 @@ class ItemsHistoryCandleProvider : public ItemsHistoryItemProvider { */ string ToString() override { return "IndicatorTf candle provider on " + indi PTR_DEREF GetFullName(); } }; - -#endif // INDICATOR_TF_PROVIDER_H diff --git a/Indicator/IndicatorTick.h b/Indicator/IndicatorTick.h index 0dfdaa89c..017dfd4ac 100644 --- a/Indicator/IndicatorTick.h +++ b/Indicator/IndicatorTick.h @@ -20,10 +20,6 @@ * */ -// Ignore processing of this file if already included. -#ifndef INDICATOR_TICK_H -#define INDICATOR_TICK_H - #ifndef __MQL__ // Allows the preprocessor to include a header file when it is needed. #pragma once @@ -264,5 +260,3 @@ IndicatorDataEntry TickToEntry(long _timestamp, TickAB& _tick) { _entry.SetFlag(INDI_ENTRY_FLAG_IS_VALID, _tick.ask != 0 && _tick.bid != 0); return _entry; } - -#endif diff --git a/Indicator/IndicatorTick.provider.h b/Indicator/IndicatorTick.provider.h index 40c690d34..cb11c45eb 100644 --- a/Indicator/IndicatorTick.provider.h +++ b/Indicator/IndicatorTick.provider.h @@ -20,9 +20,10 @@ * */ -// Ignore processing of this file if already included. -#ifndef INDICATOR_TICK_PROVIDER_H -#define INDICATOR_TICK_PROVIDER_H +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif #ifndef __MQL__ // Allows the preprocessor to include a header file when it is needed. @@ -70,5 +71,3 @@ class ItemsHistoryTickProvider : public ItemsHistoryItemProvider> { */ string ToString() override { return "IndicatorTick tick provider on " + indi PTR_DEREF GetFullName(); } }; - -#endif // INDICATOR_TICK_PROVIDER_H diff --git a/Indicators/Bitwise/Indi_Candle.mqh b/Indicators/Bitwise/Indi_Candle.mqh index 154129dcd..af1400619 100644 --- a/Indicators/Bitwise/Indi_Candle.mqh +++ b/Indicators/Bitwise/Indi_Candle.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../../Bar.struct.h" #include "../../Indicator/Indicator.h" diff --git a/Indicators/Bitwise/Indi_Pattern.mqh b/Indicators/Bitwise/Indi_Pattern.mqh index 2b1f5ccd1..58b40c201 100644 --- a/Indicators/Bitwise/Indi_Pattern.mqh +++ b/Indicators/Bitwise/Indi_Pattern.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../../Bar.struct.h" #include "../../Indicator/Indicator.define.h" diff --git a/Indicators/Bitwise/includes.h b/Indicators/Bitwise/includes.h index f6bd6e906..740c61001 100644 --- a/Indicators/Bitwise/includes.h +++ b/Indicators/Bitwise/includes.h @@ -25,6 +25,11 @@ * Include file to include all bitwise indicators. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Bitwise indicators. #include "Indi_Candle.mqh" #include "Indi_Pattern.mqh" diff --git a/Indicators/DrawIndicator.mqh b/Indicators/DrawIndicator.mqh index 7293b5cdc..f64a5081e 100644 --- a/Indicators/DrawIndicator.mqh +++ b/Indicators/DrawIndicator.mqh @@ -25,15 +25,16 @@ * Group of functions intended for working with graphic objects relating to any specified chart. */ -// Ignore processing of this file if already included. -#ifndef DRAW_INDICATOR_MQH -#define DRAW_INDICATOR_MQH +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif // Includes. +#include "../Indicator/IndicatorBase.h" #include "../Platform/Plot.h" #include "../Storage/Dict/DictObject.h" #include "../Storage/Object.h" -#include "../Indicator/IndicatorBase.h" class DrawPoint { public: @@ -135,4 +136,3 @@ class DrawIndicator { } } }; -#endif // DRAW_INDICATOR_MQH diff --git a/Indicators/Indi_AC.mqh b/Indicators/Indi_AC.mqh index 0cd7efe82..19c1819f6 100644 --- a/Indicators/Indi_AC.mqh +++ b/Indicators/Indi_AC.mqh @@ -20,15 +20,15 @@ * */ -// Includes. -#include "../Indicator/Indicator.h" -#include "../Storage/Dict/Buffer/BufferStruct.h" - #ifndef __MQL__ // Allows the preprocessor to include a header file when it is needed. #pragma once #endif +// Includes. +#include "../Indicator/Indicator.h" +#include "../Storage/Dict/Buffer/BufferStruct.h" + // Structs. struct IndiACParams : IndicatorParams { // Struct constructor. diff --git a/Indicators/Indi_AD.mqh b/Indicators/Indi_AD.mqh index e4bb3ee92..3f94e8a57 100644 --- a/Indicators/Indi_AD.mqh +++ b/Indicators/Indi_AD.mqh @@ -20,14 +20,14 @@ * */ -// Includes. -#include "../Indicator/Indicator.h" - #ifndef __MQL__ // Allows the preprocessor to include a header file when it is needed. #pragma once #endif +// Includes. +#include "../Indicator/Indicator.h" + // Structs. struct IndiADParams : IndicatorParams { // Struct constructor. diff --git a/Indicators/Indi_ADXW.mqh b/Indicators/Indi_ADXW.mqh index 01ca8329c..6acef54b7 100644 --- a/Indicators/Indi_ADXW.mqh +++ b/Indicators/Indi_ADXW.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Indicator/Indicator.h" #include "../Storage/Dict/Buffer/BufferStruct.h" diff --git a/Indicators/Indi_AMA.mqh b/Indicators/Indi_AMA.mqh index 88bc711c6..ed71fd32f 100644 --- a/Indicators/Indi_AMA.mqh +++ b/Indicators/Indi_AMA.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Indicator/Indicator.h" #include "../Storage/Dict/Buffer/BufferStruct.h" diff --git a/Indicators/Indi_ASI.mqh b/Indicators/Indi_ASI.mqh index 8d73f734d..19e2ab77a 100644 --- a/Indicators/Indi_ASI.mqh +++ b/Indicators/Indi_ASI.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Indicator/Indicator.h" #include "../Platform/Platform.h" diff --git a/Indicators/Indi_BWMFI.mqh b/Indicators/Indi_BWMFI.mqh index 2582c2eec..62ba99039 100644 --- a/Indicators/Indi_BWMFI.mqh +++ b/Indicators/Indi_BWMFI.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Indicator/Indicator.h" diff --git a/Indicators/Indi_BWZT.mqh b/Indicators/Indi_BWZT.mqh index 0b20a06cb..2f40af8cb 100644 --- a/Indicators/Indi_BWZT.mqh +++ b/Indicators/Indi_BWZT.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Defines. // 38 bars (DATA_LIMIT) was originally specified by Indicators/Examples/BW-ZoneTrade.mq5 #define INDI_BWZT_DATA_LIMIT 100 diff --git a/Indicators/Indi_BearsPower.mqh b/Indicators/Indi_BearsPower.mqh index 475ce9b97..35e93d760 100644 --- a/Indicators/Indi_BearsPower.mqh +++ b/Indicators/Indi_BearsPower.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Indicator/Indicator.h" diff --git a/Indicators/Indi_BullsPower.mqh b/Indicators/Indi_BullsPower.mqh index 737b0bf7e..511af2f0d 100644 --- a/Indicators/Indi_BullsPower.mqh +++ b/Indicators/Indi_BullsPower.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Indicator/Indicator.h" diff --git a/Indicators/Indi_CCI.mqh b/Indicators/Indi_CCI.mqh index 418a229f4..e8c98069f 100644 --- a/Indicators/Indi_CCI.mqh +++ b/Indicators/Indi_CCI.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Indicator/Indicator.h" #include "Indi_PriceFeeder.mqh" diff --git a/Indicators/Indi_CHO.mqh b/Indicators/Indi_CHO.mqh index 16d7221b7..35d6ec999 100644 --- a/Indicators/Indi_CHO.mqh +++ b/Indicators/Indi_CHO.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Defines. // 2 bars was originally specified by Indicators/Examples/CHO.mq5 #define INDI_CHO_MIN_BARS 2 diff --git a/Indicators/Indi_CHV.mqh b/Indicators/Indi_CHV.mqh index 3119985f0..e305e0ffa 100644 --- a/Indicators/Indi_CHV.mqh +++ b/Indicators/Indi_CHV.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Indicator/Indicator.h" #include "../Storage/Dict/Buffer/BufferStruct.h" diff --git a/Indicators/Indi_ColorBars.mqh b/Indicators/Indi_ColorBars.mqh index 8ece4900b..49924e9e3 100644 --- a/Indicators/Indi_ColorBars.mqh +++ b/Indicators/Indi_ColorBars.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Indicator/Indicator.h" #include "../Storage/Dict/Buffer/BufferStruct.h" diff --git a/Indicators/Indi_ColorCandlesDaily.mqh b/Indicators/Indi_ColorCandlesDaily.mqh index 6041fbd82..0b83c596f 100644 --- a/Indicators/Indi_ColorCandlesDaily.mqh +++ b/Indicators/Indi_ColorCandlesDaily.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Indicator/Indicator.h" #include "../Storage/Dict/Buffer/BufferStruct.h" diff --git a/Indicators/Indi_ColorLine.mqh b/Indicators/Indi_ColorLine.mqh index e8210a155..99ffcbd20 100644 --- a/Indicators/Indi_ColorLine.mqh +++ b/Indicators/Indi_ColorLine.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Indicator/Indicator.h" #include "../Storage/Dict/Buffer/BufferStruct.h" diff --git a/Indicators/Indi_DEMA.mqh b/Indicators/Indi_DEMA.mqh index 922bc7ffd..9e9961003 100644 --- a/Indicators/Indi_DEMA.mqh +++ b/Indicators/Indi_DEMA.mqh @@ -20,9 +20,10 @@ * */ -// Prevents processing this includes file for the second time. -#ifndef INDI_DEMA_MQH -#define INDI_DEMA_MQH +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif // Defines. #ifdef __MQL5__ @@ -279,4 +280,3 @@ class Indi_DEMA : public Indicator { iparams.applied_price = _applied_price; } }; -#endif // INDI_DEMA_MQH diff --git a/Indicators/Indi_DeMarker.mqh b/Indicators/Indi_DeMarker.mqh index e3b7bb9aa..974befc35 100644 --- a/Indicators/Indi_DeMarker.mqh +++ b/Indicators/Indi_DeMarker.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Indicator/Indicator.h" diff --git a/Indicators/Indi_Demo.mqh b/Indicators/Indi_Demo.mqh index 25b747228..8fad53b13 100644 --- a/Indicators/Indi_Demo.mqh +++ b/Indicators/Indi_Demo.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Indicator/Indicator.h" #include "../Storage/Dict/Buffer/BufferStruct.h" diff --git a/Indicators/Indi_DetrendedPrice.mqh b/Indicators/Indi_DetrendedPrice.mqh index 75e57be62..c913d3137 100644 --- a/Indicators/Indi_DetrendedPrice.mqh +++ b/Indicators/Indi_DetrendedPrice.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Indicator/Indicator.h" #include "../Storage/Dict/Buffer/BufferStruct.h" diff --git a/Indicators/Indi_Drawer.mqh b/Indicators/Indi_Drawer.mqh index e551fd9b7..75cd23825 100644 --- a/Indicators/Indi_Drawer.mqh +++ b/Indicators/Indi_Drawer.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Indicator/Indicator.h" #include "../Storage/Dict/DictStruct.h" diff --git a/Indicators/Indi_Drawer.struct.h b/Indicators/Indi_Drawer.struct.h index 01ed8cbf2..82359ff26 100644 --- a/Indicators/Indi_Drawer.struct.h +++ b/Indicators/Indi_Drawer.struct.h @@ -25,6 +25,11 @@ * Includes Indi_Drawer's structs. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Indicator/Indicator.struct.h" #include "../Serializer/SerializerNode.enum.h" diff --git a/Indicators/Indi_Force.mqh b/Indicators/Indi_Force.mqh index 31b617982..7edf326b2 100644 --- a/Indicators/Indi_Force.mqh +++ b/Indicators/Indi_Force.mqh @@ -31,6 +31,11 @@ * 3. Trading volume. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Indicator/Indicator.h" #include "../Indicators/Price/Indi_MA.h" diff --git a/Indicators/Indi_FractalAdaptiveMA.mqh b/Indicators/Indi_FractalAdaptiveMA.mqh index 4d421d072..b5335927a 100644 --- a/Indicators/Indi_FractalAdaptiveMA.mqh +++ b/Indicators/Indi_FractalAdaptiveMA.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Indicator/Indicator.h" #include "../Storage/Dict/Buffer/BufferStruct.h" diff --git a/Indicators/Indi_Fractals.mqh b/Indicators/Indi_Fractals.mqh index d9ccf5f6c..0ab3f68ea 100644 --- a/Indicators/Indi_Fractals.mqh +++ b/Indicators/Indi_Fractals.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Indicator/Indicator.h" diff --git a/Indicators/Indi_Gator.mqh b/Indicators/Indi_Gator.mqh index 61430807c..aaa179c6e 100644 --- a/Indicators/Indi_Gator.mqh +++ b/Indicators/Indi_Gator.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + /** * @file * Gator Oscillator @@ -29,6 +34,7 @@ // Includes. #include "../Indicator/Indicator.h" +#include "../Indicators/Price/Indi_MA.h" #ifndef __MQLBUILD__ // Indicator constants. diff --git a/Indicators/Indi_HeikenAshi.mqh b/Indicators/Indi_HeikenAshi.mqh index e1b19d96f..e23be6406 100644 --- a/Indicators/Indi_HeikenAshi.mqh +++ b/Indicators/Indi_HeikenAshi.mqh @@ -27,6 +27,11 @@ * Doesn't give independent signals. Is used to define volatility (trend strength). */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Indicator/Indicator.h" #include "../Storage/ValueStorage.all.h" diff --git a/Indicators/Indi_Ichimoku.mqh b/Indicators/Indi_Ichimoku.mqh index fa568fad7..824b1fe1d 100644 --- a/Indicators/Indi_Ichimoku.mqh +++ b/Indicators/Indi_Ichimoku.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Indicator/Indicator.h" diff --git a/Indicators/Indi_Killzones.mqh b/Indicators/Indi_Killzones.mqh index 462a067ca..0711215ba 100644 --- a/Indicators/Indi_Killzones.mqh +++ b/Indicators/Indi_Killzones.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Indicator/Indicator.h" #include "../Market.struct.h" diff --git a/Indicators/Indi_MFI.mqh b/Indicators/Indi_MFI.mqh index be35d5e77..f9a809bf7 100644 --- a/Indicators/Indi_MFI.mqh +++ b/Indicators/Indi_MFI.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Indicator/Indicator.h" diff --git a/Indicators/Indi_MassIndex.mqh b/Indicators/Indi_MassIndex.mqh index 7d1013fe7..405c604f1 100644 --- a/Indicators/Indi_MassIndex.mqh +++ b/Indicators/Indi_MassIndex.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Indicator/Indicator.h" #include "../Storage/Dict/Buffer/BufferStruct.h" diff --git a/Indicators/Indi_Momentum.mqh b/Indicators/Indi_Momentum.mqh index d23b4b57d..226510ccf 100644 --- a/Indicators/Indi_Momentum.mqh +++ b/Indicators/Indi_Momentum.mqh @@ -29,6 +29,11 @@ * In addition, it can help to identify when the price action is losing steam to prepare for a potential trend reversal. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Indicator/Indicator.h" #include "Indi_PriceFeeder.mqh" diff --git a/Indicators/Indi_OBV.mqh b/Indicators/Indi_OBV.mqh index cd9378bf3..5de1ad59d 100644 --- a/Indicators/Indi_OBV.mqh +++ b/Indicators/Indi_OBV.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Indicator/Indicator.h" diff --git a/Indicators/Indi_OsMA.mqh b/Indicators/Indi_OsMA.mqh index 697d06d7c..54a1c8070 100644 --- a/Indicators/Indi_OsMA.mqh +++ b/Indicators/Indi_OsMA.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Indicator/Indicator.h" diff --git a/Indicators/Indi_PriceChannel.mqh b/Indicators/Indi_PriceChannel.mqh index bacd96f43..339470ac1 100644 --- a/Indicators/Indi_PriceChannel.mqh +++ b/Indicators/Indi_PriceChannel.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Indicator/Indicator.h" #include "../Storage/Dict/Buffer/BufferStruct.h" @@ -73,7 +78,8 @@ class Indi_PriceChannel : public Indicator { } // PC uses high and low prices only. - return _ds PTR_DEREF HasSpecificAppliedPriceValueStorage(PRICE_HIGH | PRICE_LOW); + return _ds PTR_DEREF HasSpecificAppliedPriceValueStorage(PRICE_HIGH) && + _ds PTR_DEREF HasSpecificAppliedPriceValueStorage(PRICE_LOW); } /** diff --git a/Indicators/Indi_PriceVolumeTrend.mqh b/Indicators/Indi_PriceVolumeTrend.mqh index d9a12ed71..536afd406 100644 --- a/Indicators/Indi_PriceVolumeTrend.mqh +++ b/Indicators/Indi_PriceVolumeTrend.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Defines. // 100 bars was originally specified by Indicators/Examples/PVT.mq5 #define INDI_PVT_MIN_BARS 2 diff --git a/Indicators/Indi_RS.mqh b/Indicators/Indi_RS.mqh index c5c4f5b04..e7f50f033 100644 --- a/Indicators/Indi_RS.mqh +++ b/Indicators/Indi_RS.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Indicator/Indicator.h" #include "../Storage/Dict/Buffer/BufferStruct.h" @@ -110,7 +115,7 @@ class Indi_RS : public Indicator { // Updating Maths' data sources to be the same as RS data source. imath.GetByKey(0) REF_DEREF SetDataSource(GetDataSource()); imath.GetByKey(1) REF_DEREF SetDataSource(GetDataSource()); - return imath[_mode].Ptr().GetEntryValue(); + return imath[_mode] REF_DEREF GetEntryValue(); break; default: SetUserError(ERR_INVALID_PARAMETER); diff --git a/Indicators/Indi_RVI.mqh b/Indicators/Indi_RVI.mqh index 6d5337720..09ed46293 100644 --- a/Indicators/Indi_RVI.mqh +++ b/Indicators/Indi_RVI.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Indicator/Indicator.h" diff --git a/Indicators/Indi_RateOfChange.mqh b/Indicators/Indi_RateOfChange.mqh index fe9ebebfa..609d0c447 100644 --- a/Indicators/Indi_RateOfChange.mqh +++ b/Indicators/Indi_RateOfChange.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Indicator/Indicator.h" #include "../Storage/Dict/Buffer/BufferStruct.h" diff --git a/Indicators/Indi_StdDev.mqh b/Indicators/Indi_StdDev.mqh index 5ba32d176..f588ed39e 100644 --- a/Indicators/Indi_StdDev.mqh +++ b/Indicators/Indi_StdDev.mqh @@ -27,6 +27,11 @@ * It doesn't give independent signals. Is used to define volatility (trend strength). */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Indicator/Indicator.h" #include "../Storage/Cache/ObjectsCache.h" diff --git a/Indicators/Indi_TEMA.mqh b/Indicators/Indi_TEMA.mqh index 14d98a012..f73d64973 100644 --- a/Indicators/Indi_TEMA.mqh +++ b/Indicators/Indi_TEMA.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Indicator/Indicator.h" #include "../Storage/Dict/Buffer/BufferStruct.h" diff --git a/Indicators/Indi_TRIX.mqh b/Indicators/Indi_TRIX.mqh index 880b5a7d9..5027de778 100644 --- a/Indicators/Indi_TRIX.mqh +++ b/Indicators/Indi_TRIX.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Indicator/Indicator.h" #include "../Storage/Dict/Buffer/BufferStruct.h" diff --git a/Indicators/Indi_UltimateOscillator.mqh b/Indicators/Indi_UltimateOscillator.mqh index a3b31deab..cb4a47948 100644 --- a/Indicators/Indi_UltimateOscillator.mqh +++ b/Indicators/Indi_UltimateOscillator.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Indicator/Indicator.h" #include "../Storage/Dict/Buffer/BufferStruct.h" @@ -107,9 +112,9 @@ class Indi_UltimateOscillator : public Indicator { _indi, Util::MakeKey(_fast_period, _middle_period, _slow_period, _fast_k, _middle_k, _slow_k)); // Will return Indi_ATRs with the same candles source as _indi's. - IndicatorData *_indi_atr_fast = Indi_ATR::GetCached(_indi, _fast_period); - IndicatorData *_indi_atr_middle = Indi_ATR::GetCached(_indi, _middle_period); - IndicatorData *_indi_atr_slow = Indi_ATR::GetCached(_indi, _slow_period); + Indi_ATR *_indi_atr_fast = Indi_ATR::GetCached(_indi, _fast_period); + Indi_ATR *_indi_atr_middle = Indi_ATR::GetCached(_indi, _middle_period); + Indi_ATR *_indi_atr_slow = Indi_ATR::GetCached(_indi, _slow_period); return iUOOnArray(INDICATOR_CALCULATE_POPULATED_PARAMS_LONG, _fast_period, _middle_period, _slow_period, _fast_k, _middle_k, _slow_k, _mode, _shift, _cache, _indi_atr_fast, _indi_atr_middle, _indi_atr_slow); @@ -120,8 +125,8 @@ class Indi_UltimateOscillator : public Indicator { */ static double iUOOnArray(INDICATOR_CALCULATE_PARAMS_LONG, int _fast_period, int _middle_period, int _slow_period, int _fast_k, int _middle_k, int _slow_k, int _mode, int _abs_shift, - IndiBufferCache *_cache, IndicatorData *_indi_atr_fast, - IndicatorData *_indi_atr_middle, IndicatorData *_indi_atr_slow, bool _recalculate = false) { + IndiBufferCache *_cache, Indi_ATR *_indi_atr_fast, Indi_ATR *_indi_atr_middle, + Indi_ATR *_indi_atr_slow, bool _recalculate = false) { _cache PTR_DEREF SetPriceBuffer(_open, _high, _low, _close); if (!_cache PTR_DEREF HasBuffers()) { diff --git a/Indicators/Indi_VIDYA.mqh b/Indicators/Indi_VIDYA.mqh index e6a29adb5..983878395 100644 --- a/Indicators/Indi_VIDYA.mqh +++ b/Indicators/Indi_VIDYA.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Indicator/Indicator.h" #include "../Storage/Dict/Buffer/BufferStruct.h" diff --git a/Indicators/Indi_VROC.mqh b/Indicators/Indi_VROC.mqh index 49d36f112..9dcb9cd0f 100644 --- a/Indicators/Indi_VROC.mqh +++ b/Indicators/Indi_VROC.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Indicator/Indicator.h" #include "../Storage/Dict/Buffer/BufferStruct.h" diff --git a/Indicators/Indi_Volumes.mqh b/Indicators/Indi_Volumes.mqh index a2a44227e..2552bbe8e 100644 --- a/Indicators/Indi_Volumes.mqh +++ b/Indicators/Indi_Volumes.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Defines. // 2 bars was originally specified by Indicators/Examples/Volumes.mq5 #define INDI_VOLUMES_MIN_BARS 2 diff --git a/Indicators/Indi_WilliamsAD.mqh b/Indicators/Indi_WilliamsAD.mqh index 39ae47871..8e0e131d5 100644 --- a/Indicators/Indi_WilliamsAD.mqh +++ b/Indicators/Indi_WilliamsAD.mqh @@ -20,12 +20,18 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Defines. // 2 bars was originally specified by Indicators/Examples/W_AD.mq5 #define INDI_WAD_MIN_BARS 100 // Includes. #include "../Indicator/Indicator.h" +#include "../Platform/Platform.h" #include "../Storage/Dict/Buffer/BufferStruct.h" #include "../Storage/ValueStorage.all.h" diff --git a/Indicators/Indi_ZigZag.mqh b/Indicators/Indi_ZigZag.mqh index 97efecc53..0ecadda9e 100644 --- a/Indicators/Indi_ZigZag.mqh +++ b/Indicators/Indi_ZigZag.mqh @@ -20,12 +20,18 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Defines. // 100 bars was originally specified by Indicators/Examples/ZigZag.mq5 #define INDI_ZIGZAG_MIN_BARS 100 // Includes. #include "../Indicator/Indicator.h" +#include "../Platform/Platform.h" #include "../Platform/Terminal.h" #include "../Storage/ValueStorage.all.h" @@ -115,7 +121,8 @@ class Indi_ZigZag : public Indicator { * Returns value for ZigZag indicator. */ static double iCustomZigZag(string _symbol, ENUM_TIMEFRAMES _tf, string _name, int _depth, int _deviation, - int _backstep, ENUM_ZIGZAG_LINE _mode = 0, int _shift = 0, IndicatorData *_obj = NULL) { + int _backstep, ENUM_ZIGZAG_LINE _mode = ZIGZAG_BUFFER, int _shift = 0, + IndicatorData *_obj = NULL) { #ifdef __MQL5__ int _handle = Object::IsValid(_obj) ? _obj.Get(IndicatorDataState::INDICATOR_DATA_STATE_PROP_HANDLE) : NULL; double _res[]; @@ -150,8 +157,8 @@ class Indi_ZigZag : public Indicator { /** * Returns value for ZigZag indicator. */ - static double iZigZag(IndicatorData *_indi, int _depth, int _deviation, int _backstep, ENUM_ZIGZAG_LINE _mode = 0, - int _rel_shift = 0) { + static double iZigZag(IndicatorData *_indi, int _depth, int _deviation, int _backstep, + ENUM_ZIGZAG_LINE _mode = ZIGZAG_BUFFER, int _rel_shift = 0) { INDI_REQUIRE_BARS_OR_RETURN_EMPTY(_indi, INDI_ZIGZAG_MIN_BARS); INDICATOR_CALCULATE_POPULATE_PARAMS_AND_CACHE_LONG(_indi, Util::MakeKey(_depth, _deviation, _backstep)); return iZigZagOnArray(INDICATOR_CALCULATE_POPULATED_PARAMS_LONG, _depth, _deviation, _backstep, _mode, diff --git a/Indicators/Indi_ZigZagColor.mqh b/Indicators/Indi_ZigZagColor.mqh index 5877cb0a1..cf78ae7bf 100644 --- a/Indicators/Indi_ZigZagColor.mqh +++ b/Indicators/Indi_ZigZagColor.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Defines. // 100 bars was originally specified by Indicators/Examples/ZigzagColor.mq5 #define INDI_ZIGZAG_COLOR_MIN_BARS 100 @@ -97,7 +102,7 @@ class Indi_ZigZagColor : public Indicator { * Returns value for ZigZag Color indicator. */ static double iZigZagColor(IndicatorData *_indi, int _depth, int _deviation, int _backstep, - ENUM_ZIGZAG_LINE _mode = 0, int _rel_shift = 0) { + ENUM_ZIGZAG_LINE _mode = ZIGZAG_BUFFER, int _rel_shift = 0) { INDI_REQUIRE_BARS_OR_RETURN_EMPTY(_indi, INDI_ZIGZAG_COLOR_MIN_BARS); INDICATOR_CALCULATE_POPULATE_PARAMS_AND_CACHE_LONG(_indi, Util::MakeKey(_depth, _deviation, _backstep)); return iZigZagColorOnArray(INDICATOR_CALCULATE_POPULATED_PARAMS_LONG, _depth, _deviation, _backstep, _mode, diff --git a/Indicators/OHLC/Indi_OHLC.mqh b/Indicators/OHLC/Indi_OHLC.mqh index 0dcbddc25..0f847a0af 100644 --- a/Indicators/OHLC/Indi_OHLC.mqh +++ b/Indicators/OHLC/Indi_OHLC.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../../Indicator/Indicator.h" #include "../../Storage/Dict/Buffer/BufferStruct.h" diff --git a/Indicators/OHLC/includes.h b/Indicators/OHLC/includes.h index 2c6de4d7a..8cf89dd84 100644 --- a/Indicators/OHLC/includes.h +++ b/Indicators/OHLC/includes.h @@ -25,5 +25,10 @@ * Include file to include all OHLC indicators. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // OHLC indicators. #include "Indi_OHLC.mqh" diff --git a/Indicators/Oscillator/Indi_MACD.h b/Indicators/Oscillator/Indi_MACD.h index b50ea0736..6c35a1258 100644 --- a/Indicators/Oscillator/Indi_MACD.h +++ b/Indicators/Oscillator/Indi_MACD.h @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../../Indicator/Indicator.h" diff --git a/Indicators/Oscillator/Indi_RSI.h b/Indicators/Oscillator/Indi_RSI.h index 36948b52a..4248ffcf5 100644 --- a/Indicators/Oscillator/Indi_RSI.h +++ b/Indicators/Oscillator/Indi_RSI.h @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../../Indicator/Indicator.h" #include "../../Storage/Dict/DictStruct.h" diff --git a/Indicators/Oscillator/Indi_Stochastic.h b/Indicators/Oscillator/Indi_Stochastic.h index b1e2add7f..82cbbda3c 100644 --- a/Indicators/Oscillator/Indi_Stochastic.h +++ b/Indicators/Oscillator/Indi_Stochastic.h @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../../Indicator/Indicator.h" #include "../Price/Indi_MA.h" diff --git a/Indicators/Oscillator/Indi_WPR.h b/Indicators/Oscillator/Indi_WPR.h index 41498c5c7..9795dc5c5 100644 --- a/Indicators/Oscillator/Indi_WPR.h +++ b/Indicators/Oscillator/Indi_WPR.h @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../../Indicator/Indicator.h" #include "../../Platform/Terminal.h" diff --git a/Indicators/Oscillator/includes.h b/Indicators/Oscillator/includes.h index 0b971dd52..cb4fa953b 100644 --- a/Indicators/Oscillator/includes.h +++ b/Indicators/Oscillator/includes.h @@ -25,6 +25,11 @@ * Include file to include all oscillator indicators. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Oscillator indicators. #include "Indi_MACD.h" #include "Indi_RSI.h" diff --git a/Indicators/Price/Indi_AppliedPrice.h b/Indicators/Price/Indi_AppliedPrice.h index df5249d28..8360c9342 100644 --- a/Indicators/Price/Indi_AppliedPrice.h +++ b/Indicators/Price/Indi_AppliedPrice.h @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../../Indicator/Indicator.h" #include "../../Storage/Dict/Buffer/BufferStruct.h" diff --git a/Indicators/Price/Indi_MA.h b/Indicators/Price/Indi_MA.h index 9a41ecf8a..d772382a5 100644 --- a/Indicators/Price/Indi_MA.h +++ b/Indicators/Price/Indi_MA.h @@ -20,9 +20,10 @@ * */ -// Prevents processing this includes file for the second time. -#ifndef INDI_MA_H -#define INDI_MA_H +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif // Includes. #include "../../Indicator/Indicator.h" @@ -800,5 +801,3 @@ double iMAOnArray(ARRAY_REF(double, _arr), int _total, int _period, int _ma_shif return Indi_MA::iMAOnArray(_arr, _total, _period, _ma_shift, _ma_method, _abs_shift, _cache); } #endif - -#endif // INDI_MA_H diff --git a/Indicators/Price/includes.h b/Indicators/Price/includes.h index b24e244aa..edb2924b6 100644 --- a/Indicators/Price/includes.h +++ b/Indicators/Price/includes.h @@ -25,6 +25,11 @@ * Include file to include all price indicators. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Price indicators. #include "Indi_AppliedPrice.h" #include "Indi_MA.h" diff --git a/Indicators/PriceMulti/Indi_Alligator.h b/Indicators/PriceMulti/Indi_Alligator.h index 426cbcf70..4563f0b9c 100644 --- a/Indicators/PriceMulti/Indi_Alligator.h +++ b/Indicators/PriceMulti/Indi_Alligator.h @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../../Indicator/Indicator.h" #include "../Price/Indi_MA.h" diff --git a/Indicators/PriceMulti/includes.h b/Indicators/PriceMulti/includes.h index c8112d71a..295bcd4f4 100644 --- a/Indicators/PriceMulti/includes.h +++ b/Indicators/PriceMulti/includes.h @@ -25,5 +25,10 @@ * Include file to include all price multi indicators. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Price multi indicators. #include "Indi_Alligator.h" diff --git a/Indicators/PriceRange/Indi_Bands.h b/Indicators/PriceRange/Indi_Bands.h index 6b9612347..8553fe890 100644 --- a/Indicators/PriceRange/Indi_Bands.h +++ b/Indicators/PriceRange/Indi_Bands.h @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../../Indicator/Indicator.h" #include "../Indi_CCI.mqh" diff --git a/Indicators/PriceRange/Indi_Pivot.h b/Indicators/PriceRange/Indi_Pivot.h index 427fd5382..286c3a5f6 100644 --- a/Indicators/PriceRange/Indi_Pivot.h +++ b/Indicators/PriceRange/Indi_Pivot.h @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../../Bar.struct.h" #include "../../Indicator/Indicator.struct.h" diff --git a/Indicators/PriceRange/Indi_SAR.h b/Indicators/PriceRange/Indi_SAR.h index 8f12916b3..d3248a20b 100644 --- a/Indicators/PriceRange/Indi_SAR.h +++ b/Indicators/PriceRange/Indi_SAR.h @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../../Indicator/Indicator.h" diff --git a/Indicators/PriceRange/includes.h b/Indicators/PriceRange/includes.h index b4f73d5bc..095213f65 100644 --- a/Indicators/PriceRange/includes.h +++ b/Indicators/PriceRange/includes.h @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + /** * @file * Include file to include all price range indicators. diff --git a/Indicators/Special/Indi_Custom.mqh b/Indicators/Special/Indi_Custom.mqh index 4d8984f44..3d0175c00 100644 --- a/Indicators/Special/Indi_Custom.mqh +++ b/Indicators/Special/Indi_Custom.mqh @@ -20,9 +20,10 @@ * */ -// Prevents processing the same indicator file twice. -#ifndef INDI_CUSTOM_MQH -#define INDI_CUSTOM_MQH +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif // Defines #ifndef INDI_CUSTOM_PATH @@ -127,5 +128,3 @@ class Indi_Custom : public Indicator { return _value; } }; - -#endif // INDI_CUSTOM_MQH diff --git a/Indicators/Special/Indi_Math.mqh b/Indicators/Special/Indi_Math.mqh index 0df25f3be..830d68fff 100644 --- a/Indicators/Special/Indi_Math.mqh +++ b/Indicators/Special/Indi_Math.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../../Indicator/Indicator.h" #include "../../Math/Math.enum.h" diff --git a/Indicators/Special/includes.h b/Indicators/Special/includes.h index f8c2c8624..e1124ae15 100644 --- a/Indicators/Special/includes.h +++ b/Indicators/Special/includes.h @@ -25,6 +25,11 @@ * Include file to include all special indicators. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Special indicators. #include "Indi_Custom.mqh" #include "Indi_Math.mqh" diff --git a/Indicators/Tick/Indi_TickMt.h b/Indicators/Tick/Indi_TickMt.h index 027684237..a9ec01337 100644 --- a/Indicators/Tick/Indi_TickMt.h +++ b/Indicators/Tick/Indi_TickMt.h @@ -121,7 +121,7 @@ class Indi_TickMt : public IndicatorTick, _out_ticks)) { ArrayResize(_out_ticks, 0); - static MqlTick _tmp_ticks[]; + static ARRAY(MqlTick, _tmp_ticks); ArrayResize(_tmp_ticks, 0); // There's no history in MQL4. @@ -162,7 +162,7 @@ class Indi_TickMt : public IndicatorTick class DictStruct; // Includes. +#include "File.mqh" #include "Storage/Array.h" #include "Storage/Collection.h" #include "Storage/DateTime.h" #include "Storage/Dict/DictStruct.h" -#include "File.mqh" #include "Storage/Object.h" // Define assert macros. @@ -339,5 +340,3 @@ bool Log::AddLastError(string prefix, string suffix) { bool Log::AddLastError(string prefix, long suffix) { return Add(V_ERROR, Terminal::GetLastErrorText(), prefix, StringFormat("%d", suffix)); } - -#endif diff --git a/MD5.mqh b/MD5.mqh index 6014cd14c..265f9f5f5 100644 --- a/MD5.mqh +++ b/MD5.mqh @@ -42,9 +42,14 @@ @see: http://www.cnblogs.com/niniwzw/archive/2009/12/05/1617685.html */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. -#include "Storage/Array.h" #include "Convert.basic.h" +#include "Storage/Array.h" /** * Class to provide implementation of MD5 algorithm. diff --git a/Mail.mqh b/Mail.mqh index 80fd09022..aee989e01 100644 --- a/Mail.mqh +++ b/Mail.mqh @@ -20,15 +20,16 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. -#include "Exchange/Account/AccountMt.h" #include "Convert.mqh" +#include "Exchange/Account/AccountMt.h" #include "Platform/Order.h" -// Prevents processing this includes file for the second time. -#ifndef MAIL_MQH -#define MAIL_MQH - /** * Implements Mail class. */ @@ -136,4 +137,3 @@ class Mail { */ bool SendMailExecuteOrder() { return SendMail(GetMailSubjectExecuteOrder(), GetMailBodyExecuteOrder()); } }; -#endif diff --git a/Market.struct.h b/Market.struct.h index 361985015..76580f027 100644 --- a/Market.struct.h +++ b/Market.struct.h @@ -25,14 +25,19 @@ * Includes Market's structs. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Forward declaration. class Serializer; // Includes. -#include "Storage/DateTime.entry.h" -#include "Storage/DateTime.struct.h" #include "Serializer/SerializerNode.enum.h" #include "Std.h" +#include "Storage/DateTime.entry.h" +#include "Storage/DateTime.struct.h" // Market info. struct MarketData { diff --git a/Math/Math.extern.h b/Math/Math.extern.h index 637a790c7..9248b9253 100644 --- a/Math/Math.extern.h +++ b/Math/Math.extern.h @@ -22,6 +22,7 @@ // Define external global functions. #ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. #pragma once #include diff --git a/Math/Matrix.h b/Math/Matrix.h index 06e89cbf4..57fa065d5 100644 --- a/Math/Matrix.h +++ b/Math/Matrix.h @@ -20,9 +20,10 @@ * */ -// Prevents processing this includes file for the second time. -#ifndef MATRIX_MQH -#define MATRIX_MQH +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif #ifdef USE_MQL_MATH_STAT #ifdef __MQL5__ @@ -2262,5 +2263,3 @@ class Matrix { return _out + "]"; } }; - -#endif diff --git a/Math/MatrixMini.h b/Math/MatrixMini.h index d4371b581..134d092d2 100644 --- a/Math/MatrixMini.h +++ b/Math/MatrixMini.h @@ -20,9 +20,10 @@ * */ -// Prevents processing this includes file for the second time. -#ifndef MINIMATRIX_H -#define MINIMATRIX_H +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif // Includes. #include "../Platform/Platform.extern.h" @@ -59,5 +60,3 @@ class MatrixMini2d { int SizeY() { return size_y; } }; - -#endif // MINIMATRIX_H diff --git a/Pattern.mqh b/Pattern.mqh index 2990db07c..7cc828192 100644 --- a/Pattern.mqh +++ b/Pattern.mqh @@ -24,6 +24,11 @@ * Provides functionality for detecting candle patterns. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "Pattern.struct.h" diff --git a/Platform/Chart/Chart.define.h b/Platform/Chart/Chart.define.h index 18af886c7..f2a7afe9d 100644 --- a/Platform/Chart/Chart.define.h +++ b/Platform/Chart/Chart.define.h @@ -25,6 +25,11 @@ * Terminal's defines. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + /* Defines */ // Define type of timeframe periods using bitwise values. diff --git a/Platform/Chart/Chart.h b/Platform/Chart/Chart.h index 56a499281..50893cdc2 100644 --- a/Platform/Chart/Chart.h +++ b/Platform/Chart/Chart.h @@ -29,19 +29,20 @@ * - https://www.mql5.com/en/docs/series */ -// Prevents processing this includes file for the second time. -#ifndef CHART_H -#define CHART_H +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif // Includes. -#include "Chart.define.h" -#include "Chart.enum.h" -#include "Chart.struct.h" -#include "Chart.struct.serialize.h" #include "../../Convert.mqh" #include "../../Market.mqh" #include "../../Serializer/Serializer.h" #include "../../Task/TaskCondition.enum.h" +#include "Chart.define.h" +#include "Chart.enum.h" +#include "Chart.struct.h" +#include "Chart.struct.serialize.h" // Forward class declaration. class Chart; @@ -182,5 +183,3 @@ class Chart : public Market { void SerializeStub(int _n1 = 1, int _n2 = 1, int _n3 = 1, int _n4 = 1, int _n5 = 1) {} }; - -#endif // CHART_H diff --git a/Platform/Chart/Chart.struct.serialize.h b/Platform/Chart/Chart.struct.serialize.h index 8c2b9205b..d5079527f 100644 --- a/Platform/Chart/Chart.struct.serialize.h +++ b/Platform/Chart/Chart.struct.serialize.h @@ -25,6 +25,11 @@ * Includes Chart's struct serializers. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Forward class declaration. class Serializer; diff --git a/Platform/Chart3D/Chart3D.h b/Platform/Chart3D/Chart3D.h index d97115759..a95a9cf97 100644 --- a/Platform/Chart3D/Chart3D.h +++ b/Platform/Chart3D/Chart3D.h @@ -25,6 +25,11 @@ * 3D Chart. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + #include "../../Bar.struct.h" #include "../../Indicator/IndicatorData.h" #include "../../Indicators/Price/Indi_MA.h" diff --git a/Platform/Chart3D/Chart3DCandles.h b/Platform/Chart3D/Chart3DCandles.h index 3344b8682..ff532ecdf 100644 --- a/Platform/Chart3D/Chart3DCandles.h +++ b/Platform/Chart3D/Chart3DCandles.h @@ -25,6 +25,11 @@ * 3D chart candles renderer. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + #include "../Chart/Chart.define.h" #include "Chart3DType.h" #include "Cube.h" diff --git a/Platform/Chart3D/Chart3DType.h b/Platform/Chart3D/Chart3DType.h index 588d596f8..1a753e7ed 100644 --- a/Platform/Chart3D/Chart3DType.h +++ b/Platform/Chart3D/Chart3DType.h @@ -25,6 +25,11 @@ * 3D chart type renderer. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + #include "../../Refs.mqh" #include "Device.h" diff --git a/Platform/Chart3D/Cube.h b/Platform/Chart3D/Cube.h index 5e6b1d6e1..d3715a1bd 100644 --- a/Platform/Chart3D/Cube.h +++ b/Platform/Chart3D/Cube.h @@ -25,6 +25,11 @@ * Cube mesh. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + #include "Face.h" #include "Mesh.h" diff --git a/Platform/Chart3D/Device.h b/Platform/Chart3D/Device.h index b28c55ce8..7ac435633 100644 --- a/Platform/Chart3D/Device.h +++ b/Platform/Chart3D/Device.h @@ -25,6 +25,11 @@ * Generic graphics device. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + #include "../../Refs.mqh" #include "../../Util.h" #include "Frontend.h" diff --git a/Platform/Chart3D/Devices/MTDX/MTDXDevice.h b/Platform/Chart3D/Devices/MTDX/MTDXDevice.h index 8e0c6554f..713c7a407 100644 --- a/Platform/Chart3D/Devices/MTDX/MTDXDevice.h +++ b/Platform/Chart3D/Devices/MTDX/MTDXDevice.h @@ -25,6 +25,11 @@ * MetaTrader DX-targeted graphics device. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + #include "../../Device.h" class MTDXDevice : public Device { diff --git a/Platform/Chart3D/Devices/MTDX/MTDXIndexBuffer.h b/Platform/Chart3D/Devices/MTDX/MTDXIndexBuffer.h index 43ddbfccb..924651dbf 100644 --- a/Platform/Chart3D/Devices/MTDX/MTDXIndexBuffer.h +++ b/Platform/Chart3D/Devices/MTDX/MTDXIndexBuffer.h @@ -25,6 +25,11 @@ * MetaTrader DX-targeted graphics device's index buffer. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + #include "../../IndexBuffer.h" class MTDXIndexBuffer : public IndexBuffer { diff --git a/Platform/Chart3D/Devices/MTDX/MTDXShader.h b/Platform/Chart3D/Devices/MTDX/MTDXShader.h index ff75425a8..9fb0109b4 100644 --- a/Platform/Chart3D/Devices/MTDX/MTDXShader.h +++ b/Platform/Chart3D/Devices/MTDX/MTDXShader.h @@ -25,6 +25,11 @@ * MetaTrader DX-targeted unversal graphics shader. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + #include "../../Shader.h" class MTDXShader : public Shader { diff --git a/Platform/Chart3D/Devices/MTDX/MTDXVertexBuffer.h b/Platform/Chart3D/Devices/MTDX/MTDXVertexBuffer.h index 3a6163f4e..5af0b8405 100644 --- a/Platform/Chart3D/Devices/MTDX/MTDXVertexBuffer.h +++ b/Platform/Chart3D/Devices/MTDX/MTDXVertexBuffer.h @@ -25,6 +25,11 @@ * MetaTrader DX-targeted graphics vertex buffer. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + #include "../../VertexBuffer.h" class MTDXVertexBuffer : public VertexBuffer { diff --git a/Platform/Chart3D/Face.h b/Platform/Chart3D/Face.h index c298cfb9e..4a1bab0ee 100644 --- a/Platform/Chart3D/Face.h +++ b/Platform/Chart3D/Face.h @@ -25,6 +25,11 @@ * Generic graphics face object. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + #include "Math.h" // Face flags. diff --git a/Platform/Chart3D/Frontend.h b/Platform/Chart3D/Frontend.h index 52a316a2e..19e301b7f 100644 --- a/Platform/Chart3D/Frontend.h +++ b/Platform/Chart3D/Frontend.h @@ -25,6 +25,11 @@ * Generic graphics front-end (display buffer target). */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + #include "../../Refs.mqh" struct DrawTextQueueItem { diff --git a/Platform/Chart3D/Frontends/MT5Frontend.h b/Platform/Chart3D/Frontends/MT5Frontend.h index 7f5532550..094f16b01 100644 --- a/Platform/Chart3D/Frontends/MT5Frontend.h +++ b/Platform/Chart3D/Frontends/MT5Frontend.h @@ -25,6 +25,11 @@ * MT5 graphics front-end (display buffer target). */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + #include "../Frontend.h" /** diff --git a/Platform/Chart3D/IndexBuffer.h b/Platform/Chart3D/IndexBuffer.h index e628369ab..789aca763 100644 --- a/Platform/Chart3D/IndexBuffer.h +++ b/Platform/Chart3D/IndexBuffer.h @@ -25,6 +25,11 @@ * Generic graphics index buffer. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + #include "../../Refs.mqh" class Device; diff --git a/Platform/Chart3D/Interface.h b/Platform/Chart3D/Interface.h index 27d56457e..c833094f3 100644 --- a/Platform/Chart3D/Interface.h +++ b/Platform/Chart3D/Interface.h @@ -25,6 +25,11 @@ * Chart events. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + #include "../../Util.h" enum ENUM_INTERFACE_EVENT { diff --git a/Platform/Chart3D/Material.h b/Platform/Chart3D/Material.h index 6c084ca8c..43c5313a3 100644 --- a/Platform/Chart3D/Material.h +++ b/Platform/Chart3D/Material.h @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + #include "Math.h" /** diff --git a/Platform/Chart3D/Math.h b/Platform/Chart3D/Math.h index 8db6be380..78c283976 100644 --- a/Platform/Chart3D/Math.h +++ b/Platform/Chart3D/Math.h @@ -3,6 +3,11 @@ //| Copyright 2019,MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + #ifdef __MQL__ #property copyright "Copyright 2019,MetaQuotes Software Corp." #property link "https://www.mql5.com" diff --git a/Platform/Chart3D/Mesh.h b/Platform/Chart3D/Mesh.h index d962ab138..cf8a200d0 100644 --- a/Platform/Chart3D/Mesh.h +++ b/Platform/Chart3D/Mesh.h @@ -25,8 +25,13 @@ * Generic graphics mesh. */ -#include "../../Storage/Dict/Dict.h" +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + #include "../../Refs.mqh" +#include "../../Storage/Dict/Dict.h" #include "../../Util.h" #include "Face.h" #include "IndexBuffer.h" diff --git a/Platform/Chart3D/Shader.h b/Platform/Chart3D/Shader.h index 05e237d63..51eefccc6 100644 --- a/Platform/Chart3D/Shader.h +++ b/Platform/Chart3D/Shader.h @@ -25,6 +25,11 @@ * Generic graphics shader. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + #include "../../Refs.mqh" // Shader type. diff --git a/Platform/Chart3D/ShaderVertexLayout.struct.h b/Platform/Chart3D/ShaderVertexLayout.struct.h index f6332e9c5..026d2d8a6 100644 --- a/Platform/Chart3D/ShaderVertexLayout.struct.h +++ b/Platform/Chart3D/ShaderVertexLayout.struct.h @@ -25,6 +25,11 @@ * Defines ShaderVertexLayout structure. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Vertex layout used for Vertex Shaders. struct ShaderVertexLayout { string name; diff --git a/Platform/Chart3D/TSR.h b/Platform/Chart3D/TSR.h index e6843e449..2d487df24 100644 --- a/Platform/Chart3D/TSR.h +++ b/Platform/Chart3D/TSR.h @@ -25,6 +25,11 @@ * Translations, scale and rotation matrices. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + #include "Math.h" class TSR { diff --git a/Platform/Chart3D/Vertex.h b/Platform/Chart3D/Vertex.h index 29965fcef..65e9248b0 100644 --- a/Platform/Chart3D/Vertex.h +++ b/Platform/Chart3D/Vertex.h @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + #include "../../Refs.mqh" /** diff --git a/Platform/Chart3D/VertexBuffer.h b/Platform/Chart3D/VertexBuffer.h index 3e7567ae1..8cea3b09d 100644 --- a/Platform/Chart3D/VertexBuffer.h +++ b/Platform/Chart3D/VertexBuffer.h @@ -25,6 +25,11 @@ * Generic graphics vertex buffer. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + #include "../../Refs.mqh" class VertexBuffer : public Dynamic { diff --git a/Platform/Order.define.h b/Platform/Order.define.h index af96f14ef..f002027c3 100644 --- a/Platform/Order.define.h +++ b/Platform/Order.define.h @@ -25,6 +25,11 @@ * Includes Order's defines. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + #ifndef __MQL4__ // Mode constants. #define MODE_TRADES 0 diff --git a/Platform/Order.h b/Platform/Order.h index 4e0f14a19..d15186ff5 100644 --- a/Platform/Order.h +++ b/Platform/Order.h @@ -25,30 +25,31 @@ * Implements class for managing orders. */ -// Prevents processing this includes file for the second time. -#ifndef ORDER_MQH -#define ORDER_MQH +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif // Forward declaration. class SymbolInfo; // Includes. #include "../Convert.mqh" -#include "../Storage/Data.define.h" -#include "../Storage/Data.struct.h" -#include "Deal.enum.h" +#include "../Exchange/SymbolInfo/SymbolInfo.h" #include "../Log.mqh" -#include "Order.define.h" -#include "Order.enum.h" -#include "Order.struct.h" #include "../Serializer/Serializer.define.h" #include "../Serializer/Serializer.h" #include "../Serializer/SerializerConverter.h" #include "../Serializer/SerializerJson.h" #include "../Std.h" +#include "../Storage/Data.define.h" +#include "../Storage/Data.struct.h" #include "../Storage/String.h" -#include "../Exchange/SymbolInfo/SymbolInfo.h" #include "../Task/TaskAction.enum.h" +#include "Deal.enum.h" +#include "Order.define.h" +#include "Order.enum.h" +#include "Order.struct.h" /* Defines for backward compatibility. */ @@ -2909,5 +2910,3 @@ class Order : public SymbolInfo { ENUM_ORDER_SELECT_TYPE Order::selected_ticket_type = ORDER_SELECT_TYPE_NONE; unsigned long Order::selected_ticket_id = 0; #endif - -#endif // ORDER_MQH diff --git a/Platform/OrderQuery.h b/Platform/OrderQuery.h index 412740df1..c76f485e5 100644 --- a/Platform/OrderQuery.h +++ b/Platform/OrderQuery.h @@ -25,11 +25,16 @@ * Implements class for querying list of orders. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. -#include "../Storage/Dict/DictStruct.h" -#include "Order.h" #include "../Refs.mqh" #include "../Std.h" +#include "../Storage/Dict/DictStruct.h" +#include "Order.h" class OrderQuery : public Dynamic { protected: diff --git a/Platform/Orders.h b/Platform/Orders.h index 6341f2002..42279c9fd 100644 --- a/Platform/Orders.h +++ b/Platform/Orders.h @@ -20,18 +20,23 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Forward declarations. class Orders; // Includes. #include "../Exchange/Account/Account.h" #include "../Exchange/SymbolInfo/SymbolInfo.struct.static.h" -#include "Chart/Chart.struct.static.h" #include "../Log.mqh" #include "../Math/Math.h" +#include "../Trade.struct.h" +#include "Chart/Chart.struct.static.h" #include "Order.h" #include "Terminal.h" -#include "../Trade.struct.h" /* Defines */ diff --git a/Platform/Platform.extern.h b/Platform/Platform.extern.h index 36ed84b64..b9c93db05 100644 --- a/Platform/Platform.extern.h +++ b/Platform/Platform.extern.h @@ -25,6 +25,8 @@ #pragma once // Includes. +#include + #include "../Exchange/Account/Account.enum.h" #include "../Storage/Data.define.h" #include "../Storage/DateTime.h" @@ -32,12 +34,14 @@ #include "Deal.enum.h" #include "Order.define.h" #include "Order.enum.h" +#include "Platform.enum.h" #include "Terminal.enum.h" // Forward declarations. struct MqlTradeRequest; struct MqlTradeResult; struct MqlTradeCheckResult; +struct MqlTick; template double iCustom(string symbol, int timeframe, string name, Args... args) { @@ -182,4 +186,12 @@ int GetLastError() { return _LastError; } void ResetLastError() { _LastError = 0; } +int CopyTicks(const string symbol_name, ARRAY_REF(MqlTick, ticks_array), unsigned int flags = COPY_TICKS_ALL, + int64 from = 0, unsigned int count = 0); + +int CopyTicksRange(const string symbol_name, ARRAY_REF(MqlTick, ticks_array), unsigned int flags = COPY_TICKS_ALL, + int64 from_msc = 0, int64 to_msc = 0); + +void Sleep(int milliseconds) { std::this_thread::sleep_for(std::chrono::milliseconds(milliseconds)); } + #endif diff --git a/Platform/PlatformTime.h b/Platform/PlatformTime.h index 1588185dc..73e16008c 100644 --- a/Platform/PlatformTime.h +++ b/Platform/PlatformTime.h @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Storage/DateTime.enum.h" #include "../Storage/DateTime.struct.h" @@ -29,7 +34,6 @@ * Platform time retrieval. */ #ifndef __MQL__ -#pragma once // Includes. #include diff --git a/Platform/Plot.h b/Platform/Plot.h index 3d630769f..d2f8aa64e 100644 --- a/Platform/Plot.h +++ b/Platform/Plot.h @@ -25,6 +25,11 @@ * Group of functions intended for working with graphic objects relating to any specified chart. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Class dependencies. class Chart; class Plot; diff --git a/Platform/Terminal.define.h b/Platform/Terminal.define.h index fb94241be..475c938c5 100644 --- a/Platform/Terminal.define.h +++ b/Platform/Terminal.define.h @@ -25,6 +25,11 @@ * Terminal's defines. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + /* Defines */ // Codepages. diff --git a/Platform/Terminal.h b/Platform/Terminal.h index 1103cafc1..f720c9e00 100644 --- a/Platform/Terminal.h +++ b/Platform/Terminal.h @@ -29,18 +29,19 @@ * - https://www.mql5.com/en/docs/chart_operations */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Forward declaration. class Terminal; -// Prevents processing this includes file for the second time. -#ifndef TERMINAL_MQH -#define TERMINAL_MQH - // Includes. #include "../Convert.mqh" +#include "../Refs.mqh" #include "../Storage/Data.struct.h" #include "../Storage/Object.h" -#include "../Refs.mqh" #include "../Storage/String.h" #include "Terminal.define.h" #include "Terminal.enum.h" @@ -967,5 +968,3 @@ class Terminal : public Object { // @docs: https://docs.mql4.com/chart_operations/windowexpertname string WindowExpertName(void) { return Terminal::WindowExpertName(); } #endif - -#endif // TERMINAL_MQH diff --git a/Platform/Web/Web.h b/Platform/Web/Web.h index 65bb3ed9f..fb1e27097 100644 --- a/Platform/Web/Web.h +++ b/Platform/Web/Web.h @@ -23,12 +23,10 @@ // Properties. #ifdef __MQL__ #property strict +// Allows the preprocessor to include a header file when it is needed. +#pragma once #endif -// Prevents processing this includes file for the second time. -#ifndef WEB_MQH -#define WEB_MQH - // Includes. #include "../../Platform/Platform.h" @@ -84,4 +82,3 @@ class Web { return _res; } }; -#endif diff --git a/Profiler.mqh b/Profiler.mqh index 7f5e7710a..fed207d91 100644 --- a/Profiler.mqh +++ b/Profiler.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "Storage/Collection.h" #include "Timer.mqh" diff --git a/Report.mqh b/Report.mqh index 991cc2919..081182a5d 100644 --- a/Report.mqh +++ b/Report.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "Storage/DateTime.h" #include "Storage/String.h" @@ -28,33 +33,31 @@ * Class to provide report handling methods. */ class Report { -public: - - // Used for writing the report file. - string log[]; - - /* - * Add message into the report file. - */ - void ReportAdd(string msg) { - int last = ArraySize(log); - ArrayResize(log, last + 1); - log[last] = DateTimeStatic::TimeToStr(TimeCurrent(), TIME_DATE|TIME_SECONDS) + ": " + msg; - } - - /* - * Write report data into file. - */ - static void WriteReport(string filename, string data, bool verbose = false) { - int handle = FileOpen(filename, FILE_CSV|FILE_WRITE, '\t'); - if (handle < 1) return; - - FileWrite(handle, data); - FileClose(handle); - - if (verbose) { - String::PrintText(data); - } + public: + // Used for writing the report file. + string log[]; + + /* + * Add message into the report file. + */ + void ReportAdd(string msg) { + int last = ArraySize(log); + ArrayResize(log, last + 1); + log[last] = DateTimeStatic::TimeToStr(TimeCurrent(), TIME_DATE | TIME_SECONDS) + ": " + msg; + } + + /* + * Write report data into file. + */ + static void WriteReport(string filename, string data, bool verbose = false) { + int handle = FileOpen(filename, FILE_CSV | FILE_WRITE, '\t'); + if (handle < 1) return; + + FileWrite(handle, data); + FileClose(handle); + + if (verbose) { + String::PrintText(data); } - + } }; diff --git a/Serializer/Serializer.define.h b/Serializer/Serializer.define.h index bff8d7f1c..fc8660f72 100644 --- a/Serializer/Serializer.define.h +++ b/Serializer/Serializer.define.h @@ -25,6 +25,11 @@ * Serializer's defines. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + /* Defines */ #ifdef __MQL__ diff --git a/Serializer/Serializer.h b/Serializer/Serializer.h index 128a1c9ac..0cadf3e2c 100644 --- a/Serializer/Serializer.h +++ b/Serializer/Serializer.h @@ -20,9 +20,10 @@ * */ -// Prevents processing this includes file for the second time. -#ifndef SERIALIZER_MQH -#define SERIALIZER_MQH +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif // Includes. #include "../Convert.basic.h" @@ -474,5 +475,3 @@ class Serializer { return Struct(key); } }; - -#endif // End: SERIALIZER_MQH diff --git a/Serializer/SerializerBinary.h b/Serializer/SerializerBinary.h index 789c9adeb..e5e94e9e5 100644 --- a/Serializer/SerializerBinary.h +++ b/Serializer/SerializerBinary.h @@ -20,9 +20,10 @@ * */ -// Prevents processing this includes file for the second time. -#ifndef SERIALIZER_BINARY_MQH -#define SERIALIZER_BINARY_MQH +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif // Includes. #include "../Storage/Dict/DictBase.h" @@ -129,5 +130,3 @@ class SerializerBinary { return NULL; } }; - -#endif diff --git a/Serializer/SerializerConverter.h b/Serializer/SerializerConverter.h index 0c46435e8..c9d883c05 100644 --- a/Serializer/SerializerConverter.h +++ b/Serializer/SerializerConverter.h @@ -25,10 +25,6 @@ #pragma once #endif -// Prevents processing this includes file for the second time. -#ifndef SERIALIZER_CONVERTER_MQH -#define SERIALIZER_CONVERTER_MQH - // Forward declarations. class SerializerNode; @@ -226,5 +222,3 @@ class SerializerConverter { return SerializerConverter::FromObject(stub, _serializer_flags); } }; - -#endif diff --git a/Serializer/SerializerCsv.h b/Serializer/SerializerCsv.h index 46352f157..5b7d718c5 100644 --- a/Serializer/SerializerCsv.h +++ b/Serializer/SerializerCsv.h @@ -20,16 +20,17 @@ * */ -// Prevents processing this includes file for the second time. -#ifndef SERIALIZER_CSV_MQH -#define SERIALIZER_CSV_MQH +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif // Includes. +#include "../Math/Matrix.h" +#include "../Math/MatrixMini.h" #include "../Storage/Dict/Dict.h" #include "../Storage/Dict/DictObject.h" #include "../Storage/Dict/DictStruct.h" -#include "../Math/Matrix.h" -#include "../Math/MatrixMini.h" #include "../Storage/Object.h" #include "SerializerConverter.h" #include "SerializerNode.h" @@ -292,5 +293,3 @@ class SerializerCsv { return true; } }; - -#endif diff --git a/Serializer/SerializerDict.h b/Serializer/SerializerDict.h index 647a7ab3d..7235ffc50 100644 --- a/Serializer/SerializerDict.h +++ b/Serializer/SerializerDict.h @@ -20,9 +20,10 @@ * */ -// Prevents processing this includes file for the second time. -#ifndef SERIALIZER_DICT_MQH -#define SERIALIZER_DICT_MQH +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif // Includes. #include "SerializerNode.h" @@ -46,5 +47,3 @@ class SerializerDict { } } }; - -#endif diff --git a/Serializer/SerializerJson.h b/Serializer/SerializerJson.h index 682fbf919..0de0effbb 100644 --- a/Serializer/SerializerJson.h +++ b/Serializer/SerializerJson.h @@ -20,9 +20,10 @@ * */ -// Prevents processing this includes file for the second time. -#ifndef SERIALIZER_JSON_MQH -#define SERIALIZER_JSON_MQH +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif // Includes. #include "../Storage/Dict/DictBase.h" @@ -392,5 +393,3 @@ class SerializerJson { return NULL; } }; - -#endif diff --git a/Serializer/SerializerNode.h b/Serializer/SerializerNode.h index d4eb4cf63..6619bd216 100644 --- a/Serializer/SerializerNode.h +++ b/Serializer/SerializerNode.h @@ -20,9 +20,10 @@ * */ -// Prevents processing this includes file for the second time. -#ifndef SERIALIZER_NODE_H -#define SERIALIZER_NODE_H +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif // Includes. #include "../Math/Math.extern.h" @@ -367,5 +368,3 @@ class SerializerNode { return repr; } }; - -#endif // SERIALIZER_NODE_H diff --git a/Serializer/SerializerNodeIterator.h b/Serializer/SerializerNodeIterator.h index a20a8fb4a..9a816d349 100644 --- a/Serializer/SerializerNodeIterator.h +++ b/Serializer/SerializerNodeIterator.h @@ -20,9 +20,10 @@ * */ -// Prevents processing this includes file for the second time. -#ifndef SERIALIZER_NODE_ITERATOR_H -#define SERIALIZER_NODE_ITERATOR_H +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif #include "Serializer.h" #include "SerializerNode.h" @@ -111,5 +112,3 @@ class SerializerIterator : public SerializerNodeIterator { SerializerNodeType ParentNodeType() { return _collection PTR_DEREF GetType(); } }; - -#endif diff --git a/Serializer/SerializerNodeParam.h b/Serializer/SerializerNodeParam.h index 147be46f4..c5718a179 100644 --- a/Serializer/SerializerNodeParam.h +++ b/Serializer/SerializerNodeParam.h @@ -20,11 +20,12 @@ * */ -// Prevents processing this includes file for the second time. -#include "SerializerConversions.h" +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif -#ifndef SERIALIZER_NODE_PARAM_H -#define SERIALIZER_NODE_PARAM_H +#include "SerializerConversions.h" /** * Enumeration. @@ -333,5 +334,3 @@ SerializerNodeParam* SerializerNodeParam::FromString(string& value) { PTR_ATTRIB(param, _string) = value; return param; } - -#endif // SERIALIZER_NODE_PARAM_H diff --git a/Serializer/SerializerObject.h b/Serializer/SerializerObject.h index a1132e5c0..e42585f05 100644 --- a/Serializer/SerializerObject.h +++ b/Serializer/SerializerObject.h @@ -20,9 +20,10 @@ * */ -// Prevents processing this includes file for the second time. -#ifndef SERIALIZER_OBJECT_MQH -#define SERIALIZER_OBJECT_MQH +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif // Includes. #include "../Storage/Dict/DictBase.h" @@ -37,5 +38,3 @@ class SerializerObject { public: static string Stringify(SerializerNode* _root) { return ""; } }; - -#endif diff --git a/Serializer/SerializerSqlite.h b/Serializer/SerializerSqlite.h index 01eab37e0..291c468cb 100644 --- a/Serializer/SerializerSqlite.h +++ b/Serializer/SerializerSqlite.h @@ -20,9 +20,10 @@ * */ -// Prevents processing this includes file for the second time. -#ifndef SERIALIZER_SQL_MQH -#define SERIALIZER_SQL_MQH +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif // Includes. #include "../Storage/Database.h" @@ -91,5 +92,3 @@ class SerializerSqlite { return true; } }; - -#endif diff --git a/SetFile.mqh b/SetFile.mqh index e7d8d802d..39e32abb4 100644 --- a/SetFile.mqh +++ b/SetFile.mqh @@ -20,151 +20,140 @@ * */ -class SetFile { - struct SetFileData - { - string key; - string val; - }; - - int handle, count; - SetFileData array[]; - - public: - - bool LoadFromFile(string path) { - handle = FileOpen(path, FILE_READ|FILE_CSV|FILE_ANSI, '='); - - if (handle == INVALID_HANDLE) { - //PrintFormat("Failed to open %s file, Error code = %d", handle,GetLastError()); - FileClose(handle); - return true; - } - - if (FileSize(handle) == 0) { - //PrintFormat("Failed to open %s file, Error code = %d", handle,GetLastError()); - FileClose(handle); - return false; - } - - count = 0; - while(FileIsEnding(handle)==false) - { - ArrayResize(array,(count+1),100000); - - array[count].key = FileReadString(handle); - array[count].val = FileReadString(handle); - count++; - } - - FileClose(handle); - - return true; - } - - string GetValueString (string key) { - - for (int i = 0; i <= ArraySize(array); i++) - { - if (array[i].key == key) - { - return(array[i].val); - break; - } - } - - return(NULL); - } - - int GetValueInteger (string key) { - string value = GetValueString(key); - - if(value != NULL) { - #ifdef MQL4 - return(StrToInteger(value)); - #else - return((int) StringToInteger(value)); - #endif - } else { - return(NULL); - } - } - - double GetValueDouble (string key) { - string value = GetValueString(key); - - if(value != NULL) { - #ifdef MQL4 - return(StrToDouble(value)); - #else - return(StringToDouble(value)); - #endif - } else { - return(NULL); - } - } - - bool SetValue (string key, string value) { - - int i = 0; - for (;i <= ArraySize(array); i++) - { - if (array[i].key == key) - { - array[i].val = value; - return true; - break; - } - } - - ArrayResize(array,(i+2),100000); - - array[(i + 1)].key = key; - array[(i + 1)].val = value; - - return true; - } - - bool SetValue (string key, double value) { - - int i = 0; - for (;i <= ArraySize(array); i++) - { - if (array[i].key == key) - { - array[i].val = DoubleToString(value); - return true; - break; - } - } - - ArrayResize(array,(i+2),100000); - - array[(i + 1)].key = key; - array[(i + 1)].val = DoubleToString(value); - - return true; - } - - bool SetValue (string key, int value) { - - int i = 0; - for (;i <= ArraySize(array); i++) - { - if (array[i].key == key) - { - array[i].val = IntegerToString(value); - return true; - break; - } - } - - ArrayResize(array,(i+2),100000); - - array[(i + 1)].key = key; - array[(i + 1)].val = IntegerToString(value); - - return true; - } +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif +class SetFile { + struct SetFileData { + string key; + string val; + }; + + int handle, count; + SetFileData array[]; + + public: + bool LoadFromFile(string path) { + handle = FileOpen(path, FILE_READ | FILE_CSV | FILE_ANSI, '='); + + if (handle == INVALID_HANDLE) { + // PrintFormat("Failed to open %s file, Error code = %d", handle,GetLastError()); + FileClose(handle); + return true; + } + + if (FileSize(handle) == 0) { + // PrintFormat("Failed to open %s file, Error code = %d", handle,GetLastError()); + FileClose(handle); + return false; + } + + count = 0; + while (FileIsEnding(handle) == false) { + ArrayResize(array, (count + 1), 100000); + + array[count].key = FileReadString(handle); + array[count].val = FileReadString(handle); + count++; + } + + FileClose(handle); + + return true; + } + + string GetValueString(string key) { + for (int i = 0; i <= ArraySize(array); i++) { + if (array[i].key == key) { + return (array[i].val); + break; + } + } + + return (NULL); + } + + int GetValueInteger(string key) { + string value = GetValueString(key); + + if (value != NULL) { +#ifdef MQL4 + return (StrToInteger(value)); +#else + return ((int)StringToInteger(value)); +#endif + } else { + return (NULL); + } + } + + double GetValueDouble(string key) { + string value = GetValueString(key); + + if (value != NULL) { +#ifdef MQL4 + return (StrToDouble(value)); +#else + return (StringToDouble(value)); +#endif + } else { + return (NULL); + } + } + + bool SetValue(string key, string value) { + int i = 0; + for (; i <= ArraySize(array); i++) { + if (array[i].key == key) { + array[i].val = value; + return true; + break; + } + } + + ArrayResize(array, (i + 2), 100000); + + array[(i + 1)].key = key; + array[(i + 1)].val = value; + + return true; + } + + bool SetValue(string key, double value) { + int i = 0; + for (; i <= ArraySize(array); i++) { + if (array[i].key == key) { + array[i].val = DoubleToString(value); + return true; + break; + } + } + + ArrayResize(array, (i + 2), 100000); + + array[(i + 1)].key = key; + array[(i + 1)].val = DoubleToString(value); + + return true; + } + + bool SetValue(string key, int value) { + int i = 0; + for (; i <= ArraySize(array); i++) { + if (array[i].key == key) { + array[i].val = IntegerToString(value); + return true; + break; + } + } + + ArrayResize(array, (i + 2), 100000); + + array[(i + 1)].key = key; + array[(i + 1)].val = IntegerToString(value); + + return true; + } }; diff --git a/Socket.mqh b/Socket.mqh index 136980282..a377202b7 100644 --- a/Socket.mqh +++ b/Socket.mqh @@ -25,6 +25,11 @@ * Implements class for socket connection. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "File.define.h" #include "Std.h" diff --git a/Stats.mqh b/Stats.mqh index c3a265747..0580ae986 100644 --- a/Stats.mqh +++ b/Stats.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "Platform/Chart/Chart.h" #include "Platform/Platform.h" diff --git a/Storage/Array.extern.h b/Storage/Array.extern.h index 976004818..20cf8635e 100644 --- a/Storage/Array.extern.h +++ b/Storage/Array.extern.h @@ -22,6 +22,7 @@ // Define external global functions. #ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. #pragma once #include "../Common.extern.h" @@ -97,4 +98,14 @@ int ArraySort(ARRAY_REF(T, array)) { return 0; } +template +void ArrayFill(ARRAY_REF(X, array), int start, int count, X value) { + Array::ArrayFill(array, start, count, value); +} + +template +void ArrayFill(FIXED_ARRAY_REF(X, array, size), int start, int count, X value) { + Array::ArrayFill(array, start, count, value); +} + #endif diff --git a/Storage/Array.h b/Storage/Array.h index 5486e3ee9..392ad263a 100644 --- a/Storage/Array.h +++ b/Storage/Array.h @@ -102,6 +102,28 @@ class Array { } } + template + static void ArrayFill(ARRAY_REF(X, array), int start, int count, X value) { + start = MathMax(start, 0); + int end = MathMin(ArraySize(array), start + count); + + for (int i = start; i < end; ++i) { + array[i] = value; + } + } + +#ifdef __cplusplus + template + static void ArrayFill(FIXED_ARRAY_REF(X, array, size), int start, int count, X value) { + start = MathMax(start, 0); + int end = MathMin(size, start + count); + + for (int i = start; i < end; ++i) { + array[i] = value; + } + } +#endif + template static int ArrayCopy(ARRAY_REF(T, dst_array), const ARRAY_REF(T, src_array), const int dst_start = 0, const int src_start = 0, const int count = WHOLE_ARRAY) { diff --git a/Storage/Collection.h b/Storage/Collection.h index 98934caf2..f88820a34 100644 --- a/Storage/Collection.h +++ b/Storage/Collection.h @@ -20,9 +20,10 @@ * */ -// Prevents processing this includes file for the second time. -#ifndef COLLECTION_H -#define COLLECTION_H +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif // Includes. #include "../Storage/Object.h" @@ -209,4 +210,3 @@ class Collection { return _out; } }; -#endif // COLLECTION_H diff --git a/Storage/Data.define.h b/Storage/Data.define.h index a66e5fdd5..00a70f128 100644 --- a/Storage/Data.define.h +++ b/Storage/Data.define.h @@ -25,6 +25,11 @@ * Includes Data's defines. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + #ifndef __MQL4__ // -- #ifndef DoubleToStr diff --git a/Storage/Database.extern.h b/Storage/Database.extern.h index 1376330ac..64a6d25db 100644 --- a/Storage/Database.extern.h +++ b/Storage/Database.extern.h @@ -24,6 +24,9 @@ // Define external global functions. #ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once + // Closes a database. // @docs: https://www.mql5.com/en/docs/database/databaseclose void DatabaseClose(int database // database handle received in DatabaseOpen @@ -36,8 +39,8 @@ extern bool DatabaseExecute(int database, // database handle received in Databa // Opens or creates a database in a specified file. // @docs: https://www.mql5.com/en/docs/database/databaseopen -int DatabaseOpen(string filename, // file name - uint flags // combination of flags +int DatabaseOpen(string filename, // file name + unsigned int flags // combination of flags ); // Starts transaction execution. diff --git a/Storage/Database.h b/Storage/Database.h index 147225b63..65a96b745 100644 --- a/Storage/Database.h +++ b/Storage/Database.h @@ -28,9 +28,10 @@ * @docs https://www.mql5.com/en/docs/database */ -// Prevents processing this includes file for the second time. -#ifndef DATABASE_H -#define DATABASE_H +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif // Includes. #include "../Math/MatrixMini.h" @@ -256,4 +257,3 @@ class Database { */ bool SetTableSchema(string _name, DatabaseTableSchema &_schema) { return tables.Set(_name, _schema); } }; -#endif // DATABASE_H diff --git a/Storage/Database.struct.h b/Storage/Database.struct.h index 46f623778..e3c216401 100644 --- a/Storage/Database.struct.h +++ b/Storage/Database.struct.h @@ -25,6 +25,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Structs. struct DatabaseTableColumnEntry { string name; diff --git a/Storage/DateTime.h b/Storage/DateTime.h index c820bf37d..7372a8d48 100644 --- a/Storage/DateTime.h +++ b/Storage/DateTime.h @@ -29,9 +29,10 @@ * - https://www.mql5.com/en/docs/dateandtime */ -// Prevents processing this includes file for the second time. -#ifndef DATETIME_MQH -#define DATETIME_MQH +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif // Forward declarations. struct DataParamEntry; @@ -252,5 +253,3 @@ datetime TimeCurrent(MqlDateTime &dt_struct) { } #endif - -#endif // DATETIME_MQH diff --git a/Storage/Dict/Buffer/Buffer.h b/Storage/Dict/Buffer/Buffer.h index 61e080091..2f25b79f4 100644 --- a/Storage/Dict/Buffer/Buffer.h +++ b/Storage/Dict/Buffer/Buffer.h @@ -20,9 +20,10 @@ * */ -// Prevents processing this includes file for the second time. -#ifndef BUFFER_H -#define BUFFER_H +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif // Includes. #include "../Dict.h" @@ -108,4 +109,3 @@ class Buffer : public Dict { return (T)median; } }; -#endif // BUFFER_H diff --git a/Storage/Dict/Buffer/BufferCandle.h b/Storage/Dict/Buffer/BufferCandle.h index e616796ee..9d512c42d 100644 --- a/Storage/Dict/Buffer/BufferCandle.h +++ b/Storage/Dict/Buffer/BufferCandle.h @@ -20,9 +20,10 @@ * */ -// Prevents processing this includes file for the second time. -#ifndef BUFFER_CANDLE_H -#define BUFFER_CANDLE_H +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif // Includes. #include "../../../Candle.struct.h" @@ -62,5 +63,3 @@ class BufferCandle : public BufferStruct> { */ string ToJSON() { return SerializerConverter::FromObject(THIS_REF).ToString(); } }; - -#endif // BUFFER_CANDLE_H diff --git a/Storage/Dict/Buffer/BufferFXT.h b/Storage/Dict/Buffer/BufferFXT.h index 6cf4461d8..f4985aa31 100644 --- a/Storage/Dict/Buffer/BufferFXT.h +++ b/Storage/Dict/Buffer/BufferFXT.h @@ -19,9 +19,10 @@ * along with this program. If not, see . */ -// Prevents processing this includes file for the second time. -#ifndef BUFFER_FXT_H -#define BUFFER_FXT_H +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif // Includes. #include "../../../Exchange/Account/AccountMt.h" @@ -302,5 +303,3 @@ class BufferFXT : public DictStruct { // @see: https://docs.mql4.com/files/filewritestruct } }; - -#endif // BUFFER_FXT_H diff --git a/Storage/Dict/Buffer/BufferStruct.h b/Storage/Dict/Buffer/BufferStruct.h index ca5906759..5db539b6f 100644 --- a/Storage/Dict/Buffer/BufferStruct.h +++ b/Storage/Dict/Buffer/BufferStruct.h @@ -20,9 +20,10 @@ * */ -// Prevents processing this includes file for the second time. -#ifndef BUFFER_STRUCT_H -#define BUFFER_STRUCT_H +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif // Includes. #include "../../../Serializer/Serializer.h" @@ -116,5 +117,3 @@ class BufferStruct : public DictStruct { */ long GetMin() { return min; } }; - -#endif // BUFFER_STRUCT_H diff --git a/Storage/Dict/Buffer/BufferTick.h b/Storage/Dict/Buffer/BufferTick.h index 6730ff705..44960c3ae 100644 --- a/Storage/Dict/Buffer/BufferTick.h +++ b/Storage/Dict/Buffer/BufferTick.h @@ -20,9 +20,10 @@ * */ -// Prevents processing this includes file for the second time. -#ifndef BUFFER_TICK_H -#define BUFFER_TICK_H +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif // Includes. #include "../../../Indicator/IndicatorData.enum.h" @@ -216,5 +217,3 @@ class BufferTick : public BufferStruct> { return NULL; } }; - -#endif // BUFFER_TICK_H diff --git a/Storage/Dict/Dict.h b/Storage/Dict/Dict.h index 45f304aa1..4341a87f0 100644 --- a/Storage/Dict/Dict.h +++ b/Storage/Dict/Dict.h @@ -20,9 +20,10 @@ * */ -// Prevents processing this includes file for the second time. -#ifndef DICT_H -#define DICT_H +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif #include "../../Convert.basic.h" #include "../../Math/Matrix.h" @@ -448,5 +449,3 @@ class Dict : public DictBase { return result; } }; - -#endif diff --git a/Storage/Dict/DictBase.h b/Storage/Dict/DictBase.h index a01d14535..34e4b011b 100644 --- a/Storage/Dict/DictBase.h +++ b/Storage/Dict/DictBase.h @@ -20,9 +20,10 @@ * */ -// Prevents processing this includes file for the second time. -#ifndef DICT_BASE_H -#define DICT_BASE_H +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif // Includes. #include "../../Convert.mqh" @@ -390,5 +391,3 @@ class DictBase { */ unsigned int Hash(float x) { return (unsigned int)((unsigned long)x * 10000 % 10000); } }; - -#endif diff --git a/Storage/Dict/DictSlot.h b/Storage/Dict/DictSlot.h index 00925d3f5..b9cf1af2a 100644 --- a/Storage/Dict/DictSlot.h +++ b/Storage/Dict/DictSlot.h @@ -20,9 +20,10 @@ * */ -// Prevents processing this includes file for the second time. -#ifndef DICT_SLOT_H -#define DICT_SLOT_H +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif enum DICT_SLOT_FLAGS { DICT_SLOT_INVALID = 1, DICT_SLOT_HAS_KEY = 2, DICT_SLOT_IS_USED = 4, DICT_SLOT_WAS_USED = 8 }; @@ -60,5 +61,3 @@ class DictSlot { void RemoveFlags(unsigned char flags) { _flags &= (unsigned char)~flags; } }; - -#endif // DICT_SLOT_H diff --git a/Storage/Object.enum.h b/Storage/Object.enum.h index 021ccd22e..29d84affd 100644 --- a/Storage/Object.enum.h +++ b/Storage/Object.enum.h @@ -26,7 +26,7 @@ */ #ifndef __MQLBUILD__ - +// Allows the preprocessor to include a header file when it is needed. #pragma once // Used for checking the type of the object pointer. diff --git a/Storage/Object.extern.h b/Storage/Object.extern.h index d166ea319..3f0778bbd 100644 --- a/Storage/Object.extern.h +++ b/Storage/Object.extern.h @@ -26,6 +26,7 @@ */ #ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. #pragma once // Includes. diff --git a/Storage/Object.h b/Storage/Object.h index 85bd312f9..cf9feaf40 100644 --- a/Storage/Object.h +++ b/Storage/Object.h @@ -20,9 +20,10 @@ * */ -// Prevents processing this includes file for the second time. -#ifndef OBJECT_H -#define OBJECT_H +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif // Includes. #include "../Refs.mqh" @@ -130,4 +131,3 @@ class Object : public Dynamic { // Initialize static global variables. // Object *Object::list = { 0 }; -#endif // OBJECT_H diff --git a/Storage/Redis.h b/Storage/Redis.h index 852803ec0..81eef8ce5 100644 --- a/Storage/Redis.h +++ b/Storage/Redis.h @@ -24,6 +24,12 @@ * @file * Implements class for storing/retrieving Redis database data. */ + +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + #include "../Serializer/Serializer.h" #include "../Serializer/SerializerConversions.h" #include "../Serializer/SerializerJson.h" diff --git a/Storage/String.extern.h b/Storage/String.extern.h index 26d44187f..924c2d79c 100644 --- a/Storage/String.extern.h +++ b/Storage/String.extern.h @@ -20,8 +20,8 @@ * */ -// Prevents processing this includes file for the second time. #ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. #pragma once // Includes. diff --git a/Storage/String.h b/Storage/String.h index 73ced295d..260efa983 100644 --- a/Storage/String.h +++ b/Storage/String.h @@ -20,9 +20,10 @@ * */ -// Prevents processing this includes file for the second time. -#ifndef STRING_MQH -#define STRING_MQH +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif // Includes. #include "../Common.extern.h" @@ -119,4 +120,3 @@ class String { #endif } }; -#endif // STRING_MQH diff --git a/Storage/ValueStorage.price_median.h b/Storage/ValueStorage.price_median.h index 6a05fad9d..e58953c08 100644 --- a/Storage/ValueStorage.price_median.h +++ b/Storage/ValueStorage.price_median.h @@ -24,6 +24,11 @@ * Median price version of ValueStorage. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Indicator/IndicatorBase.h" #include "Cache/ObjectsCache.h" diff --git a/Storage/ValueStorage.price_typical.h b/Storage/ValueStorage.price_typical.h index 3ca6300f0..d063e0112 100644 --- a/Storage/ValueStorage.price_typical.h +++ b/Storage/ValueStorage.price_typical.h @@ -24,6 +24,11 @@ * Typical price version of ValueStorage. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "Cache/ObjectsCache.h" #include "ValueStorage.history.h" diff --git a/Storage/ValueStorage.price_weighted.h b/Storage/ValueStorage.price_weighted.h index e86b7cbe6..04581f325 100644 --- a/Storage/ValueStorage.price_weighted.h +++ b/Storage/ValueStorage.price_weighted.h @@ -24,6 +24,11 @@ * Weighted price version of ValueStorage. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "Cache/ObjectsCache.h" #include "ValueStorage.history.h" diff --git a/Strategy.struct.pricestop.h b/Strategy.struct.pricestop.h index 8a14b983d..240ef01b3 100644 --- a/Strategy.struct.pricestop.h +++ b/Strategy.struct.pricestop.h @@ -61,7 +61,7 @@ struct StrategyPriceStop { // IndicatorParams iparams; /* Constructors */ - void StrategyPriceStop(int _method = 0, float _ivalue = 0) : method(_method), ivalue(_ivalue) {} + StrategyPriceStop(int _method = 0, float _ivalue = 0) : method(_method), ivalue(_ivalue) {} // Main methods. // Calculate price stop value. float GetValue(int _shift = 0, int _direction = -1, float _min_trade_dist = 0.0f) { @@ -84,7 +84,7 @@ struct StrategyPriceStop { } if (CheckMethod(STRATEGY_PRICE_STOP_PRICE_PP)) { double _pp, _r1, _r2, _r3, _r4, _s1, _s2, _s3, _s4; - double _prices[4]; + FIXED_ARRAY(double, _prices, 4); _prices[0] = _ohlc0.GetClose(); _prices[1] = _direction > 0 ? _ohlc0.GetHigh() : _ohlc0.GetLow(); _prices[2] = _direction > 0 ? _ohlc1.GetHigh() : _ohlc1.GetLow(); diff --git a/SummaryReport.mqh b/SummaryReport.mqh index 84eb08feb..324eabdf0 100644 --- a/SummaryReport.mqh +++ b/SummaryReport.mqh @@ -20,8 +20,13 @@ * */ -#include "Exchange/Account/AccountMt.h" +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + #include "Convert.mqh" +#include "Exchange/Account/AccountMt.h" #include "Indicator/IndicatorData.h" #include "Platform/Order.struct.h" #include "Platform/Terminal.h" diff --git a/Test.mqh b/Test.mqh index ebb9a463d..c181fe28a 100644 --- a/Test.mqh +++ b/Test.mqh @@ -25,6 +25,11 @@ * Provides base functionality for testing purposes. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Define an assert macros. #define assertTrueOrFail(cond, msg) \ if (!(cond)) { \ diff --git a/Tester.mqh b/Tester.mqh index 0538230cf..f81a50f40 100644 --- a/Tester.mqh +++ b/Tester.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "Exchange/SymbolInfo/SymbolInfo.h" #include "Platform/Terminal.h" diff --git a/Tests.mqh b/Tests.mqh index f40cb9fec..318a1225e 100644 --- a/Tests.mqh +++ b/Tests.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "Indicator/Indicator.h" #include "Market.mqh" diff --git a/Timer.mqh b/Timer.mqh index d18ac4ebb..c15d89314 100644 --- a/Timer.mqh +++ b/Timer.mqh @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "Math/Math.h" #include "Storage/Object.h" diff --git a/Trade/TradeSignal.h b/Trade/TradeSignal.h index 16cb3d33a..73645602c 100644 --- a/Trade/TradeSignal.h +++ b/Trade/TradeSignal.h @@ -20,6 +20,11 @@ * */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "TradeSignal.struct.h" diff --git a/Trade/TradeSignal.struct.h b/Trade/TradeSignal.struct.h index b5ce076e7..92946633f 100644 --- a/Trade/TradeSignal.struct.h +++ b/Trade/TradeSignal.struct.h @@ -25,6 +25,11 @@ * Includes TradeSignal's structs. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Platform/Chart/Chart.enum.h" #include "../Serializer/SerializerConverter.h" diff --git a/Trade/TradeSignalManager.h b/Trade/TradeSignalManager.h index 7a955d55c..da966da63 100644 --- a/Trade/TradeSignalManager.h +++ b/Trade/TradeSignalManager.h @@ -25,6 +25,11 @@ * Implements TradeSignalManager class. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Includes. #include "../Storage/Dict/DictObject.h" #include "TradeSignal.h" diff --git a/Trade/TradeSignalManager.struct.h b/Trade/TradeSignalManager.struct.h index 67aa68c6b..bf3e56c08 100644 --- a/Trade/TradeSignalManager.struct.h +++ b/Trade/TradeSignalManager.struct.h @@ -25,6 +25,11 @@ * Implements TradeSignalManager's structures. */ +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + // Defines. #define TSM_PROP_FREQ STRUCT_ENUM(TradeSignalManagerParams, TSM_PARAMS_PROP_FREQ) #define TSM_PROP_LAST_CHECK STRUCT_ENUM(TradeSignalManagerParams, TSM_PARAMS_PROP_LAST_CHECK) From 27edd661d052ce2c23a908de849a2311bb426ca5 Mon Sep 17 00:00:00 2001 From: Adrian Kierzkowski Date: Tue, 4 Jul 2023 20:00:26 +0200 Subject: [PATCH 21/26] WIP. Fixing C++ errors. One step further. --- Bar.struct.h | 12 + Candle.struct.h | 20 +- Config.mqh | 8 +- Convert.basic.h | 44 +- Convert.mqh | 24 +- EA.mqh | 317 ++++++------- EA.struct.h | 3 +- Exchange/Account/AccountMt.h | 20 +- Exchange/Exchange.struct.h | 2 +- Exchange/SymbolInfo/SymbolInfo.extern.h | 2 +- Exchange/SymbolInfo/SymbolInfo.h | 6 +- Exchange/SymbolInfo/SymbolInfo.struct.h | 12 +- .../SymbolInfo/SymbolInfo.struct.static.h | 8 +- Indicator/Indicator.h | 16 +- Indicator/IndicatorBase.h | 6 +- Indicator/IndicatorCandle.h | 10 +- Indicator/IndicatorCandle.provider.h | 4 +- Indicator/IndicatorData.enum.h | 4 +- Indicator/IndicatorData.h | 28 +- Indicator/IndicatorData.struct.h | 18 +- Indicator/IndicatorRenko.h | 6 +- Indicator/IndicatorRenko.provider.h | 4 +- Indicator/IndicatorTf.provider.h | 14 +- Indicator/IndicatorTick.h | 2 +- Indicator/IndicatorTick.provider.h | 4 +- Indicator/tests/IndicatorTf.test.mq5 | 4 +- Indicator/tests/IndicatorTick.test.mq5 | 2 +- Indicators/Indi_CHO.mqh | 2 +- Indicators/Indi_PriceVolumeTrend.mqh | 2 +- Indicators/Indi_StdDev.mqh | 2 +- Indicators/Indi_VROC.mqh | 2 +- Indicators/Indi_Volumes.mqh | 2 +- Indicators/Oscillator/Indi_RSI.h | 6 +- Indicators/PriceRange/Indi_Pivot.h | 2 +- Indicators/Tick/Indi_TickMt.h | 10 +- Indicators/Tick/Indi_TickProvider.h | 2 +- Indicators/Tick/Indi_TickRandom.h | 2 +- Indicators/tests/DrawIndicator.test.mq5 | 14 +- Log.mqh | 4 +- MD5.mqh | 30 +- Market.mqh | 5 +- Math/Math.define.h | 4 +- Platform/Chart/Chart.h | 21 +- Platform/Chart/Chart.struct.h | 16 +- Platform/Chart/Chart.struct.static.h | 10 +- Platform/Chart/ChartBase.h | 14 +- Platform/Chart/ChartMt.h | 4 +- Platform/Chart3D/Interface.h | 2 +- Platform/Chart3D/Math.h | 8 +- Platform/Chart3D/Mesh.h | 8 +- Platform/MQL5.mqh | 417 +++++++++--------- Platform/Order.h | 201 ++++----- Platform/Order.struct.h | 44 +- Platform/OrderQuery.h | 14 +- Platform/Orders.h | 8 +- Platform/Platform.enum.h | 44 ++ Platform/Platform.extern.h | 27 +- Platform/Platform.h | 58 ++- Platform/Plot.h | 28 +- Platform/Terminal.h | 12 +- Platform/tests/Order.test.mq5 | 8 +- Platform/tests/OrderQuery.test.mq5 | 4 +- Profiler.mqh | 4 +- Serializer/SerializerBinary.h | 2 +- Serializer/SerializerConversions.h | 4 +- Serializer/SerializerNodeParam.h | 24 +- Stats.mqh | 18 +- Std.h | 2 + Storage/Array.h | 12 +- Storage/Collection.h | 2 +- Storage/Data.enum.h | 4 +- Storage/Data.struct.h | 26 +- Storage/Database.h | 2 +- Storage/Dict/Buffer/Buffer.h | 12 +- Storage/Dict/Buffer/BufferFXT.h | 6 +- Storage/Dict/Buffer/BufferStruct.h | 20 +- Storage/Dict/DictBase.h | 2 +- Storage/Dict/DictStruct.h | 2 +- Storage/ItemsHistory.h | 16 +- Storage/Object.h | 8 +- Storage/String.extern.h | 2 +- Storage/ValueStorage.h | 18 +- Storage/ValueStorage.spread.h | 8 +- Storage/ValueStorage.tick_volume.h | 8 +- Storage/ValueStorage.volume.h | 10 +- Strategy.mqh | 61 +-- Strategy.struct.h | 12 +- Strategy.struct.pricestop.h | 7 +- Task/Task.struct.h | 1 + Task/tests/TaskAction.test.mq5 | 8 +- Task/tests/TaskCondition.test.mq5 | 8 +- Task/tests/TaskGetter.test.mq5 | 2 +- Tick/Tick.struct.h | 18 +- Ticker.mqh | 14 +- Timer.mqh | 8 +- Trade.mqh | 79 ++-- Trade.struct.h | 8 +- Trade/TradeSignal.struct.h | 12 +- Trade/TradeSignalManager.h | 6 +- Trade/TradeSignalManager.struct.h | 6 +- tests/StrategyTest-RSI.mq5 | 20 +- tests/TickerTest.mq5 | 2 +- 102 files changed, 1114 insertions(+), 1007 deletions(-) create mode 100644 Platform/Platform.enum.h diff --git a/Bar.struct.h b/Bar.struct.h index 63d77eea9..fe55530d2 100644 --- a/Bar.struct.h +++ b/Bar.struct.h @@ -70,6 +70,18 @@ struct BarOHLC low = fmin(low, _prices[i]); } } + BarOHLC(CONST_ARRAY_REF(double, _prices, 4), datetime _time = 0) : time(_time) { + _time = _time == (datetime)0 ? TimeCurrent() : _time; + int _size = 4; + close = _prices[0]; + open = _prices[_size - 1]; + high = fmax(close, open); + low = fmin(close, open); + for (int i = 0; i < _size; i++) { + high = fmax(high, _prices[i]); + low = fmin(low, _prices[i]); + } + } // Struct methods. // Getters bool GetPivots(ENUM_PP_TYPE _type, double &_pp, double &_r1, double &_r2, double &_r3, double &_r4, double &_s1, diff --git a/Candle.struct.h b/Candle.struct.h index 596ddbb89..ec0768bb5 100644 --- a/Candle.struct.h +++ b/Candle.struct.h @@ -231,14 +231,14 @@ struct CandleOCTOHLC : CandleOHLC { int length; // Open and close timestamps of ticks that were part of this candle. - long open_timestamp_ms, close_timestamp_ms; + int64 open_timestamp_ms, close_timestamp_ms; // Number of ticks which formed the candle. Also known as volume. int volume; // Struct constructor. CandleOCTOHLC(T _open = 0, T _high = 0, T _low = 0, T _close = 0, int _start_time = -1, int _length = 0, - long _open_timestamp_ms = -1, long _close_timestamp_ms = -1, int _volume = 0) + int64 _open_timestamp_ms = -1, int64 _close_timestamp_ms = -1, int _volume = 0) : CandleOHLC(_open, _high, _low, _close), is_complete(true), start_time(_start_time), @@ -264,7 +264,7 @@ struct CandleOCTOHLC : CandleOHLC { /** * Initializes candle with a given start time, lenght in seconds, first tick's timestamp and its price. */ - void Init(int _start_time, int _length, long _timestamp_ms = -1, T _price = 0) { + void Init(int _start_time, int _length, int64 _timestamp_ms = -1, T _price = 0) { is_complete = false; start_time = _start_time; length = _length; @@ -277,7 +277,7 @@ struct CandleOCTOHLC : CandleOHLC { /** * Updates OHLC values taking into consideration tick's timestamp. */ - void Update(long _timestamp_ms, T _price) { + void Update(int64 _timestamp_ms, T _price) { if (!ContainsTimeMs(_timestamp_ms)) { Print("Error: Cannot update candle. Given time doesn't fit in candle's time-frame!"); DebugBreak(); @@ -308,12 +308,12 @@ struct CandleOCTOHLC : CandleOHLC { /** * Method used by ItemsHistory. */ - long GetTimeMs() { return (long)start_time * 1000; } + int64 GetTimeMs() { return (int64)start_time * 1000; } /** * Method used by ItemsHistory. */ - long GetLengthMs() { return (long)length * 1000; } + int64 GetLengthMs() { return (int64)length * 1000; } /** * Returns candle's start time. @@ -323,18 +323,18 @@ struct CandleOCTOHLC : CandleOHLC { /** * Returns timestamp of open price. */ - long GetOpenTimestamp() { return open_timestamp_ms / 1000; } + int64 GetOpenTimestamp() { return open_timestamp_ms / 1000; } /** * Returns timestamp of close price. */ - long GetCloseTimestamp() { return close_timestamp_ms / 1000; } + int64 GetCloseTimestamp() { return close_timestamp_ms / 1000; } /** * Whether given time fits in the candle. */ - bool ContainsTimeMs(long _time_ms) { - return _time_ms >= (long)start_time * 1000 && _time_ms < (long)(start_time + length) * 1000; + bool ContainsTimeMs(int64 _time_ms) { + return _time_ms >= (int64)start_time * 1000 && _time_ms < (int64)(start_time + length) * 1000; } // Serializers. diff --git a/Config.mqh b/Config.mqh index 8213b902e..6fafbd41f 100644 --- a/Config.mqh +++ b/Config.mqh @@ -30,10 +30,10 @@ #define CONFIG_MQH // Includes. -#include "Storage/Dict/DictStruct.h" #include "File.mqh" -#include "Storage/Object.h" #include "Serializer/Serializer.h" +#include "Storage/Dict/DictStruct.h" +#include "Storage/Object.h" enum CONFIG_FORMAT { CONFIG_FORMAT_JSON, CONFIG_FORMAT_JSON_NO_WHITESPACES, CONFIG_FORMAT_INI }; @@ -84,7 +84,7 @@ struct ConfigEntry : public MqlParam { ConfigEntry() { type = (ENUM_DATATYPE)-1; } ConfigEntry(const ConfigEntry& _r) { THIS_REF = _r; } - ConfigEntry(long _value) { + ConfigEntry(int64 _value) { type = ENUM_DATATYPE::TYPE_LONG; integer_value = _value; } @@ -198,7 +198,7 @@ class Config : public DictStruct { return Set(key, param); } - bool Set(string key, long value) { + bool Set(string key, int64 value) { ConfigEntry param = value; return Set(key, param); } diff --git a/Convert.basic.h b/Convert.basic.h index 496e78bee..b1a7d546d 100644 --- a/Convert.basic.h +++ b/Convert.basic.h @@ -40,7 +40,7 @@ class ConvertBasic { /** * Convert integer to hex. */ - static string IntToHex(long long_number) { + static string IntToHex(int64 long_number) { string result; int integer_number = (int)long_number; for (int i = 0; i < 4; i++) { @@ -88,8 +88,8 @@ class ConvertBasic { static void StringToType(string _value, unsigned int& _out) { _out = (unsigned int)StringToInteger(_value); } static void StringToType(string _value, char& _out) { _out = (char)_value[0]; } static void StringToType(string _value, unsigned char& _out) { _out = (unsigned char)_value[0]; } - static void StringToType(string _value, long& _out) { _out = StringToInteger(_value); } - static void StringToType(string _value, unsigned long& _out) { _out = StringToInteger(_value); } + static void StringToType(string _value, int64& _out) { _out = StringToInteger(_value); } + static void StringToType(string _value, uint64& _out) { _out = StringToInteger(_value); } static void StringToType(string _value, short& _out) { _out = (short)StringToInteger(_value); } static void StringToType(string _value, unsigned short& _out) { _out = (unsigned short)StringToInteger(_value); } static void StringToType(string _value, float& _out) { _out = (float)StringToDouble(_value); } @@ -116,8 +116,8 @@ class ConvertBasic { static void BoolToType(bool _value, unsigned char& _out) { _out = (unsigned char)_value; } static void BoolToType(bool _value, int& _out) { _out = (int)_value; } static void BoolToType(bool _value, unsigned int& _out) { _out = (unsigned int)_value; } - static void BoolToType(bool _value, long& _out) { _out = (long)_value; } - static void BoolToType(bool _value, unsigned long& _out) { _out = (unsigned long)_value; } + static void BoolToType(bool _value, int64& _out) { _out = (int64)_value; } + static void BoolToType(bool _value, uint64& _out) { _out = (uint64)_value; } static void BoolToType(bool _value, short& _out) { _out = (short)_value; } static void BoolToType(bool _value, unsigned short& _out) { _out = (unsigned short)_value; } static void BoolToType(bool _value, float& _out) { _out = (float)_value; } @@ -133,23 +133,23 @@ class ConvertBasic { return _out; } - static void LongToType(long _value, bool& _out) { _out = (bool)_value; } - static void LongToType(long _value, char& _out) { _out = (char)_value; } - static void LongToType(long _value, unsigned char& _out) { _out = (unsigned char)_value; } - static void LongToType(long _value, int& _out) { _out = (int)_value; } - static void LongToType(long _value, unsigned int& _out) { _out = (unsigned int)_value; } - static void LongToType(long _value, long& _out) { _out = (long)_value; } - static void LongToType(long _value, unsigned long& _out) { _out = (unsigned long)_value; } - static void LongToType(long _value, short& _out) { _out = (short)_value; } - static void LongToType(long _value, unsigned short& _out) { _out = (unsigned short)_value; } - static void LongToType(long _value, float& _out) { _out = (float)_value; } - static void LongToType(long _value, double& _out) { _out = (double)_value; } - static void LongToType(long _value, string& _out) { _out = _value ? "1" : "0"; } - static void LongToType(long _value, color& _out) { _out = 0; } - static void LongToType(long _value, datetime& _out) {} + static void LongToType(int64 _value, bool& _out) { _out = (bool)_value; } + static void LongToType(int64 _value, char& _out) { _out = (char)_value; } + static void LongToType(int64 _value, unsigned char& _out) { _out = (unsigned char)_value; } + static void LongToType(int64 _value, int& _out) { _out = (int)_value; } + static void LongToType(int64 _value, unsigned int& _out) { _out = (unsigned int)_value; } + static void LongToType(int64 _value, int64& _out) { _out = (int64)_value; } + static void LongToType(int64 _value, uint64& _out) { _out = (uint64)_value; } + static void LongToType(int64 _value, short& _out) { _out = (short)_value; } + static void LongToType(int64 _value, unsigned short& _out) { _out = (unsigned short)_value; } + static void LongToType(int64 _value, float& _out) { _out = (float)_value; } + static void LongToType(int64 _value, double& _out) { _out = (double)_value; } + static void LongToType(int64 _value, string& _out) { _out = _value ? "1" : "0"; } + static void LongToType(int64 _value, color& _out) { _out = 0; } + static void LongToType(int64 _value, datetime& _out) {} template - static X LongTo(long _value) { + static X LongTo(int64 _value) { X _out; LongToType(_value, _out); return _out; @@ -160,8 +160,8 @@ class ConvertBasic { static void DoubleToType(double _value, unsigned char& _out) { _out = (unsigned char)_value; } static void DoubleToType(double _value, int& _out) { _out = (int)_value; } static void DoubleToType(double _value, unsigned int& _out) { _out = (unsigned int)_value; } - static void DoubleToType(double _value, long& _out) { _out = (long)_value; } - static void DoubleToType(double _value, unsigned long& _out) { _out = (unsigned long)_value; } + static void DoubleToType(double _value, int64& _out) { _out = (int64)_value; } + static void DoubleToType(double _value, uint64& _out) { _out = (uint64)_value; } static void DoubleToType(double _value, short& _out) { _out = (short)_value; } static void DoubleToType(double _value, unsigned short& _out) { _out = (unsigned short)_value; } static void DoubleToType(double _value, float& _out) { _out = (float)_value; } diff --git a/Convert.mqh b/Convert.mqh index 1103756d2..86abc3ed9 100644 --- a/Convert.mqh +++ b/Convert.mqh @@ -26,17 +26,17 @@ #endif // Includes. +#include "Convert.extern.h" #include "Exchange/Account/Account.enum.h" #include "Exchange/Account/Account.extern.h" -#include "Storage/Array.h" -#include "Convert.extern.h" -#include "Storage/DateTime.extern.h" -#include "Storage/DateTime.h" -#include "Math/Math.extern.h" -#include "Platform/Order.enum.h" #include "Exchange/SymbolInfo/SymbolInfo.enum.h" #include "Exchange/SymbolInfo/SymbolInfo.extern.h" #include "Exchange/SymbolInfo/SymbolInfo.struct.static.h" +#include "Math/Math.extern.h" +#include "Platform/Order.enum.h" +#include "Storage/Array.h" +#include "Storage/DateTime.extern.h" +#include "Storage/DateTime.h" /** * Class to provide conversion methods. @@ -164,12 +164,12 @@ class Convert { /** * Convert points into pips. */ - static double PointsToPips(long pts, int digits) { return (double)(pts / PointsPerPip(digits)); } + static double PointsToPips(int64 pts, int digits) { return (double)(pts / PointsPerPip(digits)); } /** * Convert points into pips. */ - static double PointsToPips(long pts, string _symbol = NULL) { + static double PointsToPips(int64 pts, string _symbol = NULL) { return PointsToPips(pts, (unsigned int)SymbolInfoStatic::SymbolInfoInteger(_symbol, SYMBOL_DIGITS)); } @@ -177,7 +177,7 @@ class Convert { * Convert points into price value. * */ - static double PointsToValue(long pts, int mode, string _symbol = NULL) { + static double PointsToValue(int64 pts, int mode, string _symbol = NULL) { switch (mode) { case 0: // Forex. // In currencies a tick is a point. @@ -201,7 +201,7 @@ class Convert { /** * Convert points into price value. */ - static double PointsToValue(long pts, int mode, int digits) { + static double PointsToValue(int64 pts, int mode, int digits) { switch (mode) { case 0: // Forex. return PipsToValue((double)pts / PointsPerPip(digits), digits); @@ -222,8 +222,8 @@ class Convert { /** * Convert points into price value. */ - static double PointsToValue(long pts, string _symbol = NULL) { - return PointsToValue(pts, (int)SymbolInfoStatic::SymbolInfoInteger(_symbol, SYMBOL_TRADE_CALC_MODE)); + static double PointsToValue(int64 pts, string _symbol = NULL) { + return PointsToValue(pts, SymbolInfoStatic::SymbolInfoInteger(_symbol, SYMBOL_TRADE_CALC_MODE)); } /** diff --git a/EA.mqh b/EA.mqh index c7f8e7e29..a3179f174 100644 --- a/EA.mqh +++ b/EA.mqh @@ -57,7 +57,7 @@ class EA : public Taskable { protected: // Class variables. AccountMt *account; - DictStruct> strats; + DictStruct> strats; Log logger; Terminal terminal; @@ -110,7 +110,7 @@ class EA : public Taskable { // Add and process tasks. Init(); // Initialize a trade instance for the current chart and symbol. - Ref _source = Platform::FetchDefaultCandleIndicator(_Symbol, PERIOD_CURRENT); + Ref _source = Platform::FetchDefaultCandleIndicator(_Symbol, PERIOD_CURRENT); TradeParams _tparams; Trade _trade(_tparams, _source.Ptr()); trade.Set(_Symbol, _trade); @@ -174,16 +174,16 @@ class EA : public Taskable { */ TradeSignalEntry GetStrategySignalEntry(Strategy *_strat, bool _trade_allowed = true, int _shift = 0) { // float _bf = 1.0; - float _scl = _strat.Get(STRAT_PARAM_SCL); - float _sol = _strat.Get(STRAT_PARAM_SOL); - int _scfm = _strat.Get(STRAT_PARAM_SCFM); - int _scft = _strat.Get(STRAT_PARAM_SCFT); - int _scm = _strat.Get(STRAT_PARAM_SCM); - int _sob = _strat.Get(STRAT_PARAM_SOB); - int _sofm = _strat.Get(STRAT_PARAM_SOFM); - int _soft = _strat.Get(STRAT_PARAM_SOFT); - int _som = _strat.Get(STRAT_PARAM_SOM); - int _ss = _shift >= 0 ? _shift : _strat.Get(STRAT_PARAM_SHIFT); + float _scl = _strat PTR_DEREF Get(STRAT_PARAM_SCL); + float _sol = _strat PTR_DEREF Get(STRAT_PARAM_SOL); + int _scfm = _strat PTR_DEREF Get(STRAT_PARAM_SCFM); + int _scft = _strat PTR_DEREF Get(STRAT_PARAM_SCFT); + int _scm = _strat PTR_DEREF Get(STRAT_PARAM_SCM); + int _sob = _strat PTR_DEREF Get(STRAT_PARAM_SOB); + int _sofm = _strat PTR_DEREF Get(STRAT_PARAM_SOFM); + int _soft = _strat PTR_DEREF Get(STRAT_PARAM_SOFT); + int _som = _strat PTR_DEREF Get(STRAT_PARAM_SOM); + int _ss = _shift >= 0 ? _shift : _strat PTR_DEREF Get(STRAT_PARAM_SHIFT); unsigned int _signals = 0; // sparams.Get(STRAT_PARAM_WEIGHT)); if (_trade_allowed) { @@ -191,20 +191,22 @@ class EA : public Taskable { // sresult.SetBoostFactor(sparams.IsBoosted() ? SignalOpenBoost(ORDER_TYPE_BUY, _sob) : 1.0f); // sresult.SetLotSize(sparams.GetLotSizeWithFactor()); // Process open signals when trade is allowed. - _signals |= _strat.SignalOpen(ORDER_TYPE_BUY, _som, _sol, _ss) ? SIGNAL_OPEN_BUY_MAIN : 0; - _signals |= !_strat.SignalOpenFilterMethod(ORDER_TYPE_BUY, _sofm) ? SIGNAL_OPEN_BUY_FILTER : 0; - _signals |= _strat.SignalOpen(ORDER_TYPE_SELL, _som, _sol, _ss) ? SIGNAL_OPEN_SELL_MAIN : 0; - _signals |= !_strat.SignalOpenFilterMethod(ORDER_TYPE_SELL, _sofm) ? SIGNAL_OPEN_SELL_FILTER : 0; - _signals |= !_strat.SignalOpenFilterTime(_soft) ? SIGNAL_OPEN_TIME_FILTER : 0; + _signals |= _strat PTR_DEREF SignalOpen(ORDER_TYPE_BUY, _som, _sol, _ss) ? SIGNAL_OPEN_BUY_MAIN : 0; + _signals |= !_strat PTR_DEREF SignalOpenFilterMethod(ORDER_TYPE_BUY, _sofm) ? SIGNAL_OPEN_BUY_FILTER : 0; + _signals |= _strat PTR_DEREF SignalOpen(ORDER_TYPE_SELL, _som, _sol, _ss) ? SIGNAL_OPEN_SELL_MAIN : 0; + _signals |= !_strat PTR_DEREF SignalOpenFilterMethod(ORDER_TYPE_SELL, _sofm) ? SIGNAL_OPEN_SELL_FILTER : 0; + _signals |= !_strat PTR_DEREF SignalOpenFilterTime(_soft) ? SIGNAL_OPEN_TIME_FILTER : 0; } // Process close signals. - _signals |= _strat.SignalClose(ORDER_TYPE_BUY, _scm, _scl, _ss) ? SIGNAL_CLOSE_BUY_MAIN : 0; - _signals |= !_strat.SignalCloseFilter(ORDER_TYPE_BUY, _scfm) ? SIGNAL_CLOSE_BUY_FILTER : 0; - _signals |= _strat.SignalClose(ORDER_TYPE_SELL, _scm, _scl, _ss) ? SIGNAL_CLOSE_SELL_MAIN : 0; - _signals |= !_strat.SignalCloseFilter(ORDER_TYPE_SELL, _scfm) ? SIGNAL_CLOSE_SELL_FILTER : 0; - _signals |= !_strat.SignalCloseFilterTime(_scft) ? SIGNAL_CLOSE_TIME_FILTER : 0; - TradeSignalEntry _sentry(_signals, _strat.GetSource() PTR_DEREF GetTf(), _strat.Get(STRAT_PARAM_ID)); - _sentry.Set(STRUCT_ENUM(TradeSignalEntry, TRADE_SIGNAL_PROP_STRENGTH), _strat.SignalOpen(_sofm, _sol, _ss)); + _signals |= _strat PTR_DEREF SignalClose(ORDER_TYPE_BUY, _scm, _scl, _ss) ? SIGNAL_CLOSE_BUY_MAIN : 0; + _signals |= !_strat PTR_DEREF SignalCloseFilter(ORDER_TYPE_BUY, _scfm) ? SIGNAL_CLOSE_BUY_FILTER : 0; + _signals |= _strat PTR_DEREF SignalClose(ORDER_TYPE_SELL, _scm, _scl, _ss) ? SIGNAL_CLOSE_SELL_MAIN : 0; + _signals |= !_strat PTR_DEREF SignalCloseFilter(ORDER_TYPE_SELL, _scfm) ? SIGNAL_CLOSE_SELL_FILTER : 0; + _signals |= !_strat PTR_DEREF SignalCloseFilterTime(_scft) ? SIGNAL_CLOSE_TIME_FILTER : 0; + TradeSignalEntry _sentry(_signals, _strat PTR_DEREF GetSource() PTR_DEREF GetTf(), + _strat PTR_DEREF Get(STRAT_PARAM_ID)); + _sentry.Set(STRUCT_ENUM(TradeSignalEntry, TRADE_SIGNAL_PROP_STRENGTH), + _strat PTR_DEREF SignalOpen(_sofm, _sol, _ss)); _sentry.Set(STRUCT_ENUM(TradeSignalEntry, TRADE_SIGNAL_PROP_TIME), ::TimeGMT()); return _sentry; } @@ -229,9 +231,9 @@ class EA : public Taskable { */ template void Set(ENUM_STRATEGY_PARAM _param, T _value) { - for (DictStructIterator> iter = strats.Begin(); iter.IsValid(); ++iter) { + for (DictStructIterator> iter = strats.Begin(); iter.IsValid(); ++iter) { Strategy *_strat = iter.Value().Ptr(); - _strat.Set(_param, _value); + _strat PTR_DEREF Set(_param, _value); } } @@ -242,7 +244,7 @@ class EA : public Taskable { void Set(ENUM_TRADE_PARAM _param, T _value) { for (DictObjectIterator iter = trade.Begin(); iter.IsValid(); ++iter) { Trade *_trade = iter.Value(); - _trade.Set(_param, _value); + _trade PTR_DEREF Set(_param, _value); } } @@ -258,51 +260,53 @@ class EA : public Taskable { for (DictObjectIterator _iter = tsm.GetIterSignalsActive(); _iter.IsValid(); ++_iter) { bool _result_local = true; TradeSignal *_signal = _iter.Value(); - if (_signal.Get(STRUCT_ENUM(TradeSignalEntry, TRADE_SIGNAL_FLAG_PROCESSED))) { + if (_signal PTR_DEREF Get(STRUCT_ENUM(TradeSignalEntry, TRADE_SIGNAL_FLAG_PROCESSED))) { // Ignores already processed signals. continue; } Trade *_trade = trade.GetByKey(_Symbol); Strategy *_strat = - strats.GetByKey(_signal.Get(STRUCT_ENUM(TradeSignalEntry, TRADE_SIGNAL_PROP_MAGIC_ID))).Ptr(); - if (_trade.Get(TRADE_STATE_ORDERS_ACTIVE)) { - float _sig_close = _signal.GetSignalClose(); + strats.GetByKey(_signal PTR_DEREF Get(STRUCT_ENUM(TradeSignalEntry, TRADE_SIGNAL_PROP_MAGIC_ID))) + .Ptr(); + if (_trade PTR_DEREF Get(TRADE_STATE_ORDERS_ACTIVE)) { + float _sig_close = _signal PTR_DEREF GetSignalClose(); string _comment_close = - _strat != NULL && _sig_close != 0.0f ? _strat.GetOrderCloseComment() : __FUNCTION_LINE__; + _strat != NULL && _sig_close != 0.0f ? _strat PTR_DEREF GetOrderCloseComment() : __FUNCTION_LINE__; // Check if we should close the orders. if (_sig_close >= 0.5f) { // Close signal for buy order. - _trade.OrdersCloseViaProp2( - ORDER_MAGIC, _signal.Get(STRUCT_ENUM(TradeSignalEntry, TRADE_SIGNAL_PROP_MAGIC_ID)), ORDER_TYPE, - ORDER_TYPE_BUY, MATH_COND_EQ, ORDER_REASON_CLOSED_BY_SIGNAL, _comment_close); + _trade PTR_DEREF OrdersCloseViaProp2( + ORDER_MAGIC, _signal PTR_DEREF Get(STRUCT_ENUM(TradeSignalEntry, TRADE_SIGNAL_PROP_MAGIC_ID)), + ORDER_TYPE, ORDER_TYPE_BUY, MATH_COND_EQ, ORDER_REASON_CLOSED_BY_SIGNAL, _comment_close); // Buy orders closed. - _strat.OnOrderClose(ORDER_TYPE_BUY); + _strat PTR_DEREF OnOrderClose(ORDER_TYPE_BUY); } if (_sig_close <= -0.5f) { // Close signal for sell order. - _trade.OrdersCloseViaProp2( - ORDER_MAGIC, _signal.Get(STRUCT_ENUM(TradeSignalEntry, TRADE_SIGNAL_PROP_MAGIC_ID)), ORDER_TYPE, - ORDER_TYPE_SELL, MATH_COND_EQ, ORDER_REASON_CLOSED_BY_SIGNAL, _comment_close); + _trade PTR_DEREF OrdersCloseViaProp2( + ORDER_MAGIC, _signal PTR_DEREF Get(STRUCT_ENUM(TradeSignalEntry, TRADE_SIGNAL_PROP_MAGIC_ID)), + ORDER_TYPE, ORDER_TYPE_SELL, MATH_COND_EQ, ORDER_REASON_CLOSED_BY_SIGNAL, _comment_close); // Sell orders closed. - _strat.OnOrderClose(ORDER_TYPE_SELL); + _strat PTR_DEREF OnOrderClose(ORDER_TYPE_SELL); } } - _trade_allowed &= _trade.IsTradeAllowed(); - _trade_allowed &= !_strat.IsSuspended(); + _trade_allowed &= _trade PTR_DEREF IsTradeAllowed(); + _trade_allowed &= !_strat PTR_DEREF IsSuspended(); if (_trade_allowed) { - float _sig_open = _signal.GetSignalOpen(); + float _sig_open = _signal PTR_DEREF GetSignalOpen(); unsigned int _sig_f = eparams.Get(STRUCT_ENUM(EAParams, EA_PARAM_PROP_SIGNAL_FILTER)); - string _comment_open = _strat != NULL && _sig_open != 0.0f ? _strat.GetOrderOpenComment() : __FUNCTION_LINE__; + string _comment_open = + _strat != NULL && _sig_open != 0.0f ? _strat PTR_DEREF GetOrderOpenComment() : __FUNCTION_LINE__; // Open orders on signals. if (_sig_open >= 0.5f) { // Open signal for buy. // When H1 or H4 signal filter is enabled, do not open minute-based orders on opposite or neutral signals. if (_sig_f == 0) { // @fixme: || GetSignalOpenFiltered(_signal, _sig_f) >= 0.5f) { - _strat.Set(TRADE_PARAM_ORDER_COMMENT, _comment_open); + _strat PTR_DEREF Set(TRADE_PARAM_ORDER_COMMENT, _comment_open); // Buy order open. _result_local &= TradeRequest(ORDER_TYPE_BUY, _Symbol, _strat); if (_result_local && eparams.CheckSignalFilter(STRUCT_ENUM(EAParams, EA_PARAM_SIGNAL_FILTER_FIRST))) { - _signal.Set(STRUCT_ENUM(TradeSignalEntry, TRADE_SIGNAL_FLAG_PROCESSED), true); + _signal PTR_DEREF Set(STRUCT_ENUM(TradeSignalEntry, TRADE_SIGNAL_FLAG_PROCESSED), true); break; } } @@ -311,26 +315,27 @@ class EA : public Taskable { // Open signal for sell. // When H1 or H4 signal filter is enabled, do not open minute-based orders on opposite or neutral signals. if (_sig_f == 0) { // @fixme: || GetSignalOpenFiltered(_signal, _sig_f) <= -0.5f) { - _strat.Set(TRADE_PARAM_ORDER_COMMENT, _comment_open); + _strat PTR_DEREF Set(TRADE_PARAM_ORDER_COMMENT, _comment_open); // Sell order open. _result_local &= TradeRequest(ORDER_TYPE_SELL, _Symbol, _strat); if (_result_local && eparams.CheckSignalFilter(STRUCT_ENUM(EAParams, EA_PARAM_SIGNAL_FILTER_FIRST))) { - _signal.Set(STRUCT_ENUM(TradeSignalEntry, TRADE_SIGNAL_FLAG_PROCESSED), true); + _signal PTR_DEREF Set(STRUCT_ENUM(TradeSignalEntry, TRADE_SIGNAL_FLAG_PROCESSED), true); break; } } } if (_result_local) { - _signal.Set(STRUCT_ENUM(TradeSignalEntry, TRADE_SIGNAL_FLAG_PROCESSED), true); + _signal PTR_DEREF Set(STRUCT_ENUM(TradeSignalEntry, TRADE_SIGNAL_FLAG_PROCESSED), true); } else { _last_error = GetLastError(); if (_last_error > 0) { - logger.Warning(StringFormat("Error: %d", _last_error), __FUNCTION_LINE__, _strat.GetName()); + logger.Warning(StringFormat("Error: %d", _last_error), __FUNCTION_LINE__, _strat PTR_DEREF GetName()); ResetLastError(); } - if (_trade.Get(TRADE_STATE_MONEY_NOT_ENOUGH)) { - logger.Warning(StringFormat("Suspending strategy.", _last_error), __FUNCTION_LINE__, _strat.GetName()); - _strat.Suspended(true); + if (_trade PTR_DEREF Get(TRADE_STATE_MONEY_NOT_ENOUGH)) { + logger.Warning(StringFormat("Suspending strategy.", _last_error), __FUNCTION_LINE__, + _strat PTR_DEREF GetName()); + _strat PTR_DEREF Suspended(true); } } } @@ -355,20 +360,20 @@ class EA : public Taskable { bool _result = false; Trade *_trade = trade.GetByKey(_symbol); // Prepare a request. - MqlTradeRequest _request = _trade.GetTradeOpenRequest(_cmd); - _request.comment = _strat.GetOrderOpenComment(); - _request.magic = _strat.Get(STRAT_PARAM_ID); + MqlTradeRequest _request = _trade PTR_DEREF GetTradeOpenRequest(_cmd); + _request.comment = _strat PTR_DEREF GetOrderOpenComment(); + _request.magic = _strat PTR_DEREF Get(STRAT_PARAM_ID); _request.price = SymbolInfoStatic::GetOpenOffer(_symbol, _cmd); - _request.volume = fmax(_strat.Get(STRAT_PARAM_LS), SymbolInfoStatic::GetVolumeMin(_symbol)); + _request.volume = fmax(_strat PTR_DEREF Get(STRAT_PARAM_LS), SymbolInfoStatic::GetVolumeMin(_symbol)); // @fixit Uncomment - // _request.volume = _trade.NormalizeLots(_request.volume); + // _request.volume = _trade PTR_DEREF NormalizeLots(_request.volume); // Prepare an order parameters. OrderParams _oparams; - _strat.OnOrderOpen(_oparams); + _strat PTR_DEREF OnOrderOpen(_oparams); // Send the request. - _result = _trade.RequestSend(_request, _oparams); + _result = _trade PTR_DEREF RequestSend(_request, _oparams); return _result; } @@ -387,27 +392,28 @@ class EA : public Taskable { if (estate.IsActive()) { ProcessPeriods(); // Process all enabled strategies and retrieve their signals. - for (DictStructIterator> iter = strats.Begin(); iter.IsValid(); ++iter) { + for (DictStructIterator> iter = strats.Begin(); iter.IsValid(); ++iter) { bool _can_trade = true; Strategy *_strat = iter.Value().Ptr(); Trade *_trade = trade.GetByKey(_Symbol); - if (_strat.IsEnabled()) { + if (_strat PTR_DEREF IsEnabled()) { if (estate.Get(STRUCT_ENUM(EAState, EA_STATE_PROP_NEW_PERIODS)) >= DATETIME_MINUTE) { // Process when new periods started. - _strat.OnPeriod(estate.Get(STRUCT_ENUM(EAState, EA_STATE_PROP_NEW_PERIODS))); - _strat.ProcessTasks(); - _trade.OnPeriod(estate.Get(STRUCT_ENUM(EAState, EA_STATE_PROP_NEW_PERIODS))); + _strat PTR_DEREF OnPeriod(estate.Get(STRUCT_ENUM(EAState, EA_STATE_PROP_NEW_PERIODS))); + _strat PTR_DEREF ProcessTasks(); + _trade PTR_DEREF OnPeriod(estate.Get(STRUCT_ENUM(EAState, EA_STATE_PROP_NEW_PERIODS))); eresults.stg_processed_periods++; } - if (_strat.TickFilter(_tick)) { - _can_trade &= !_strat.IsSuspended(); - TradeSignalEntry _sentry = GetStrategySignalEntry(_strat, _can_trade, _strat.Get(STRAT_PARAM_SHIFT)); + if (_strat PTR_DEREF TickFilter(_tick)) { + _can_trade &= !_strat PTR_DEREF IsSuspended(); + TradeSignalEntry _sentry = + GetStrategySignalEntry(_strat, _can_trade, _strat PTR_DEREF Get(STRAT_PARAM_SHIFT)); if (_sentry.Get(STRUCT_ENUM(TradeSignalEntry, TRADE_SIGNAL_PROP_SIGNALS)) > 0) { TradeSignal _signal(_sentry); if (_signal.GetSignalClose() != _signal.GetSignalOpen()) { tsm.SignalAdd(_signal); //, _tick.time); } - StgProcessResult _strat_result = _strat.GetProcessResult(); + StgProcessResult _strat_result = _strat PTR_DEREF GetProcessResult(); eresults.last_error = fmax(eresults.last_error, _strat_result.last_error); eresults.stg_errored += (int)_strat_result.last_error > ERR_NO_ERROR; eresults.stg_processed++; @@ -415,7 +421,7 @@ class EA : public Taskable { } } } - if (tsm.GetSignalsActive().Size() > 0 && tsm.IsReady()) { + if (tsm.GetSignalsActive() PTR_DEREF Size() > 0 && tsm.IsReady()) { // Process all strategies' signals and trigger trading orders. ProcessSignals(_tick, eparams.Get(STRUCT_ENUM(EAParams, EA_PARAM_PROP_SIGNAL_FILTER))); } @@ -442,33 +448,33 @@ class EA : public Taskable { * Process data to store. */ void ProcessData() { - long _timestamp = estate.last_updated.GetEntry().GetTimestamp(); + int64 _timestamp = estate.last_updated.GetEntry().GetTimestamp(); if (eparams.CheckFlagDataStore(EA_DATA_STORE_CHART)) { ChartEntry _entry = Chart().GetEntry(); data_chart.Add(_entry, _entry.bar.ohlc.time); } if (eparams.CheckFlagDataStore(EA_DATA_STORE_INDICATOR)) { - for (DictStructIterator> iter = strats.Begin(); iter.IsValid(); ++iter) { + for (DictStructIterator> iter = strats.Begin(); iter.IsValid(); ++iter) { Strategy *_strati = iter.Value().Ptr(); - IndicatorData *_indi = _strati.GetIndicator(); + IndicatorData *_indi = _strati PTR_DEREF GetIndicator(); if (_indi != NULL) { ENUM_TIMEFRAMES _itf = _indi PTR_DEREF GetTf(); - IndicatorDataEntry _ientry = _indi.GetEntry(); + IndicatorDataEntry _ientry = _indi PTR_DEREF GetEntry(); if (!data_indi.KeyExists(_itf)) { // Create new timeframe buffer if does not exist. BufferStruct *_ide = new BufferStruct; - data_indi.Set(_itf, _ide); + data_indi.Set(_itf, PTR_TO_REF(_ide)); } // Save entry into data_indi. - data_indi[_itf].Add(_ientry); + data_indi[_itf] PTR_DEREF Add(_ientry); } } } /* if (eparams.CheckFlagDataStore(EA_DATA_STORE_STRATEGY)) { - for (DictStructIterator> iter = strats.Begin(); iter.IsValid(); ++iter) { + for (DictStructIterator> iter = strats.Begin(); iter.IsValid(); ++iter) { Strategy *_strat = iter.Value().Ptr(); - StgEntry _sentry = _strat.GetEntry(); + StgEntry _sentry = _strat PTR_DEREF GetEntry(); ENUM_TIMEFRAMES _stf = iter_tf.Key(); // @fixme if (!data_stg.KeyExists(_stf)) { // Create new timeframe buffer if does not exist. @@ -501,7 +507,7 @@ class EA : public Taskable { * Export data. */ void DataExport(unsigned short _methods) { - long _timestamp = estate.last_updated.GetEntry().GetTimestamp(); + int64 _timestamp = estate.last_updated.GetEntry().GetTimestamp(); int _serializer_flags = SERIALIZER_FLAG_SKIP_HIDDEN | SERIALIZER_FLAG_INCLUDE_DEFAULT | SERIALIZER_FLAG_INCLUDE_DYNAMIC | SERIALIZER_FLAG_REUSE_STUB | SERIALIZER_FLAG_REUSE_OBJECT; @@ -533,14 +539,14 @@ class EA : public Taskable { SerializerConverter::MakeStubObject>(_serializer_flags); /* - for (DictStructIterator> iter = strats.Begin(); iter.IsValid(); ++iter) { + for (DictStructIterator> iter = strats.Begin(); iter.IsValid(); ++iter) { ENUM_TIMEFRAMES _itf = iter_tf.Key(); // @fixme if (data_indi.KeyExists(_itf)) { BufferStruct _indi_buff = data_indi.GetByKey(_itf); SerializerConverter _obj = SerializerConverter::FromObject(_indi_buff, _serializer_flags); - for (DictStructIterator> iter = strats[_itf].Begin(); iter.IsValid(); ++iter) { + for (DictStructIterator> iter = strats[_itf].Begin(); iter.IsValid(); ++iter) { string _key_indi = "Indicator"; _key_indi += StringFormat("-%d-%d-%d", _itf, _indi_buff.GetMin(), _indi_buff.GetMax()); @@ -568,7 +574,7 @@ class EA : public Taskable { SerializerConverter _stub = SerializerConverter::MakeStubObject>(_serializer_flags); /* @fixme - for (DictStructIterator> iter = strats.Begin(); iter.IsValid(); ++iter) { + for (DictStructIterator> iter = strats.Begin(); iter.IsValid(); ++iter) { ENUM_TIMEFRAMES _stf = iter_tf.Key(); // @fixme if (data_stg.KeyExists(_stf)) { string _key_stg = StringFormat("Strategy-%d", _stf); @@ -618,7 +624,7 @@ class EA : public Taskable { } if (eparams.CheckFlagDataStore(EA_DATA_STORE_TRADE)) { string _key_trade = "Trade"; - // _key_sym += StringFormat("-%d-%d", data_trade.GetMin(), data_trade.GetMax()); + // _key_sym += StringFormat("-%d-%d", data_trade PTR_DEREF GetMin(), data_trade PTR_DEREF GetMax()); if ((_methods & EA_DATA_EXPORT_CSV) != 0) { // @todo // SerializerConverter _stub_trade = @@ -654,14 +660,11 @@ class EA : public Taskable { */ /* @fixme: Convert into TradeSignal format. float GetSignalOpenFiltered(StrategySignal &_signal, unsigned int _sf) { - float _result = _signal.GetSignalOpen(); - ENUM_TIMEFRAMES _sig_tf = _signal.Get(STRUCT_ENUM(StrategySignal, STRATEGY_SIGNAL_PROP_TF)); - if (ChartTf::TfToHours(_sig_tf) < 1 && bool(_sf & STRUCT_ENUM(EAParams, EA_PARAM_SIGNAL_FILTER_OPEN_M_IF_H))) { - _result = 0; - long _tfts[4]; - _tfts[0] = ChartStatic::iTime(_Symbol, PERIOD_H1); - _tfts[1] = ChartStatic::iTime(_Symbol, PERIOD_H4); - _tfts[2] = ChartStatic::iTime(_Symbol, PERIOD_H1, 1); + float _result = _signal PTR_DEREF GetSignalOpen(); + ENUM_TIMEFRAMES _sig_tf = _signal PTR_DEREF Get(STRUCT_ENUM(StrategySignal, + STRATEGY_SIGNAL_PROP_TF)); if (ChartTf::TfToHours(_sig_tf) < 1 && bool(_sf & STRUCT_ENUM(EAParams, + EA_PARAM_SIGNAL_FILTER_OPEN_M_IF_H))) { _result = 0; int64 _tfts[4]; _tfts[0] = ChartStatic::iTime(_Symbol, + PERIOD_H1); _tfts[1] = ChartStatic::iTime(_Symbol, PERIOD_H4); _tfts[2] = ChartStatic::iTime(_Symbol, PERIOD_H1, 1); _tfts[3] = ChartStatic::iTime(_Symbol, PERIOD_H4, 1); for (int i = 0; i < ArraySize(_tfts); i++) { DictStruct _ds = strat_signals.GetByKey(_tfts[i]); @@ -694,21 +697,21 @@ class EA : public Taskable { * Returns true if the strategy has been initialized correctly, otherwise false. */ template - bool StrategyAdd(ENUM_TIMEFRAMES _tf, long _magic_no = 0, int _type = 0) { + bool StrategyAdd(ENUM_TIMEFRAMES _tf, int64 _magic_no = 0, int _type = 0) { bool _result = true; _magic_no = _magic_no > 0 ? _magic_no : rand(); Ref _strat = ((SClass *)NULL).Init(_tf); - _strat.Ptr().Set(STRAT_PARAM_ID, _magic_no); - _strat.Ptr().Set(STRAT_PARAM_TF, _tf); - _strat.Ptr().Set(STRAT_PARAM_TYPE, _type); - _strat.Ptr().OnInit(); + _strat PTR_DEREF Ptr().Set(STRAT_PARAM_ID, _magic_no); + _strat PTR_DEREF Ptr().Set(STRAT_PARAM_TF, _tf); + _strat PTR_DEREF Ptr().Set(STRAT_PARAM_TYPE, _type); + _strat PTR_DEREF Ptr().OnInit(); if (!strats.KeyExists(_magic_no)) { _result &= strats.Set(_magic_no, _strat); } else { logger.Error("Strategy adding conflict!", __FUNCTION_LINE__); DebugBreak(); } - OnStrategyAdd(_strat.Ptr()); + OnStrategyAdd(_strat PTR_DEREF Ptr()); return _result; } @@ -729,7 +732,7 @@ class EA : public Taskable { * Returns true if all strategies has been initialized correctly, otherwise false. */ template - bool StrategyAdd(unsigned int _tfs, long _init_magic = 0, int _type = 0) { + bool StrategyAdd(unsigned int _tfs, int64 _init_magic = 0, int _type = 0) { bool _result = true; for (int _tfi = 0; _tfi < sizeof(int) * 8; ++_tfi) { if ((_tfs & (1 << _tfi)) != 0) { @@ -744,7 +747,7 @@ class EA : public Taskable { */ bool StrategyLoadTrades(Strategy *_strat) { Trade *_trade = trade.GetByKey(_Symbol); - return _trade.OrdersLoadByMagic(_strat.Get(STRAT_PARAM_ID)); + return _trade PTR_DEREF OrdersLoadByMagic(_strat PTR_DEREF Get(STRAT_PARAM_ID)); } /* Trade methods */ @@ -760,51 +763,54 @@ class EA : public Taskable { ResetLastError(); for (DictObjectIterator titer = trade.Begin(); titer.IsValid(); ++titer) { Trade *_trade = titer.Value(); - if (_trade.Get(TRADE_STATE_ORDERS_ACTIVE)) { - for (DictStructIterator> oiter = _trade.GetOrdersActive().Begin(); oiter.IsValid(); ++oiter) { + if (_trade PTR_DEREF Get(TRADE_STATE_ORDERS_ACTIVE)) { + for (DictStructIterator> oiter = _trade PTR_DEREF GetOrdersActive() PTR_DEREF Begin(); + oiter.IsValid(); ++oiter) { bool _sl_valid = false, _tp_valid = false; double _sl_new = 0, _tp_new = 0; Order *_order = oiter.Value().Ptr(); - if (!_order.ShouldUpdate()) { + if (!_order PTR_DEREF ShouldUpdate()) { continue; } - _order.ProcessConditions(); - if (_order.IsClosed()) { - _trade.OrderMoveToHistory(_order); + _order PTR_DEREF ProcessConditions(); + if (_order PTR_DEREF IsClosed()) { + _trade PTR_DEREF OrderMoveToHistory(_order); continue; } - ENUM_ORDER_TYPE _otype = _order.Get(ORDER_TYPE); - Strategy *_strat = strats.GetByKey(_order.Get(ORDER_MAGIC)).Ptr(); - Strategy *_strat_sl = _strat.GetStratSl(); - Strategy *_strat_tp = _strat.GetStratTp(); + ENUM_ORDER_TYPE _otype = _order PTR_DEREF Get(ORDER_TYPE); + Strategy *_strat = strats.GetByKey(_order PTR_DEREF Get(ORDER_MAGIC)).Ptr(); + Strategy *_strat_sl = _strat PTR_DEREF GetStratSl(); + Strategy *_strat_tp = _strat PTR_DEREF GetStratTp(); if (_strat_sl != NULL || _strat_tp != NULL) { - float _olots = _order.Get(ORDER_VOLUME_CURRENT); - float _trisk = _trade.Get(TRADE_PARAM_RISK_MARGIN); + float _olots = _order PTR_DEREF Get(ORDER_VOLUME_CURRENT); + float _trisk = _trade PTR_DEREF Get(TRADE_PARAM_RISK_MARGIN); if (_strat_sl != NULL) { - float _psl = _strat_sl.Get(STRAT_PARAM_PSL); - float _sl_max = _trade.GetMaxSLTP(_otype, _olots, ORDER_TYPE_SL, _trisk); - int _psm = _strat_sl.Get(STRAT_PARAM_PSM); - _sl_new = _strat_sl.PriceStop(_otype, ORDER_TYPE_SL, _psm, _psl); - _sl_new = _trade.GetSaferSLTP(_sl_new, _sl_max, _otype, ORDER_TYPE_SL); - _sl_new = _trade.NormalizeSL(_sl_new, _otype); - _sl_valid = _trade.IsValidOrderSL(_sl_new, _otype, _order.Get(ORDER_SL), _psm > 0); - _sl_new = _sl_valid ? _sl_new : _order.Get(ORDER_SL); + float _psl = _strat_sl PTR_DEREF Get(STRAT_PARAM_PSL); + float _sl_max = _trade PTR_DEREF GetMaxSLTP(_otype, _olots, ORDER_TYPE_SL, _trisk); + int _psm = _strat_sl PTR_DEREF Get(STRAT_PARAM_PSM); + _sl_new = _strat_sl PTR_DEREF PriceStop(_otype, ORDER_TYPE_SL, _psm, _psl); + _sl_new = _trade PTR_DEREF GetSaferSLTP(_sl_new, _sl_max, _otype, ORDER_TYPE_SL); + _sl_new = _trade PTR_DEREF NormalizeSL(_sl_new, _otype); + _sl_valid = + _trade PTR_DEREF IsValidOrderSL(_sl_new, _otype, _order PTR_DEREF Get(ORDER_SL), _psm > 0); + _sl_new = _sl_valid ? _sl_new : _order PTR_DEREF Get(ORDER_SL); } if (_strat_tp != NULL) { - float _ppl = _strat_tp.Get(STRAT_PARAM_PPL); - float _tp_max = _trade.GetMaxSLTP(_otype, _olots, ORDER_TYPE_TP, _trisk); - int _ppm = _strat_tp.Get(STRAT_PARAM_PPM); - _tp_new = _strat_tp.PriceStop(_otype, ORDER_TYPE_TP, _ppm, _ppl); - _tp_new = _trade.GetSaferSLTP(_tp_new, _tp_max, _otype, ORDER_TYPE_TP); - _tp_new = _trade.NormalizeTP(_tp_new, _otype); - _tp_valid = _trade.IsValidOrderTP(_tp_new, _otype, _order.Get(ORDER_TP), _ppm > 0); - _tp_new = _tp_valid ? _tp_new : _order.Get(ORDER_TP); + float _ppl = _strat_tp PTR_DEREF Get(STRAT_PARAM_PPL); + float _tp_max = _trade PTR_DEREF GetMaxSLTP(_otype, _olots, ORDER_TYPE_TP, _trisk); + int _ppm = _strat_tp PTR_DEREF Get(STRAT_PARAM_PPM); + _tp_new = _strat_tp PTR_DEREF PriceStop(_otype, ORDER_TYPE_TP, _ppm, _ppl); + _tp_new = _trade PTR_DEREF GetSaferSLTP(_tp_new, _tp_max, _otype, ORDER_TYPE_TP); + _tp_new = _trade PTR_DEREF NormalizeTP(_tp_new, _otype); + _tp_valid = + _trade PTR_DEREF IsValidOrderTP(_tp_new, _otype, _order PTR_DEREF Get(ORDER_TP), _ppm > 0); + _tp_new = _tp_valid ? _tp_new : _order PTR_DEREF Get(ORDER_TP); } } if (_sl_valid || _tp_valid) { - _result &= _order.OrderModify(_sl_new, _tp_new); + _result &= _order PTR_DEREF OrderModify(_sl_new, _tp_new); if (_result) { - _order.Set(ORDER_PROP_TIME_LAST_UPDATE, TimeCurrent()); + _order PTR_DEREF Set(ORDER_PROP_TIME_LAST_UPDATE, TimeCurrent()); } } } @@ -819,12 +825,12 @@ class EA : public Taskable { * Update EA state flags. */ void UpdateStateFlags() { - estate.Set(STRUCT_ENUM(EAState, EA_STATE_FLAG_CONNECTED), GetTerminal().IsConnected()); - estate.Set(STRUCT_ENUM(EAState, EA_STATE_FLAG_LIBS_ALLOWED), GetTerminal().IsLibrariesAllowed()); - estate.Set(STRUCT_ENUM(EAState, EA_STATE_FLAG_OPTIMIZATION), GetTerminal().IsOptimization()); - estate.Set(STRUCT_ENUM(EAState, EA_STATE_FLAG_TESTING), GetTerminal().IsTesting()); - estate.Set(STRUCT_ENUM(EAState, EA_STATE_FLAG_TRADE_ALLOWED), GetTerminal().IsTradeAllowed()); - estate.Set(STRUCT_ENUM(EAState, EA_STATE_FLAG_VISUAL_MODE), GetTerminal().IsVisualMode()); + estate.Set(STRUCT_ENUM(EAState, EA_STATE_FLAG_CONNECTED), GetTerminal() PTR_DEREF IsConnected()); + estate.Set(STRUCT_ENUM(EAState, EA_STATE_FLAG_LIBS_ALLOWED), GetTerminal() PTR_DEREF IsLibrariesAllowed()); + estate.Set(STRUCT_ENUM(EAState, EA_STATE_FLAG_OPTIMIZATION), GetTerminal() PTR_DEREF IsOptimization()); + estate.Set(STRUCT_ENUM(EAState, EA_STATE_FLAG_TESTING), GetTerminal() PTR_DEREF IsTesting()); + estate.Set(STRUCT_ENUM(EAState, EA_STATE_FLAG_TRADE_ALLOWED), GetTerminal() PTR_DEREF IsTradeAllowed()); + estate.Set(STRUCT_ENUM(EAState, EA_STATE_FLAG_VISUAL_MODE), GetTerminal() PTR_DEREF IsVisualMode()); } /** @@ -851,8 +857,8 @@ class EA : public Taskable { if (eparams.CheckFlag(EA_PARAM_FLAG_LOTSIZE_AUTO)) { // Auto calculate lot size for all strategies. Trade *_trade = trade.GetByKey(_Symbol); - _result &= _trade.Run(TRADE_ACTION_CALC_LOT_SIZE); - Set(STRAT_PARAM_LS, _trade.Get(TRADE_PARAM_LOT_SIZE)); + _result &= _trade PTR_DEREF Run(TRADE_ACTION_CALC_LOT_SIZE); + Set(STRAT_PARAM_LS, _trade PTR_DEREF Get(TRADE_PARAM_LOT_SIZE)); } return _result; } @@ -889,7 +895,7 @@ class EA : public Taskable { case EA_COND_IS_ENABLED: return estate.IsEnabled(); case EA_COND_IS_NOT_CONNECTED: - estate.Set(STRUCT_ENUM(EAState, EA_STATE_FLAG_CONNECTED), GetTerminal().IsConnected()); + estate.Set(STRUCT_ENUM(EAState, EA_STATE_FLAG_CONNECTED), GetTerminal() PTR_DEREF IsConnected()); return !estate.IsConnected(); case EA_COND_ON_NEW_MINUTE: // On new minute. return (estate.Get(STRUCT_ENUM(EAState, EA_STATE_PROP_NEW_PERIODS)) & DATETIME_MINUTE) != 0; @@ -908,7 +914,7 @@ class EA : public Taskable { case EA_COND_ON_QUIT: return estate.IsOnQuit(); default: - GetLogger().Error(StringFormat("Invalid EA condition: %d!", _entry.GetId(), __FUNCTION_LINE__)); + GetLogger() PTR_DEREF Error(StringFormat("Invalid EA condition: %d!", _entry.GetId(), __FUNCTION_LINE__)); SetUserError(ERR_INVALID_PARAMETER); break; } @@ -948,10 +954,10 @@ class EA : public Taskable { // 2nd (i:1) - Strategy's argument to pass. TaskActionEntry _entry_strat = _entry; _entry_strat.ArgRemove(0); - for (DictStructIterator> iter_strat = strats.Begin(); iter_strat.IsValid(); ++iter_strat) { + for (DictStructIterator> iter_strat = strats.Begin(); iter_strat.IsValid(); ++iter_strat) { Strategy *_strat = iter_strat.Value().Ptr(); - _result &= _strat.Run(_entry_strat); + _result &= _strat PTR_DEREF Run(_entry_strat); } return _result; } @@ -961,7 +967,7 @@ class EA : public Taskable { SetUserError(ERR_INVALID_PARAMETER); return false; default: - GetLogger().Error(StringFormat("Invalid EA action: %d!", _entry.GetId(), __FUNCTION_LINE__)); + GetLogger() PTR_DEREF Error(StringFormat("Invalid EA action: %d!", _entry.GetId(), __FUNCTION_LINE__)); SetUserError(ERR_INVALID_PARAMETER); } return _result; @@ -991,9 +997,9 @@ class EA : public Taskable { */ template Strategy *GetStrategyViaProp(ENUM_STRATEGY_PARAM _prop, T _value, ENUM_MATH_CONDITION _op = MATH_COND_EQ) { - for (DictStructIterator> iter = strats.Begin(); iter.IsValid(); ++iter) { + for (DictStructIterator> iter = strats.Begin(); iter.IsValid(); ++iter) { Strategy *_strat = iter.Value().Ptr(); - if (Math::Compare(_strat.Get(_prop), _value, _op)) { + if (Math::Compare(_strat PTR_DEREF Get(_prop), _value, _op)) { return _strat; } } @@ -1010,9 +1016,10 @@ class EA : public Taskable { template Strategy *GetStrategyViaProp2(ENUM_STRATEGY_PARAM _prop1, T1 _value1, ENUM_STRATEGY_PARAM _prop2, T2 _value2, ENUM_MATH_CONDITION _op = MATH_COND_EQ) { - for (DictStructIterator> iter = strats.Begin(); iter.IsValid(); ++iter) { + for (DictStructIterator> iter = strats.Begin(); iter.IsValid(); ++iter) { Strategy *_strat = iter.Value().Ptr(); - if (Math::Compare(_strat.Get(_prop1), _value1, _op) && Math::Compare(_strat.Get(_prop2), _value2, _op)) { + if (Math::Compare(_strat PTR_DEREF Get(_prop1), _value1, _op) && + Math::Compare(_strat PTR_DEREF Get(_prop2), _value2, _op)) { return _strat; } } @@ -1032,7 +1039,7 @@ class EA : public Taskable { /** * Gets DictStruct reference to strategies. */ - DictStruct> *GetStrategies() { return GetPointer(strats); } + DictStruct> *GetStrategies() { return GetPointer(strats); } /** * Gets EA state. @@ -1054,7 +1061,7 @@ class EA : public Taskable { /** * Gets reference to strategies. */ - DictStruct> *Strategies() { return &strats; } + DictStruct> *Strategies() { return &strats; } /* Setters */ @@ -1104,9 +1111,9 @@ class EA : public Taskable { virtual void OnStrategyAdd(Strategy *_strat) { // Sets margin risk. float _margin_risk = eparams.Get(STRUCT_ENUM(EAParams, EA_PARAM_PROP_RISK_MARGIN_MAX)); - _strat.Set(TRADE_PARAM_RISK_MARGIN, _margin_risk); + _strat PTR_DEREF Set(TRADE_PARAM_RISK_MARGIN, _margin_risk); // Link a logger instance. - logger.Link(_strat.GetLogger()); + logger.Link(_strat PTR_DEREF GetLogger()); // Load existing strategy trades. StrategyLoadTrades(_strat); } @@ -1131,13 +1138,13 @@ class EA : public Taskable { SerializerNodeType Serialize(Serializer &_s) { _s.Pass(THIS_REF, "account", account, SERIALIZER_FIELD_FLAG_DYNAMIC); - for (DictStructIterator> _iter = GetStrategies().Begin(); _iter.IsValid(); ++_iter) { + for (DictStructIterator> _iter = GetStrategies() PTR_DEREF Begin(); _iter.IsValid(); ++_iter) { Strategy *_strat = _iter.Value().Ptr(); // @fixme: GH-422 - // _s.PassWriteOnly(this, "strat:" + _strat.GetName(), _strat); - string _sname = _strat.GetName(); // + "@" + Chart::TfToString(_strat.GetTf()); // @todo - string _sparams = _strat.GetParams().ToString(); - string _sresults = _strat.GetProcessResult().ToString(); + // _s.PassWriteOnly(this, "strat:" + _strat PTR_DEREF GetName(), _strat); + string _sname = _strat PTR_DEREF GetName(); // + "@" + Chart::TfToString(_strat PTR_DEREF GetTf()); // @todo + string _sparams = _strat PTR_DEREF GetParams().ToString(); + string _sresults = _strat PTR_DEREF GetProcessResult().ToString(); _s.Pass(THIS_REF, "strat:params:" + _sname, _sparams); _s.Pass(THIS_REF, "strat:results:" + _sname, _sresults); } diff --git a/EA.struct.h b/EA.struct.h index 48e260ecb..26f4ea3ff 100644 --- a/EA.struct.h +++ b/EA.struct.h @@ -31,6 +31,7 @@ #endif // Includes. +#include "Log.mqh" #include "Storage/DateTime.h" #include "Task/Task.struct.h" @@ -81,7 +82,7 @@ struct EAParams { }; // Struct special methods. - EAParams(string _name = __FILE__, ENUM_LOG_LEVEL _ll = V_INFO, unsigned long _magic = 0) + EAParams(string _name = __FILE__, ENUM_LOG_LEVEL _ll = V_INFO, uint64 _magic = 0) : author("unknown"), data_store(EA_DATA_STORE_NONE), flags(EA_PARAM_FLAG_NONE), diff --git a/Exchange/Account/AccountMt.h b/Exchange/Account/AccountMt.h index 4d18afaec..1d0baf860 100644 --- a/Exchange/Account/AccountMt.h +++ b/Exchange/Account/AccountMt.h @@ -220,14 +220,14 @@ class AccountMt { /** * Returns the current account number. */ - static long AccountNumber() { return AccountInfoInteger(ACCOUNT_LOGIN); } - long GetLogin() { return AccountNumber(); } + static int64 AccountNumber() { return AccountInfoInteger(ACCOUNT_LOGIN); } + int64 GetLogin() { return AccountNumber(); } /** * Returns leverage of the current account. */ - static long AccountLeverage() { return AccountInfoInteger(ACCOUNT_LEVERAGE); } - long GetLeverage() { return AccountLeverage(); } + static int64 AccountLeverage() { return AccountInfoInteger(ACCOUNT_LEVERAGE); } + int64 GetLeverage() { return AccountLeverage(); } /** * Returns the calculation mode for the Stop Out level. @@ -250,9 +250,9 @@ class AccountMt { * @return * Returns the limit orders (0 for unlimited). */ - static long AccountLimitOrders() { return AccountInfoInteger(ACCOUNT_LIMIT_ORDERS); } - long GetLimitOrders(unsigned int _max = 999) { - long _limit = AccountLimitOrders(); + static int64 AccountLimitOrders() { return AccountInfoInteger(ACCOUNT_LIMIT_ORDERS); } + int64 GetLimitOrders(unsigned int _max = 999) { + int64 _limit = AccountLimitOrders(); return _limit > 0 ? _limit : _max; } @@ -595,13 +595,13 @@ class AccountMt { ARRAY(DataParamEntry, _args); return AccountMt::CheckCondition(_cond, _args); } - bool CheckCondition(ENUM_ACCOUNT_CONDITION _cond, long _arg1) { + bool CheckCondition(ENUM_ACCOUNT_CONDITION _cond, int64 _arg1) { ARRAY(DataParamEntry, _args); DataParamEntry _param1 = _arg1; ArrayPushObject(_args, _param1); return AccountMt::CheckCondition(_cond, _args); } - bool CheckCondition(ENUM_ACCOUNT_CONDITION _cond, long _arg1, long _arg2) { + bool CheckCondition(ENUM_ACCOUNT_CONDITION _cond, int64 _arg1, int64 _arg2) { ARRAY(DataParamEntry, _args); DataParamEntry _param1 = _arg1; DataParamEntry _param2 = _arg2; @@ -666,7 +666,7 @@ class AccountMt { * @docs * - https://www.mql5.com/en/docs/account/accountinfointeger */ - static long AccountInfoInteger(ENUM_ACCOUNT_INFO_INTEGER _prop_id) { return ::AccountInfoInteger(_prop_id); } + static int64 AccountInfoInteger(ENUM_ACCOUNT_INFO_INTEGER _prop_id) { return ::AccountInfoInteger(_prop_id); } /** * Returns the string value of the appropriate account property. diff --git a/Exchange/Exchange.struct.h b/Exchange/Exchange.struct.h index cf73a8e0d..dcaf60dd4 100644 --- a/Exchange/Exchange.struct.h +++ b/Exchange/Exchange.struct.h @@ -38,5 +38,5 @@ struct ExchangeParams { // Constructors. ExchangeParams() {} ExchangeParams(const ExchangeParams &_eparams) {} - long id; + int64 id; }; diff --git a/Exchange/SymbolInfo/SymbolInfo.extern.h b/Exchange/SymbolInfo/SymbolInfo.extern.h index 8446ebe7d..5e1e381bd 100644 --- a/Exchange/SymbolInfo/SymbolInfo.extern.h +++ b/Exchange/SymbolInfo/SymbolInfo.extern.h @@ -32,7 +32,7 @@ // Define external global functions. #ifndef __MQL__ -extern long SymbolInfoInteger(string name, ENUM_SYMBOL_INFO_INTEGER prop_id); +extern int64 SymbolInfoInteger(string name, ENUM_SYMBOL_INFO_INTEGER prop_id); extern bool SymbolInfoMarginRate(string name, ENUM_ORDER_TYPE order_type, double &initial_margin_rate, double &maintenance_margin_rate); extern bool SymbolInfoTick(string symbol, MqlTick &tick); diff --git a/Exchange/SymbolInfo/SymbolInfo.h b/Exchange/SymbolInfo/SymbolInfo.h index 1b8c889df..2b3d5bc36 100644 --- a/Exchange/SymbolInfo/SymbolInfo.h +++ b/Exchange/SymbolInfo/SymbolInfo.h @@ -175,12 +175,12 @@ class SymbolInfo : public Object { * * @see: https://www.mql5.com/en/docs/constants/environment_state/marketinfoconstants */ - unsigned long GetVolume() { return SymbolInfoStatic::GetTick(symbol).volume; } + uint64 GetVolume() { return SymbolInfoStatic::GetTick(symbol).volume; } /** * Gets the last volume for the current price (without updating). */ - unsigned long GetLastVolume() { return last_tick.volume; } + uint64 GetLastVolume() { return last_tick.volume; } /** * Get summary volume of current session deals. @@ -358,7 +358,7 @@ class SymbolInfo : public Object { * * @see: https://book.mql4.com/appendix/limits */ - long GetTradeStopsLevel() { return SymbolInfoStatic::SymbolInfoInteger(symbol, SYMBOL_TRADE_STOPS_LEVEL); } + int64 GetTradeStopsLevel() { return SymbolInfoStatic::SymbolInfoInteger(symbol, SYMBOL_TRADE_STOPS_LEVEL); } /** * Get a contract lot size in the base currency. diff --git a/Exchange/SymbolInfo/SymbolInfo.struct.h b/Exchange/SymbolInfo/SymbolInfo.struct.h index 866fcd088..0bca2825e 100644 --- a/Exchange/SymbolInfo/SymbolInfo.struct.h +++ b/Exchange/SymbolInfo/SymbolInfo.struct.h @@ -34,8 +34,8 @@ #include "../../Serializer/Serializable.h" #include "../../Serializer/Serializer.h" #include "../../Std.h" -#include "SymbolInfo.struct.static.h" #include "../../Tick/Tick.struct.h" +#include "SymbolInfo.struct.static.h" // Defines struct to store symbol data. struct SymbolInfoEntry @@ -43,11 +43,11 @@ struct SymbolInfoEntry : public Serializable #endif { - double bid; // Current Bid price. - double ask; // Current Ask price. - double last; // Price of the last deal. - double spread; // Current spread. - unsigned long volume; // Volume for the current last price. + double bid; // Current Bid price. + double ask; // Current Ask price. + double last; // Price of the last deal. + double spread; // Current spread. + uint64 volume; // Volume for the current last price. // Constructors. SymbolInfoEntry() : bid(0), ask(0), last(0), spread(0), volume(0) {} SymbolInfoEntry(const MqlTick& _tick, const string _symbol = "") { diff --git a/Exchange/SymbolInfo/SymbolInfo.struct.static.h b/Exchange/SymbolInfo/SymbolInfo.struct.static.h index 84cc1f4cb..592062ffd 100644 --- a/Exchange/SymbolInfo/SymbolInfo.struct.static.h +++ b/Exchange/SymbolInfo/SymbolInfo.struct.static.h @@ -72,7 +72,7 @@ struct SymbolInfoStatic { * * @see: https://www.mql5.com/en/docs/constants/environment_state/marketinfoconstants */ - static unsigned long GetVolume(string _symbol) { return GetTick(_symbol).volume; } + static uint64 GetVolume(string _symbol) { return GetTick(_symbol).volume; } /** * Get summary volume of current session deals. @@ -298,7 +298,7 @@ struct SymbolInfoStatic { * * @see: https://book.mql4.com/appendix/limits */ - static long GetTradeStopsLevel(string _symbol) { + static int64 GetTradeStopsLevel(string _symbol) { return SymbolInfoStatic::SymbolInfoInteger(_symbol, SYMBOL_TRADE_STOPS_LEVEL); } @@ -481,7 +481,7 @@ struct SymbolInfoStatic { * @param ENUM_SYMBOL_INFO_INTEGER prop_id * Identifier of a property. * - * @return long + * @return int64 * Returns the value of the property. * In case of error, information can be obtained using GetLastError() function. * @@ -490,7 +490,7 @@ struct SymbolInfoStatic { * - https://www.mql5.com/en/docs/marketinformation/symbolinfointeger * */ - static long SymbolInfoInteger(string name, ENUM_SYMBOL_INFO_INTEGER prop_id) { + static int64 SymbolInfoInteger(string name, ENUM_SYMBOL_INFO_INTEGER prop_id) { return ::SymbolInfoInteger(name, prop_id); } diff --git a/Indicator/Indicator.h b/Indicator/Indicator.h index b01f0c31a..d3d22c4ab 100644 --- a/Indicator/Indicator.h +++ b/Indicator/Indicator.h @@ -477,10 +477,10 @@ class Indicator : public IndicatorData { */ virtual bool ExecuteAction(ENUM_INDICATOR_ACTION _action, ARRAY_REF(DataParamEntry, _args)) { bool _result = true; - long _arg1 = ArraySize(_args) > 0 ? DataParamEntry::ToInteger(_args[0]) : WRONG_VALUE; + int64 _arg1 = ArraySize(_args) > 0 ? DataParamEntry::ToInteger(_args[0]) : WRONG_VALUE; switch (_action) { case INDI_ACTION_CLEAR_CACHE: - _arg1 = _arg1 != 0 ? _arg1 : (long)TimeCurrent(); + _arg1 = _arg1 != 0 ? _arg1 : (int64)TimeCurrent(); Print("Action not yet implemented!"); DebugBreak(); // idata.Clear(_arg1); @@ -496,7 +496,7 @@ class Indicator : public IndicatorData { ARRAY(DataParamEntry, _args); return ExecuteAction(_action, _args); } - bool ExecuteAction(ENUM_INDICATOR_ACTION _action, long _arg1) { + bool ExecuteAction(ENUM_INDICATOR_ACTION _action, int64 _arg1) { ARRAY(DataParamEntry, _args); DataParamEntry _param1 = _arg1; ArrayPushObject(_args, _param1); @@ -555,13 +555,13 @@ class Indicator : public IndicatorData { } else { if (_entry.CheckFlags(INDI_ENTRY_FLAG_IS_UNSIGNED)) { if (_entry.CheckFlags(INDI_ENTRY_FLAG_IS_DOUBLED)) { - _result &= !_entry.HasValue(ULONG_MAX); + _result &= !_entry.HasValue(ULONG_MAX); } else { _result &= !_entry.HasValue(UINT_MAX); } } else { if (_entry.CheckFlags(INDI_ENTRY_FLAG_IS_DOUBLED)) { - _result &= !_entry.HasValue(LONG_MAX); + _result &= !_entry.HasValue(LONG_MAX); } else { _result &= !_entry.HasValue(INT_MAX); } @@ -585,7 +585,7 @@ class Indicator : public IndicatorData { */ IndicatorDataEntry GetEntry(int _rel_shift = 0) override { ResetLastError(); - long _bar_time = GetBarTime(_rel_shift); + int64 _bar_time = GetBarTime(_rel_shift); if (Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_IDSTYPE)) == IDATA_BUILTIN && (GetPossibleDataModes() & IDATA_BUILTIN) == 0) { @@ -620,13 +620,13 @@ class Indicator : public IndicatorData { _entry.values[_mode] = GetValue(_mode, _rel_shift); break; case TYPE_LONG: - _entry.values[_mode] = GetValue(_mode, _rel_shift); + _entry.values[_mode] = GetValue(_mode, _rel_shift); break; case TYPE_UINT: _entry.values[_mode] = GetValue(_mode, _rel_shift); break; case TYPE_ULONG: - _entry.values[_mode] = GetValue(_mode, _rel_shift); + _entry.values[_mode] = GetValue(_mode, _rel_shift); break; case TYPE_DOUBLE: _entry.values[_mode] = GetValue(_mode, _rel_shift); diff --git a/Indicator/IndicatorBase.h b/Indicator/IndicatorBase.h index 8bc2f86f2..93988e235 100644 --- a/Indicator/IndicatorBase.h +++ b/Indicator/IndicatorBase.h @@ -261,14 +261,14 @@ class IndicatorBase : public Object { * * If local history is empty (not loaded), function returns 0. */ - virtual long GetSpread(int _shift = 0) = 0; + virtual int64 GetSpread(int _shift = 0) = 0; /** * Returns volume value for the bar. * * If local history is empty (not loaded), function returns 0. */ - virtual long GetVolume(int _shift = 0) = 0; + virtual int64 GetVolume(int _shift = 0) = 0; /** * Returns indicator value for a given shift and mode. @@ -281,7 +281,7 @@ class IndicatorBase : public Object { /* virtual bool HasValidEntry(int _index = 0) { unsigned int position; - long bar_time = GetBarTime(_index); + int64 bar_time = GetBarTime(_index); return bar_time > 0 && idata.KeyExists(bar_time, position) ? idata.GetByPos(position).IsValid() : false; } */ diff --git a/Indicator/IndicatorCandle.h b/Indicator/IndicatorCandle.h index 3f53afd4c..4e8121c02 100644 --- a/Indicator/IndicatorCandle.h +++ b/Indicator/IndicatorCandle.h @@ -224,7 +224,7 @@ class IndicatorCandle : public Indicator { * * If local history is empty (not loaded), function returns 0. */ - long GetVolume(int _shift = 0) override { + int64 GetVolume(int _shift = 0) override { CandleOCTOHLC _candle; if (history.TryGetItemByShift(_shift, _candle)) { @@ -239,14 +239,14 @@ class IndicatorCandle : public Indicator { * * If local history is empty (not loaded), function returns 0. */ - long GetSpread(int _shift = 0) override { return 0; } + int64 GetSpread(int _shift = 0) override { return 0; } /** * Returns tick volume value for the bar. * * If local history is empty (not loaded), function returns 0. */ - long GetTickVolume(int _shift = 0) override { return GetVolume(); } + int64 GetTickVolume(int _shift = 0) override { return GetVolume(); } /** * Returns the indicator's data entry. @@ -283,7 +283,7 @@ class IndicatorCandle : public Indicator { case INDI_CANDLE_MODE_SPREAD: case INDI_CANDLE_MODE_TICK_VOLUME: case INDI_CANDLE_MODE_VOLUME: - THIS_ATTR value_storages[_mode] = new IndicatorBufferValueStorage(THIS_PTR, _mode); + THIS_ATTR value_storages[_mode] = new IndicatorBufferValueStorage(THIS_PTR, _mode); break; case INDI_CANDLE_MODE_TIME: THIS_ATTR value_storages[_mode] = new IndicatorBufferValueStorage(THIS_PTR, _mode); @@ -309,7 +309,7 @@ class IndicatorCandle : public Indicator { /** * Converts candle into indicator's data entry. */ - IndicatorDataEntry CandleToEntry(long _timestamp, CandleOCTOHLC& _candle) { + IndicatorDataEntry CandleToEntry(int64 _timestamp, CandleOCTOHLC& _candle) { IndicatorDataEntry _entry(FINAL_INDI_CANDLE_MODE_ENTRY); _entry.timestamp = _timestamp; _entry.values[INDI_CANDLE_MODE_PRICE_OPEN] = _candle.open; diff --git a/Indicator/IndicatorCandle.provider.h b/Indicator/IndicatorCandle.provider.h index 17d46c3f5..d3f44b761 100644 --- a/Indicator/IndicatorCandle.provider.h +++ b/Indicator/IndicatorCandle.provider.h @@ -43,7 +43,7 @@ class ItemsHistoryCandleProvider : public ItemsHistoryItemProvider, ItemsHistoryItemProvider>>* _history, long _time_ms, + void OnTick(ItemsHistory, ItemsHistoryItemProvider>>* _history, int64 _time_ms, float _ask, float _bid) { // Should be overrided. } @@ -52,7 +52,7 @@ class ItemsHistoryCandleProvider : public ItemsHistoryItemProvider, ItemsHistoryCandleProvider>* _history, long _from_time_ms, + void GetItems(ItemsHistory, ItemsHistoryCandleProvider>* _history, int64 _from_time_ms, ENUM_ITEMS_HISTORY_DIRECTION _dir, int _num_items, ARRAY_REF(CandleOCTOHLC, _out_arr)) { // Method is called if there is a missing item (candle) in the history. We need to regenerate it. Print("Error: Retrieving items by this item provider is not implemented!"); diff --git a/Indicator/IndicatorData.enum.h b/Indicator/IndicatorData.enum.h index 2a29107e1..941f22bd6 100644 --- a/Indicator/IndicatorData.enum.h +++ b/Indicator/IndicatorData.enum.h @@ -34,11 +34,11 @@ enum INDICATOR_DATA_ENTRY_FLAGS { INDI_ENTRY_FLAG_NONE = 0 << 0, INDI_ENTRY_FLAG_IS_BITWISE = 1 << 0, - INDI_ENTRY_FLAG_IS_DOUBLED = 1 << 1, // Type is doubled in size (e.g. double or long). + INDI_ENTRY_FLAG_IS_DOUBLED = 1 << 1, // Type is doubled in size (e.g. double or int64). INDI_ENTRY_FLAG_IS_EXPIRED = 1 << 2, INDI_ENTRY_FLAG_IS_REAL = 1 << 3, // Type is real (float or double). INDI_ENTRY_FLAG_IS_PRICE = 1 << 4, - INDI_ENTRY_FLAG_IS_UNSIGNED = 1 << 5, // Type is unsigned (unsigned int or unsigned long). + INDI_ENTRY_FLAG_IS_UNSIGNED = 1 << 5, // Type is unsigned (unsigned int or uint64). INDI_ENTRY_FLAG_IS_VALID = 1 << 6, INDI_ENTRY_FLAG_INSUFFICIENT_DATA = 1 << 7, // Entry has missing value for that shift and probably won't ever have. }; diff --git a/Indicator/IndicatorData.h b/Indicator/IndicatorData.h index 7445a8d2f..5289778ee 100644 --- a/Indicator/IndicatorData.h +++ b/Indicator/IndicatorData.h @@ -57,11 +57,11 @@ class IndicatorData : public IndicatorBase { // Class variables. bool do_draw; bool indicator_builtin; - bool is_fed; // Whether calc_start_bar is already calculated. - int calc_start_bar; // Index of the first valid bar (from 0). - int flags; // Flags such as INDI_FLAG_INDEXABLE_BY_SHIFT. - int last_tick_index; // Index of the last tick. - long first_tick_time_ms; // Time of the first ask/bid tick. + bool is_fed; // Whether calc_start_bar is already calculated. + int calc_start_bar; // Index of the first valid bar (from 0). + int flags; // Flags such as INDI_FLAG_INDEXABLE_BY_SHIFT. + int last_tick_index; // Index of the last tick. + int64 first_tick_time_ms; // Time of the first ask/bid tick. void* mydata; bool last_tick_result; // Result of the last Tick() invocation. ENUM_INDI_DATA_VS_TYPE retarget_ap_av; // Value storage type to be used as applied price/volume. @@ -212,7 +212,7 @@ class IndicatorData : public IndicatorBase { * Returns time of the first ask/bid tick (time of first global OnTick()). * Time is compatible with time generated by IndicatorTick, e.g., Indi_TickMt. */ - long GetFirstTickTimeMs() { return first_tick_time_ms; } + int64 GetFirstTickTimeMs() { return first_tick_time_ms; } /** * Get full name of the indicator (with "over ..." part). @@ -260,7 +260,7 @@ class IndicatorData : public IndicatorBase { _price = (float)GetPrice(_ap, _shift); } else if (_idvrange == IDATA_RANGE_PRICE) { // When indicator values are the actual prices. - T _values[4]; + FIXED_ARRAY(T, _values, 4); if (!CopyValues(_values, 4, _shift, _mode)) { // When values aren't valid, return 0. return _price; @@ -1314,7 +1314,7 @@ class IndicatorData : public IndicatorBase { * * If local history is empty (not loaded), function returns 0. */ - long GetSpread(int _shift = 0) override { return GetCandle() PTR_DEREF GetSpread(_shift); } + int64 GetSpread(int _shift = 0) override { return GetCandle() PTR_DEREF GetSpread(_shift); } /** * Returns spread in pips. @@ -1452,7 +1452,7 @@ class IndicatorData : public IndicatorBase { * * If local history is empty (not loaded), function returns 0. */ - virtual long GetTickVolume(int _shift = 0) { return GetCandle() PTR_DEREF GetTickVolume(_shift); } + virtual int64 GetTickVolume(int _shift = 0) { return GetCandle() PTR_DEREF GetTickVolume(_shift); } /** * Removes candle from the buffer. Used mainly for testing purposes. @@ -1462,12 +1462,12 @@ class IndicatorData : public IndicatorBase { /** * Fetches historic ticks for a given time range. */ - bool FetchHistoryByTimeRange(long _from_ms, long _to_ms, ARRAY_REF(TickTAB, _out_ticks)) { return false; } + bool FetchHistoryByTimeRange(int64 _from_ms, int64 _to_ms, ARRAY_REF(TickTAB, _out_ticks)) { return false; } /** * Fetches historic ticks for a given start time and minimum number of tick to retrieve. */ - bool FetchHistoryByStartTimeAndCount(long _from_ms, ENUM_ITEMS_HISTORY_DIRECTION _dir, int _min_count, + bool FetchHistoryByStartTimeAndCount(int64 _from_ms, ENUM_ITEMS_HISTORY_DIRECTION _dir, int _min_count, ARRAY_REF(TickTAB, _out_ticks)) { // Print("FetchHistoryByStartTimeAndCount:"); // Print("- Requested _from_ms = ", _from_ms, ", _dir = ", EnumToString(_dir), ", _min_count = ", _min_count); @@ -1481,7 +1481,7 @@ class IndicatorData : public IndicatorBase { static ARRAY(TickTAB, _recv_ticks); // Time-frames for which we'll be receiving ticks. - long _recv_range_ms = 1000 * 60 * 30; // 30 min time-frames. + int64 _recv_range_ms = 1000 * 60 * 30; // 30 min time-frames. // Calculating initial time frame. if (_dir == ITEMS_HISTORY_DIRECTION_BACKWARD) { @@ -1489,7 +1489,7 @@ class IndicatorData : public IndicatorBase { _from_ms -= _recv_range_ms - 1; } // _to_ms will be at the last ms of _from_ms's timeframe. - long _to_ms = _from_ms + _recv_range_ms - 1; + int64 _to_ms = _from_ms + _recv_range_ms - 1; // Print("- Initial _from_ms = ", _from_ms, "_to_ms = ", _to_ms); @@ -1773,7 +1773,7 @@ class IndicatorData : public IndicatorBase { * * If local history is empty (not loaded), function returns 0. */ - long GetVolume(int _shift = 0) override { return GetCandle() PTR_DEREF GetVolume(_shift); } + int64 GetVolume(int _shift = 0) override { return GetCandle() PTR_DEREF GetVolume(_shift); } /** * Sends entry to listening indicators. diff --git a/Indicator/IndicatorData.struct.h b/Indicator/IndicatorData.struct.h index ab660f3f9..1c35698a6 100644 --- a/Indicator/IndicatorData.struct.h +++ b/Indicator/IndicatorData.struct.h @@ -44,7 +44,7 @@ union IndicatorDataEntryTypelessValue { double vdbl; float vflt; int vint; - long vlong; + int64 vlong; }; // Type-aware value for IndicatorDataEntry class. @@ -129,7 +129,7 @@ struct IndicatorDataEntryValue { double GetDbl() { return value.vdbl; } float GetFloat() { return value.vflt; } int GetInt() { return value.vint; } - long GetLong() { return value.vlong; } + int64 GetLong() { return value.vlong; } template void Get(T &_out) { _out = Get(); @@ -145,8 +145,8 @@ struct IndicatorDataEntryValue { void Get(float &_out) { _out = value.vflt; } void Get(int &_out) { _out = value.vint; } void Get(unsigned int &_out) { _out = (unsigned int)value.vint; } - void Get(long &_out) { _out = value.vlong; } - void Get(unsigned long &_out) { _out = (unsigned long)value.vint; } + void Get(int64 &_out) { _out = value.vlong; } + void Get(uint64 &_out) { _out = (uint64)value.vint; } // Setters. template void Set(T _value) { @@ -168,12 +168,12 @@ struct IndicatorDataEntryValue { value.vint = (int)_value; SetDataType(TYPE_UINT); } - void Set(long _value) { + void Set(int64 _value) { value.vlong = _value; SetDataType(TYPE_LONG); } - void Set(unsigned long _value) { - value.vlong = (long)_value; + void Set(uint64 _value) { + value.vlong = (int64)_value; SetDataType(TYPE_ULONG); } // Serializers. @@ -188,7 +188,7 @@ struct IndicatorDataEntryValue { /* Structure for indicator data entry. */ struct IndicatorDataEntry { - long timestamp; // Timestamp of the entry's bar. + int64 timestamp; // Timestamp of the entry's bar. unsigned short flags; // Indicator entry flags. ARRAY(IndicatorDataEntryValue, values); @@ -331,7 +331,7 @@ struct IndicatorDataEntry { int GetDayOfYear() { return DateTimeStatic::DayOfYear(timestamp); } int GetMonth() { return DateTimeStatic::Month(timestamp); } int GetYear() { return DateTimeStatic::Year(timestamp); } - long GetTime() { return timestamp; }; + int64 GetTime() { return timestamp; }; ENUM_DATATYPE GetDataType(int _mode) { return values[_mode].GetDataType(); } unsigned short GetDataTypeFlags(ENUM_DATATYPE _dt) { switch (_dt) { diff --git a/Indicator/IndicatorRenko.h b/Indicator/IndicatorRenko.h index 47d1125b7..8c8d04382 100644 --- a/Indicator/IndicatorRenko.h +++ b/Indicator/IndicatorRenko.h @@ -76,9 +76,9 @@ class IndicatorRenko : public IndicatorCandle { /** * Called when new tick was emitted from IndicatorTick-based source. */ - virtual void OnTick(ItemsHistory, ItemsHistoryRenkoCandleProvider>* _history, long _time_ms, + virtual void OnTick(ItemsHistory, ItemsHistoryRenkoCandleProvider>* _history, int64 _time_ms, float _ask, float _bid) { ++tick_index; @@ -68,7 +68,7 @@ class ItemsHistoryRenkoCandleProvider : public ItemsHistoryCandleProvider { * Retrieves given number of items starting from the given microseconds or index (inclusive). "_dir" identifies if we * want previous or next items from selected starting point. */ - void GetItems(ItemsHistory, ItemsHistoryRenkoCandleProvider>* _history, long _from_time_ms, + void GetItems(ItemsHistory, ItemsHistoryRenkoCandleProvider>* _history, int64 _from_time_ms, ENUM_ITEMS_HISTORY_DIRECTION _dir, int _num_items, ARRAY_REF(CandleOCTOHLC, _out_arr)) { // Method is called if there is a missing item (candle) in the history. We need to regenerate it. diff --git a/Indicator/IndicatorTf.provider.h b/Indicator/IndicatorTf.provider.h index 09006e6fc..86903d22c 100644 --- a/Indicator/IndicatorTf.provider.h +++ b/Indicator/IndicatorTf.provider.h @@ -49,7 +49,7 @@ class ItemsHistoryTfCandleProvider : public ItemsHistoryCandleProvider { /** * Called when new tick was emitted from IndicatorTick-based source. */ - void OnTick(ItemsHistory, ItemsHistoryTfCandleProvider>* _history, long _time_ms, float _ask, + void OnTick(ItemsHistory, ItemsHistoryTfCandleProvider>* _history, int64 _time_ms, float _ask, float _bid) { ++tick_index; @@ -106,15 +106,15 @@ class ItemsHistoryTfCandleProvider : public ItemsHistoryCandleProvider { /** * Returns start time of the candle (the place it's on the chart) for the given tick's time in milliseconds. */ - int GetCandleTimeFromTimeMs(long _time_ms, int _length_in_secs) { - return (int)((_time_ms - _time_ms % ((long)_length_in_secs * 1000)) / 1000); + int GetCandleTimeFromTimeMs(int64 _time_ms, int _length_in_secs) { + return (int)((_time_ms - _time_ms % ((int64)_length_in_secs * 1000)) / 1000); } /** * Retrieves given number of items starting from the given microseconds or index (inclusive). "_dir" identifies if we * want previous or next items from selected starting point. */ - void GetItems(ItemsHistory, ItemsHistoryTfCandleProvider>* _history, long _from_time_ms, + void GetItems(ItemsHistory, ItemsHistoryTfCandleProvider>* _history, int64 _from_time_ms, ENUM_ITEMS_HISTORY_DIRECTION _dir, int _num_items, ARRAY_REF(CandleOCTOHLC, _out_arr)) { // Method is called if there is a missing item (candle) in the history. We need to regenerate it. if (_from_time_ms != 0) { @@ -131,9 +131,9 @@ class ItemsHistoryTfCandleProvider : public ItemsHistoryCandleProvider { while (_num_items > 0) { // Calculating time from which and to which we want to retrieve ticks to form a candle. int _ticks_from_s = GetCandleTimeFromTimeMs(_from_time_ms, spc); - long _ticks_from_ms = (long)_ticks_from_s * 1000; - long _candle_length_ms = (long)spc * 1000; - long _ticks_to_ms = _ticks_from_ms + _candle_length_ms - 1; + int64 _ticks_from_ms = (int64)_ticks_from_s * 1000; + int64 _candle_length_ms = (int64)spc * 1000; + int64 _ticks_to_ms = _ticks_from_ms + _candle_length_ms - 1; if (!_indi_tick PTR_DEREF FetchHistoryByTimeRange(_ticks_from_ms, _ticks_to_ms, _ticks)) { // There is no more ticks in the history, giving up. diff --git a/Indicator/IndicatorTick.h b/Indicator/IndicatorTick.h index 017dfd4ac..ca4d2cd9b 100644 --- a/Indicator/IndicatorTick.h +++ b/Indicator/IndicatorTick.h @@ -252,7 +252,7 @@ class IndicatorTick : public Indicator { * Converts TickAB into IndicatorDataEntry. */ template -IndicatorDataEntry TickToEntry(long _timestamp, TickAB& _tick) { +IndicatorDataEntry TickToEntry(int64 _timestamp, TickAB& _tick) { IndicatorDataEntry _entry(2); _entry.timestamp = _timestamp; _entry.values[INDI_TICK_MODE_PRICE_ASK] = _tick.ask; diff --git a/Indicator/IndicatorTick.provider.h b/Indicator/IndicatorTick.provider.h index cb11c45eb..7e113a3c3 100644 --- a/Indicator/IndicatorTick.provider.h +++ b/Indicator/IndicatorTick.provider.h @@ -50,7 +50,7 @@ class ItemsHistoryTickProvider : public ItemsHistoryItemProvider> { /** * Called when new tick was emitted from IndicatorTick-based source. */ - virtual void OnTick(ItemsHistory, ItemsHistoryTickProvider>* _history, long _time_ms, float _ask, + virtual void OnTick(ItemsHistory, ItemsHistoryTickProvider>* _history, int64 _time_ms, float _ask, float _bid) { TickTAB _tick(_time_ms, _ask, _bid); _history PTR_DEREF Append(_tick); @@ -60,7 +60,7 @@ class ItemsHistoryTickProvider : public ItemsHistoryItemProvider> { * Retrieves given number of items starting from the given microseconds or index (inclusive). "_dir" identifies if we * want previous or next items from selected starting point. */ - void GetItems(ItemsHistory, ItemsHistoryTickProvider>* _history, long _from_time_ms, + void GetItems(ItemsHistory, ItemsHistoryTickProvider>* _history, int64 _from_time_ms, ENUM_ITEMS_HISTORY_DIRECTION _dir, int _num_items, ARRAY_REF(TickTAB, _out_arr)) { // Method is called if there is a missing item (tick) in the history. We need to regenerate it. indi PTR_DEREF FetchHistoryByStartTimeAndCount(_from_time_ms, _dir, _num_items, _out_arr); diff --git a/Indicator/tests/IndicatorTf.test.mq5 b/Indicator/tests/IndicatorTf.test.mq5 index 58f48f951..2c5bdce85 100644 --- a/Indicator/tests/IndicatorTf.test.mq5 +++ b/Indicator/tests/IndicatorTf.test.mq5 @@ -27,12 +27,12 @@ */ // Includes. +#include "../../Exchange/SymbolInfo/SymbolInfo.h" #include "../../Indicators/Indi_AMA.mqh" #include "../../Indicators/Tick/Indi_TickMt.h" #include "../../Log.mqh" #include "../../Platform/Platform.h" #include "../../Storage/Dict/DictBase.h" -#include "../../Exchange/SymbolInfo/SymbolInfo.h" #include "../../Test.mqh" #include "../../Util.h" #include "../IndicatorTf.h" @@ -119,7 +119,7 @@ void OnTick() { string c = DoubleToStr(iClose(_Symbol, PERIOD_CURRENT, 0), 5); string time = TimeToString(iTime(_Symbol, PERIOD_CURRENT, 0), TIME_DATE | TIME_MINUTES | TIME_SECONDS); - Util::Print("Tick: " + IntegerToString((long)iTime(indi_tf_real.Ptr().GetSymbol(), indi_tf_real.Ptr().GetTf(), 0)) + + Util::Print("Tick: " + IntegerToString((int64)iTime(indi_tf_real.Ptr().GetSymbol(), indi_tf_real.Ptr().GetTf(), 0)) + " (" + time + "), real = " + o + ", " + h + ", " + l + ", " + c); string c_o = DoubleToStr(indi_tf_real.Ptr().GetOpen(0), 5); diff --git a/Indicator/tests/IndicatorTick.test.mq5 b/Indicator/tests/IndicatorTick.test.mq5 index 5a59968f3..dddd25b2b 100644 --- a/Indicator/tests/IndicatorTick.test.mq5 +++ b/Indicator/tests/IndicatorTick.test.mq5 @@ -39,7 +39,7 @@ int OnInit() { Ref _indi_tick = new IndicatorTickDummy(_Symbol); Platform::Add(_indi_tick.Ptr()); - long _time = 1; + int64 _time = 1; for (double _price = 0.1; _price <= 2.0; _price += 0.1) { TickTAB _tick(_time++ * 1000, _price, _price); diff --git a/Indicators/Indi_CHO.mqh b/Indicators/Indi_CHO.mqh index 35d6ec999..044b572bc 100644 --- a/Indicators/Indi_CHO.mqh +++ b/Indicators/Indi_CHO.mqh @@ -189,7 +189,7 @@ class Indi_CHO : public Indicator { return (rates_total); } - static double AD(double high, double low, double close, long volume) { + static double AD(double high, double low, double close, int64 volume) { double res = 0.0; double sum = (close - low) - (high - close); if (sum != 0.0) { diff --git a/Indicators/Indi_PriceVolumeTrend.mqh b/Indicators/Indi_PriceVolumeTrend.mqh index 536afd406..989322c9e 100644 --- a/Indicators/Indi_PriceVolumeTrend.mqh +++ b/Indicators/Indi_PriceVolumeTrend.mqh @@ -138,7 +138,7 @@ class Indi_PriceVolumeTrend : public Indicator { } static void CalculatePVT(const int pos, const int rates_total, ValueStorage &close, - ValueStorage &volume, ValueStorage &ExtPVTBuffer) { + ValueStorage &volume, ValueStorage &ExtPVTBuffer) { for (int i = pos; i < rates_total && !IsStopped(); i++) { double prev_close = close[i - 1].Get(); // Calculate PVT value. diff --git a/Indicators/Indi_StdDev.mqh b/Indicators/Indi_StdDev.mqh index f588ed39e..89113cb40 100644 --- a/Indicators/Indi_StdDev.mqh +++ b/Indicators/Indi_StdDev.mqh @@ -215,7 +215,7 @@ class Indi_StdDev : public Indicator { _indi_ma.SetDataSource(_indi_price_feeder, 0); // Using first and only mode from price feeder. double _result = iStdDevOnIndicator(_indi_ma, NULL, NULL, period, 0, PRICE_OPEN, 0); // Last parameter is unused. - // We don't want to store reference to indicator too long. + // We don't want to store reference to indicator too int64. _indi_ma.SetDataSource(NULL, 0); return _result; diff --git a/Indicators/Indi_VROC.mqh b/Indicators/Indi_VROC.mqh index 9dcb9cd0f..5da0890ab 100644 --- a/Indicators/Indi_VROC.mqh +++ b/Indicators/Indi_VROC.mqh @@ -144,7 +144,7 @@ class Indi_VROC : public Indicator { return (rates_total); } - static void CalculateVROC(const int pos, const int rates_total, ValueStorage &volume, + static void CalculateVROC(const int pos, const int rates_total, ValueStorage &volume, ValueStorage &ExtVROCBuffer, int ExtPeriodVROC) { for (int i = pos; i < rates_total && !IsStopped(); i++) { double prev_volume = (double)(volume[i - (ExtPeriodVROC - 1)].Get()); diff --git a/Indicators/Indi_Volumes.mqh b/Indicators/Indi_Volumes.mqh index 2552bbe8e..2456a469e 100644 --- a/Indicators/Indi_Volumes.mqh +++ b/Indicators/Indi_Volumes.mqh @@ -143,7 +143,7 @@ class Indi_Volumes : public Indicator { return (rates_total); } - static void CalculateVolume(const int pos, const int rates_total, ValueStorage &volume, + static void CalculateVolume(const int pos, const int rates_total, ValueStorage &volume, ValueStorage &ExtVolumesBuffer, ValueStorage &ExtColorsBuffer) { ExtVolumesBuffer[0] = (double)volume[0].Get(); ExtColorsBuffer[0] = 0.0; diff --git a/Indicators/Oscillator/Indi_RSI.h b/Indicators/Oscillator/Indi_RSI.h index 4248ffcf5..2836603ae 100644 --- a/Indicators/Oscillator/Indi_RSI.h +++ b/Indicators/Oscillator/Indi_RSI.h @@ -75,7 +75,7 @@ struct RSIGainLossData { * Implements the Relative Strength Index indicator. */ class Indi_RSI : public Indicator { - DictStruct aux_data; + DictStruct aux_data; public: /** @@ -174,8 +174,8 @@ class Indi_RSI : public Indicator { ENUM_APPLIED_PRICE _ap = PRICE_CLOSE, int _shift = 0) { INDI_REQUIRE_BARS_OR_RETURN_EMPTY(_target, _period + _shift + 1); // +1 because of _bar_time_prev. - long _bar_time_curr = _source PTR_DEREF GetBarTime(_shift); - long _bar_time_prev = _source PTR_DEREF GetBarTime(_shift + 1); + int64 _bar_time_curr = _source PTR_DEREF GetBarTime(_shift); + int64 _bar_time_prev = _source PTR_DEREF GetBarTime(_shift + 1); if (fmin(_bar_time_curr, _bar_time_prev) < 0) { // Return empty value on invalid bar time. return EMPTY_VALUE; diff --git a/Indicators/PriceRange/Indi_Pivot.h b/Indicators/PriceRange/Indi_Pivot.h index 286c3a5f6..39b35f259 100644 --- a/Indicators/PriceRange/Indi_Pivot.h +++ b/Indicators/PriceRange/Indi_Pivot.h @@ -105,7 +105,7 @@ class Indi_Pivot : public Indicator { * Returns IndicatorDataEntry struct filled with indicator values. */ virtual IndicatorDataEntry GetEntry(int _rel_shift = 0) { - long _bar_time = GetCandle() PTR_DEREF GetBarTime(_rel_shift); + int64 _bar_time = GetCandle() PTR_DEREF GetBarTime(_rel_shift); IndicatorDataEntry _entry = idata.GetByKey(_bar_time); if (_bar_time > 0 && !_entry.IsValid() && !_entry.CheckFlag(INDI_ENTRY_FLAG_INSUFFICIENT_DATA)) { ResetLastError(); diff --git a/Indicators/Tick/Indi_TickMt.h b/Indicators/Tick/Indi_TickMt.h index a9ec01337..449888b2a 100644 --- a/Indicators/Tick/Indi_TickMt.h +++ b/Indicators/Tick/Indi_TickMt.h @@ -88,7 +88,7 @@ class Indi_TickMt : public IndicatorTick= 0 ? (int)_index : iparams.GetShift(); - long _bar_time; + int64 _bar_time; _bar_time = GetBarTime(_ishift); TickAB _tick = itdata.GetByKey(_bar_time); @@ -118,7 +118,7 @@ class Indi_TickMt : public IndicatorTick, _out_ticks)) { + virtual bool FetchHistoryByTimeRange(int64 _from_ms, int64 _to_ms, ARRAY_REF(TickTAB, _out_ticks)) { ArrayResize(_out_ticks, 0); static ARRAY(MqlTick, _tmp_ticks); @@ -160,7 +160,7 @@ class Indi_TickMt : public IndicatorTick _tick(_ask, _bid); IndicatorDataEntry _entry(TickToEntry(_time, _tick)); diff --git a/Indicators/Tick/Indi_TickProvider.h b/Indicators/Tick/Indi_TickProvider.h index 2fb91090c..c592eb39b 100644 --- a/Indicators/Tick/Indi_TickProvider.h +++ b/Indicators/Tick/Indi_TickProvider.h @@ -98,7 +98,7 @@ class Indi_TickProvider : public IndicatorTick, _out_ticks)) { + bool FetchHistoryByTimeRange(int64 _from_ms, int64 _to_ms, ARRAY_REF(TickTAB, _out_ticks)) { #ifdef __debug_indicator__ Print("Indi_TickProvider::FetchHistoryByTimeRange(from_ms = ", _from_ms, ", to_ms = ", _to_ms, ")"); #endif diff --git a/Indicators/Tick/Indi_TickRandom.h b/Indicators/Tick/Indi_TickRandom.h index 6e7b6097c..f90f9c012 100644 --- a/Indicators/Tick/Indi_TickRandom.h +++ b/Indicators/Tick/Indi_TickRandom.h @@ -85,7 +85,7 @@ class Indi_TickRandom : public IndicatorTick, _out_ticks)) { + bool FetchHistoryByTimeRange(int64 _from_ms, int64 _to_ms, ARRAY_REF(TickTAB, _out_ticks)) { // No history. return false; } diff --git a/Indicators/tests/DrawIndicator.test.mq5 b/Indicators/tests/DrawIndicator.test.mq5 index 8dbe43521..6ea4a4e3e 100644 --- a/Indicators/tests/DrawIndicator.test.mq5 +++ b/Indicators/tests/DrawIndicator.test.mq5 @@ -28,15 +28,15 @@ //#define __debug_verbose__ // Includes. +#include "../../Indicator/Indicator.struct.serialize.h" #include "../../Storage/Dict/DictStruct.h" +#include "../../Test.mqh" #include "../DrawIndicator.mqh" -#include "../../Indicator/Indicator.struct.serialize.h" -#include "../PriceRange/Indi_Bands.h" #include "../Indi_Demo.mqh" -#include "../Price/Indi_MA.h" #include "../Oscillator/Indi_RSI.h" +#include "../Price/Indi_MA.h" #include "../Price/Indi_Price.h" -#include "../../Test.mqh" +#include "../PriceRange/Indi_Bands.h" // Global variables. Ref candles; @@ -67,7 +67,7 @@ void OnTick() { if (candles REF_DEREF IsNewBar()) { bar_processed++; - for (DictIterator> iter = Platform::GetIndicators() PTR_DEREF Begin(); iter.IsValid(); + for (DictIterator> iter = Platform::GetIndicators() PTR_DEREF Begin(); iter.IsValid(); ++iter) { IndicatorData *_indi = iter.Value().Ptr(); _indi.OnTick(Platform::GetGlobalTickIndex()); @@ -149,7 +149,7 @@ bool InitIndicators() { */ // We'll be drawing all indicators' values on the chart. - for (DictIterator> iter = Platform::GetIndicators() PTR_DEREF Begin(); iter.IsValid(); + for (DictIterator> iter = Platform::GetIndicators() PTR_DEREF Begin(); iter.IsValid(); ++iter) { // iter.Value() REF_DEREF SetPlot(true); // @fixme } @@ -162,7 +162,7 @@ bool InitIndicators() { */ bool PrintIndicators(string _prefix = "") { ResetLastError(); - for (DictIterator> iter = Platform::GetIndicators() PTR_DEREF Begin(); iter.IsValid(); + for (DictIterator> iter = Platform::GetIndicators() PTR_DEREF Begin(); iter.IsValid(); ++iter) { IndicatorData *_indi = iter.Value().Ptr(); if (_indi.Get(STRUCT_ENUM(IndicatorDataState, INDICATOR_DATA_STATE_PROP_IS_READY))) { diff --git a/Log.mqh b/Log.mqh index 3f3f711d1..32679ae95 100644 --- a/Log.mqh +++ b/Log.mqh @@ -156,7 +156,7 @@ class Log : public Object { * Reports an last error. */ bool AddLastError(string prefix = "", string suffix = ""); - bool AddLastError(string prefix, long suffix); + bool AddLastError(string prefix, int64 suffix); /** * Reports an error. @@ -337,6 +337,6 @@ class Log : public Object { bool Log::AddLastError(string prefix, string suffix) { return Add(V_ERROR, Terminal::GetLastErrorText(), prefix, suffix); } -bool Log::AddLastError(string prefix, long suffix) { +bool Log::AddLastError(string prefix, int64 suffix) { return Add(V_ERROR, Terminal::GetLastErrorText(), prefix, StringFormat("%d", suffix)); } diff --git a/MD5.mqh b/MD5.mqh index 265f9f5f5..bb1644eb9 100644 --- a/MD5.mqh +++ b/MD5.mqh @@ -65,7 +65,7 @@ class MD5 { int index = len % 64; // mod 64 int count = (len - index) / 64; - long a = 0x67452301, b = 0xEFCDAB89, c = 0x98BADCFE, d = 0x10325476; + int64 a = 0x67452301, b = 0xEFCDAB89, c = 0x98BADCFE, d = 0x10325476; int buff[16], last[16], i, k = 0, last_char[4], last_index; string item; for (i = 0; i < count; i++) { @@ -101,35 +101,35 @@ class MD5 { return result; } - static long F(long x, long y, long z) { return ((x & y) | ((~x) & z)); } + static int64 F(int64 x, int64 y, int64 z) { return ((x & y) | ((~x) & z)); } - static long G(long x, long y, long z) { return ((x & z) | (y & (~z))); } + static int64 G(int64 x, int64 y, int64 z) { return ((x & z) | (y & (~z))); } - static long H(long x, long y, long z) { return ((x ^ y ^ z)); } + static int64 H(int64 x, int64 y, int64 z) { return ((x ^ y ^ z)); } - static long I(long x, long y, long z) { return ((y ^ (x | (~z)))); } + static int64 I(int64 x, int64 y, int64 z) { return ((y ^ (x | (~z)))); } - static long AddUnsigned(long a, long b) { - long c = a + b; + static int64 AddUnsigned(int64 a, int64 b) { + int64 c = a + b; return (c); } - static long FF(long a, long b, long c, long d, long x, int s, long ac) { + static int64 FF(int64 a, int64 b, int64 c, int64 d, int64 x, int s, int64 ac) { a = AddUnsigned(a, AddUnsigned(AddUnsigned(F(b, c, d), x), ac)); return (AddUnsigned(RotateLeft(a, s), b)); } - static long GG(long a, long b, long c, long d, long x, int s, long ac) { + static int64 GG(int64 a, int64 b, int64 c, int64 d, int64 x, int s, int64 ac) { a = AddUnsigned(a, AddUnsigned(AddUnsigned(G(b, c, d), x), ac)); return (AddUnsigned(RotateLeft(a, s), b)); } - static long HH(long a, long b, long c, long d, long x, int s, long ac) { + static int64 HH(int64 a, int64 b, int64 c, int64 d, int64 x, int s, int64 ac) { a = AddUnsigned(a, AddUnsigned(AddUnsigned(H(b, c, d), x), ac)); return (AddUnsigned(RotateLeft(a, s), b)); } - static long II(long a, long b, long c, long d, long x, int s, long ac) { + static int64 II(int64 a, int64 b, int64 c, int64 d, int64 x, int s, int64 ac) { a = AddUnsigned(a, AddUnsigned(AddUnsigned(I(b, c, d), x), ac)); return (AddUnsigned(RotateLeft(a, s), b)); } @@ -138,17 +138,17 @@ class MD5 { * Implementation of right shift operation for unsigned int. * See: http://www.cnblogs.com/niniwzw/archive/2009/12/04/1617130.html */ - static long RotateLeft(long lValue, int iShiftBits) { + static int64 RotateLeft(int64 lValue, int iShiftBits) { if (iShiftBits == 32) return (lValue); - long result = (lValue << iShiftBits) | (((lValue >> 1) & 0x7fffffff) >> (31 - iShiftBits)); + int64 result = (lValue << iShiftBits) | (((lValue >> 1) & 0x7fffffff) >> (31 - iShiftBits)); return (result); } /** * Assume: ArraySize(x) == 16. */ - static void MD5Transform(long &a, long &b, long &c, long &d, int &x[]) { - long AA, BB, CC, DD; + static void MD5Transform(int64 &a, int64 &b, int64 &c, int64 &d, int &x[]) { + int64 AA, BB, CC, DD; int S11 = 7, S12 = 12, S13 = 17, S14 = 22; int S21 = 5, S22 = 9, S23 = 14, S24 = 20; int S31 = 4, S32 = 11, S33 = 16, S34 = 23; diff --git a/Market.mqh b/Market.mqh index 47d7a516c..08a74f74a 100644 --- a/Market.mqh +++ b/Market.mqh @@ -25,11 +25,12 @@ #define MARKET_MQH // Includes. +#include "Exchange/SymbolInfo/SymbolInfo.h" +#include "Exchange/SymbolInfo/SymbolInfo.struct.static.h" #include "Market.struct.h" #include "Math/Math.h" +#include "Platform/Chart/Chart.define.h" #include "Serializer/Serializer.h" -#include "Exchange/SymbolInfo/SymbolInfo.h" -#include "Exchange/SymbolInfo/SymbolInfo.struct.static.h" #include "Task/TaskCondition.enum.h" /** diff --git a/Math/Math.define.h b/Math/Math.define.h index 27c2409a6..439becf80 100644 --- a/Math/Math.define.h +++ b/Math/Math.define.h @@ -77,11 +77,11 @@ #endif #ifndef LONG_MIN -#define LONG_MIN std::numeric_limits::min() +#define LONG_MIN std::numeric_limits::min() #endif #ifndef LONG_MAX -#define LONG_MAX std::numeric_limits::max() +#define LONG_MAX std::numeric_limits::max() #endif #ifndef ULONG_MAX diff --git a/Platform/Chart/Chart.h b/Platform/Chart/Chart.h index 50893cdc2..8fe18d3fa 100644 --- a/Platform/Chart/Chart.h +++ b/Platform/Chart/Chart.h @@ -66,21 +66,18 @@ ChartPriceOpen Open; int iBarShift(string _symbol, int _tf, datetime _time, bool _exact = false) { return ChartStatic::iBarShift(_symbol, (ENUM_TIMEFRAMES)_tf, _time, _exact); } -double iClose(string _symbol, int _tf, int _shift) { - return ChartStatic::iClose(_symbol, (ENUM_TIMEFRAMES)_tf, _shift); -} #endif #ifndef __MQL__ struct MqlRates { - datetime time; // Period start time - double open; // Open price - double high; // The highest price of the period - double low; // The lowest price of the period - double close; // Close price - long tick_volume; // Tick volume - int spread; // Spread - long real_volume; // Trade volume + datetime time; // Period start time + double open; // Open price + double high; // The highest price of the period + double low; // The lowest price of the period + double close; // Close price + int64 tick_volume; // Tick volume + int spread; // Spread + int64 real_volume; // Trade volume }; #endif @@ -99,7 +96,7 @@ class Chart : public Market { // Stores indicator instances. // @todo - // Dict indis; + // Dict indis; // Variables. datetime last_bar_time; diff --git a/Platform/Chart/Chart.struct.h b/Platform/Chart/Chart.struct.h index 0570bd4ca..6bd9477ce 100644 --- a/Platform/Chart/Chart.struct.h +++ b/Platform/Chart/Chart.struct.h @@ -35,15 +35,15 @@ class Class; struct ChartTf; // Includes. -#include "../../Storage/Array.h" #include "../../Bar.struct.h" +#include "../../Serializer/Serializer.h" +#include "../../Serializer/SerializerNode.enum.h" +#include "../../Storage/Array.h" +#include "../Terminal.define.h" #include "Chart.define.h" #include "Chart.enum.h" #include "Chart.struct.static.h" #include "Chart.struct.tf.h" -#include "../../Serializer/Serializer.h" -#include "../../Serializer/SerializerNode.enum.h" -#include "../Terminal.define.h" /* Defines struct to store bar entries. */ struct ChartEntry { @@ -64,15 +64,15 @@ struct ChartEntry { /* Defines struct for chart parameters. */ struct ChartParams { - long id; + int64 id; string symbol; ChartTf tf; // Copy constructor. ChartParams(ChartParams& _cparams) : symbol(_cparams.symbol), tf(_cparams.tf) {} // Constructors. - ChartParams(ENUM_TIMEFRAMES _tf = PERIOD_CURRENT, string _symbol = NULL, long _id = 0) + ChartParams(ENUM_TIMEFRAMES _tf = PERIOD_CURRENT, string _symbol = NULL, int64 _id = 0) : id(_id), symbol(_symbol), tf(_tf){}; - ChartParams(ENUM_TIMEFRAMES_INDEX _tfi, string _symbol = NULL, long _id = 0) : id(_id), symbol(_symbol), tf(_tfi){}; + ChartParams(ENUM_TIMEFRAMES_INDEX _tfi, string _symbol = NULL, int64 _id = 0) : id(_id), symbol(_symbol), tf(_tfi){}; // Getters. template T Get(ENUM_CHART_PARAM _param) { @@ -97,7 +97,7 @@ struct ChartParams { void Set(ENUM_CHART_PARAM _param, T _value) { switch (_param) { case CHART_PARAM_ID: - id = (long)_value; + id = (int64)_value; return; case CHART_PARAM_SYMBOL: symbol = (string)_value; diff --git a/Platform/Chart/Chart.struct.static.h b/Platform/Chart/Chart.struct.static.h index 7c5269129..fae59fb87 100644 --- a/Platform/Chart/Chart.struct.static.h +++ b/Platform/Chart/Chart.struct.static.h @@ -31,10 +31,10 @@ #endif // Includes. -#include "Chart.define.h" -#include "Chart.symboltf.h" #include "../Platform.extern.h" #include "../Terminal.define.h" +#include "Chart.define.h" +#include "Chart.symboltf.h" /* Defines struct for chart static methods. */ struct ChartStatic { @@ -304,10 +304,10 @@ struct ChartStatic { * * If local history is empty (not loaded), function returns 0. */ - static long iVolume(string _symbol = NULL, ENUM_TIMEFRAMES _tf = PERIOD_CURRENT, int _shift = 0) { + static int64 iVolume(string _symbol = NULL, ENUM_TIMEFRAMES _tf = PERIOD_CURRENT, int _shift = 0) { #ifdef __MQL4__ ResetLastError(); - long _volume = ::iVolume(_symbol, _tf, _shift); // Same as: Volume[_shift] + int64 _volume = ::iVolume(_symbol, _tf, _shift); // Same as: Volume[_shift] if (_LastError != ERR_NO_ERROR) { _volume = EMPTY_VALUE; ResetLastError(); @@ -354,5 +354,5 @@ struct ChartStatic { /** * Gets Chart ID. */ - static long ID() { return ::ChartID(); } + static int64 ID() { return ::ChartID(); } }; diff --git a/Platform/Chart/ChartBase.h b/Platform/Chart/ChartBase.h index ab7160bef..cf3b939c7 100644 --- a/Platform/Chart/ChartBase.h +++ b/Platform/Chart/ChartBase.h @@ -38,9 +38,9 @@ #include "Chart.struct.h" #include "Chart.symboltf.h" #include "Data.define.h" -#include "Storage/Dict/Dict.h" #include "Log.mqh" #include "Refs.mqh" +#include "Storage/Dict/Dict.h" #include "Task/TaskCondition.enum.h" /** @@ -193,7 +193,7 @@ class ChartBase : public Dynamic { * * If local history is empty (not loaded), function returns 0. */ - virtual long GetVolume(int _shift = 0) = 0; + virtual int64 GetVolume(int _shift = 0) = 0; /** * Returns the shift of the maximum value over a specific number of periods depending on type. @@ -386,10 +386,10 @@ class ChartBase : public Dynamic { int nBarsInNearPr = 0; ENUM_TIMEFRAMES TimeNearPr = PERIOD_M1; double ModellingQuality = 0; - long StartGen = 0; - long StartBar = 0; - long StartGenM1 = 0; - long HistoryTotal = 0; + int64 StartGen = 0; + int64 StartBar = 0; + int64 StartGenM1 = 0; + int64 HistoryTotal = 0; datetime x = StrToTime("1971.01.01 00:00"); datetime modeling_start_time = StrToTime("1971.01.01 00:00"); @@ -697,7 +697,7 @@ class ChartBase : public Dynamic { /** * Return size of BarOHLC array. */ - unsigned long SizeChartEntry() { return ArraySize(chart_saves); } + uint64 SizeChartEntry() { return ArraySize(chart_saves); } /* Serializers */ diff --git a/Platform/Chart/ChartMt.h b/Platform/Chart/ChartMt.h index da5b895b1..6dc74488e 100644 --- a/Platform/Chart/ChartMt.h +++ b/Platform/Chart/ChartMt.h @@ -31,9 +31,9 @@ #endif // Includes. +#include "../Terminal.define.h" #include "Chart.struct.static.h" #include "Chart.symboltf.h" -#include "../Terminal.define.h" #ifdef __DISABLED @@ -214,7 +214,7 @@ class ChartMt : public ChartBase { * * If local history is empty (not loaded), function returns 0. */ - virtual long GetVolume(int _shift = 0) override { return ::iVolume(GetSymbol(), GetTf(), _shift); } + virtual int64 GetVolume(int _shift = 0) override { return ::iVolume(GetSymbol(), GetTf(), _shift); } }; #endif diff --git a/Platform/Chart3D/Interface.h b/Platform/Chart3D/Interface.h index c833094f3..b86f80ed4 100644 --- a/Platform/Chart3D/Interface.h +++ b/Platform/Chart3D/Interface.h @@ -58,7 +58,7 @@ struct InterfaceEvent { * * Invoked when the ChartEvent event occurs. */ -void OnChartEvent(const int id, const long& lparam, const double& dparam, const string& sparam) { +void OnChartEvent(const int id, const int64& lparam, const double& dparam, const string& sparam) { datetime _dt; double _mp; int _window = 0; diff --git a/Platform/Chart3D/Math.h b/Platform/Chart3D/Math.h index 78c283976..25cd12e1d 100644 --- a/Platform/Chart3D/Math.h +++ b/Platform/Chart3D/Math.h @@ -216,10 +216,10 @@ struct DXQuaternion { //| DViewport | //+------------------------------------------------------------------+ struct DViewport { - unsigned long x; - unsigned long y; - unsigned long width; - unsigned long height; + uint64 x; + uint64 y; + uint64 width; + uint64 height; float minz; float maxz; }; diff --git a/Platform/Chart3D/Mesh.h b/Platform/Chart3D/Mesh.h index cf8a200d0..0597b3484 100644 --- a/Platform/Chart3D/Mesh.h +++ b/Platform/Chart3D/Mesh.h @@ -48,7 +48,7 @@ class Device; template struct PointEntry { T point; - long key; + int64 key; // Default constructor. PointEntry() {} @@ -66,9 +66,9 @@ struct PointEntry { return key == MakeKey(_r.point.Position.x, _r.point.Position.y, _r.point.Position.z); } - static long MakeKey(float x, float y, float z) { - return long(x / GFX_MESH_LOOKUP_PRECISION) + 4194304 * long(y / GFX_MESH_LOOKUP_PRECISION) + - 17592186044416 * long(z / GFX_MESH_LOOKUP_PRECISION); + static int64 MakeKey(float x, float y, float z) { + return int64(x / GFX_MESH_LOOKUP_PRECISION) + 4194304 * int64(y / GFX_MESH_LOOKUP_PRECISION) + + 17592186044416 * int64(z / GFX_MESH_LOOKUP_PRECISION); } }; diff --git a/Platform/MQL5.mqh b/Platform/MQL5.mqh index 1138325b6..d848b43ae 100644 --- a/Platform/MQL5.mqh +++ b/Platform/MQL5.mqh @@ -38,273 +38,284 @@ // @see: https://www.mql5.com/en/docs/constants/errorswarnings #ifdef __MQL4__ // Return codes of the trade server. -#define TRADE_RETCODE_REQUOTE 10004 // Requote -#define TRADE_RETCODE_REJECT 10006 // Request rejected -#define TRADE_RETCODE_CANCEL 10007 // Request canceled by trader -#define TRADE_RETCODE_PLACED 10008 // Order placed -#define TRADE_RETCODE_DONE 10009 // Request completed -#define TRADE_RETCODE_DONE_PARTIAL 10010 // Only part of the request was completed -#define TRADE_RETCODE_ERROR 10011 // Request processing error -#define TRADE_RETCODE_TIMEOUT 10012 // Request canceled by timeout -#define TRADE_RETCODE_INVALID 10013 // Invalid request -#define TRADE_RETCODE_INVALID_VOLUME 10014 // Invalid volume in the request -#define TRADE_RETCODE_INVALID_PRICE 10015 // Invalid price in the request -#define TRADE_RETCODE_INVALID_STOPS 10016 // Invalid stops in the request -#define TRADE_RETCODE_TRADE_DISABLED 10017 // Trade is disabled -#define TRADE_RETCODE_MARKET_CLOSED 10018 // Market is closed -#define TRADE_RETCODE_NO_MONEY 10019 // There is not enough money to complete the request -#define TRADE_RETCODE_PRICE_CHANGED 10020 // Prices changed -#define TRADE_RETCODE_PRICE_OFF 10021 // There are no quotes to process the request -#define TRADE_RETCODE_INVALID_EXPIRATION 10022 // Invalid order expiration date in the request -#define TRADE_RETCODE_ORDER_CHANGED 10023 // Order state changed -#define TRADE_RETCODE_TOO_MANY_REQUESTS 10024 // Too frequent requests -#define TRADE_RETCODE_NO_CHANGES 10025 // No changes in request -#define TRADE_RETCODE_SERVER_DISABLES_AT 10026 // Autotrading disabled by server -#define TRADE_RETCODE_CLIENT_DISABLES_AT 10027 // Autotrading disabled by client terminal -#define TRADE_RETCODE_LOCKED 10028 // Request locked for processing -#define TRADE_RETCODE_FROZEN 10029 // Order or position frozen -#define TRADE_RETCODE_INVALID_FILL 10030 // Invalid order filling type -#define TRADE_RETCODE_CONNECTION 10031 // No connection with the trade server -#define TRADE_RETCODE_ONLY_REAL 10032 // Operation is allowed only for live accounts -#define TRADE_RETCODE_LIMIT_ORDERS 10033 // The number of pending orders has reached the limit -#define TRADE_RETCODE_LIMIT_VOLUME 10034 // The volume of orders and positions for the symbol has reached the limit -#define TRADE_RETCODE_INVALID_ORDER 10035 // Incorrect or prohibited order type -#define TRADE_RETCODE_POSITION_CLOSED 10036 // Position with the specified POSITION_IDENTIFIER has already been closed -#define TRADE_RETCODE_INVALID_CLOSE_VOLUME 10038 // A close volume exceeds the current position volume -#define TRADE_RETCODE_CLOSE_ORDER_EXIST 10039 // A close order already exists. -#define TRADE_RETCODE_LIMIT_POSITIONS 10040 // The number of open positions can be limited (e.g. Netting, Hedging). +#define TRADE_RETCODE_REQUOTE 10004 // Requote +#define TRADE_RETCODE_REJECT 10006 // Request rejected +#define TRADE_RETCODE_CANCEL 10007 // Request canceled by trader +#define TRADE_RETCODE_PLACED 10008 // Order placed +#define TRADE_RETCODE_DONE 10009 // Request completed +#define TRADE_RETCODE_DONE_PARTIAL 10010 // Only part of the request was completed +#define TRADE_RETCODE_ERROR 10011 // Request processing error +#define TRADE_RETCODE_TIMEOUT 10012 // Request canceled by timeout +#define TRADE_RETCODE_INVALID 10013 // Invalid request +#define TRADE_RETCODE_INVALID_VOLUME 10014 // Invalid volume in the request +#define TRADE_RETCODE_INVALID_PRICE 10015 // Invalid price in the request +#define TRADE_RETCODE_INVALID_STOPS 10016 // Invalid stops in the request +#define TRADE_RETCODE_TRADE_DISABLED 10017 // Trade is disabled +#define TRADE_RETCODE_MARKET_CLOSED 10018 // Market is closed +#define TRADE_RETCODE_NO_MONEY 10019 // There is not enough money to complete the request +#define TRADE_RETCODE_PRICE_CHANGED 10020 // Prices changed +#define TRADE_RETCODE_PRICE_OFF 10021 // There are no quotes to process the request +#define TRADE_RETCODE_INVALID_EXPIRATION 10022 // Invalid order expiration date in the request +#define TRADE_RETCODE_ORDER_CHANGED 10023 // Order state changed +#define TRADE_RETCODE_TOO_MANY_REQUESTS 10024 // Too frequent requests +#define TRADE_RETCODE_NO_CHANGES 10025 // No changes in request +#define TRADE_RETCODE_SERVER_DISABLES_AT 10026 // Autotrading disabled by server +#define TRADE_RETCODE_CLIENT_DISABLES_AT 10027 // Autotrading disabled by client terminal +#define TRADE_RETCODE_LOCKED 10028 // Request locked for processing +#define TRADE_RETCODE_FROZEN 10029 // Order or position frozen +#define TRADE_RETCODE_INVALID_FILL 10030 // Invalid order filling type +#define TRADE_RETCODE_CONNECTION 10031 // No connection with the trade server +#define TRADE_RETCODE_ONLY_REAL 10032 // Operation is allowed only for live accounts +#define TRADE_RETCODE_LIMIT_ORDERS 10033 // The number of pending orders has reached the limit +#define TRADE_RETCODE_LIMIT_VOLUME 10034 // The volume of orders and positions for the symbol has reached the limit +#define TRADE_RETCODE_INVALID_ORDER 10035 // Incorrect or prohibited order type +#define TRADE_RETCODE_POSITION_CLOSED 10036 // Position with the specified POSITION_IDENTIFIER has already been closed +#define TRADE_RETCODE_INVALID_CLOSE_VOLUME 10038 // A close volume exceeds the current position volume +#define TRADE_RETCODE_CLOSE_ORDER_EXIST 10039 // A close order already exists. +#define TRADE_RETCODE_LIMIT_POSITIONS 10040 // The number of open positions can be limited (e.g. Netting, Hedging). #endif // Runtime Errors (@see: https://www.mql5.com/en/docs/constants/errorswarnings/errorcodes) // General error codes. #ifndef ERR_SUCCESS -#define ERR_SUCCESS 0 // The operation completed successfully. +#define ERR_SUCCESS 0 // The operation completed successfully. #endif -#define ERR_NO_MQLERROR 4000 +#define ERR_NO_MQLERROR 4000 #ifndef ERR_INTERNAL_ERROR -#define ERR_INTERNAL_ERROR 4001 // Operating system error. +#define ERR_INTERNAL_ERROR 4001 // Operating system error. #endif -#define ERR_WRONG_INTERNAL_PARAMETER 4002 // Wrong parameter in the inner call of the client terminal function. +#define ERR_WRONG_INTERNAL_PARAMETER 4002 // Wrong parameter in the inner call of the client terminal function. //#define ERR_INVALID_PARAMETER 4003 // Wrong parameter when calling the system function. -#define ERR_NOT_ENOUGH_MEMORY 4004 // Not enough memory to perform the system function. -#define ERR_STRUCT_WITHOBJECTS_ORCLASS 4005 // The structure contains objects of strings and/or dynamic arrays and/or structure of such objects and/or classes. -#define ERR_INVALID_ARRAY 4006 // Array of a wrong type, wrong size, or a damaged object of a dynamic array. -#define ERR_ARRAY_RESIZE_ERROR 4007 // Not enough memory for the relocation of an array, or an attempt to change the size of a static array. -#define ERR_STRING_RESIZE_ERROR 4008 // Not enough memory for the relocation of string. -#define ERR_NOTINITIALIZED_STRING 4009 // Not initialized string. -#define ERR_INVALID_DATETIME 4010 // Invalid date and/or time. -#define ERR_ARRAY_BAD_SIZE 4011 // Requested array size exceeds 2 GB. +#define ERR_NOT_ENOUGH_MEMORY 4004 // Not enough memory to perform the system function. +#define ERR_STRUCT_WITHOBJECTS_ORCLASS \ + 4005 // The structure contains objects of strings and/or dynamic arrays and/or structure of such objects and/or + // classes. +#define ERR_INVALID_ARRAY 4006 // Array of a wrong type, wrong size, or a damaged object of a dynamic array. +#define ERR_ARRAY_RESIZE_ERROR \ + 4007 // Not enough memory for the relocation of an array, or an attempt to change the size of a static array. +#define ERR_STRING_RESIZE_ERROR 4008 // Not enough memory for the relocation of string. +#define ERR_NOTINITIALIZED_STRING 4009 // Not initialized string. +#define ERR_INVALID_DATETIME 4010 // Invalid date and/or time. +#define ERR_ARRAY_BAD_SIZE 4011 // Requested array size exceeds 2 GB. #ifndef ERR_INVALID_POINTER -#define ERR_INVALID_POINTER 4012 // Wrong pointer. +#define ERR_INVALID_POINTER 4012 // Wrong pointer. #endif -#define ERR_INVALID_POINTER_TYPE 4013 // Wrong type of pointer. -#define ERR_FUNCTION_NOT_ALLOWED 4014 // Function is not allowed for call. -#define ERR_RESOURCE_NAME_DUPLICATED 4015 // The names of the dynamic and the static resource match. +#define ERR_INVALID_POINTER_TYPE 4013 // Wrong type of pointer. +#define ERR_FUNCTION_NOT_ALLOWED 4014 // Function is not allowed for call. +#define ERR_RESOURCE_NAME_DUPLICATED 4015 // The names of the dynamic and the static resource match. #ifndef ERR_RESOURCE_NOT_FOUND -#define ERR_RESOURCE_NOT_FOUND 4016 // Resource with this name has not been found in EX5. +#define ERR_RESOURCE_NOT_FOUND 4016 // Resource with this name has not been found in EX5. #endif -#define ERR_RESOURCE_UNSUPPOTED_TYPE 4017 // Unsupported resource type or its size exceeds 16 Mb. -#define ERR_RESOURCE_NAME_IS_TOO_LONG 4018 // The resource name exceeds 63 characters. +#define ERR_RESOURCE_UNSUPPOTED_TYPE 4017 // Unsupported resource type or its size exceeds 16 Mb. +#define ERR_RESOURCE_NAME_IS_TOO_LONG 4018 // The resource name exceeds 63 characters. // Charts. -#define ERR_CHART_WRONG_ID 4101 // Wrong chart ID. -#define ERR_CHART_NO_REPLY 4102 // Chart does not respond. +#define ERR_CHART_WRONG_ID 4101 // Wrong chart ID. +#define ERR_CHART_NO_REPLY 4102 // Chart does not respond. #ifndef ERR_CHART_NOT_FOUND -#define ERR_CHART_NOT_FOUND 4103 // Chart not found. +#define ERR_CHART_NOT_FOUND 4103 // Chart not found. #endif -#define ERR_CHART_NO_EXPERT 4104 // No Expert Advisor in the chart that could handle the event. -#define ERR_CHART_CANNOT_OPEN 4105 // Chart opening error. -#define ERR_CHART_CANNOT_CHANGE 4106 // Failed to change chart symbol and period. -#define ERR_CHART_WRONG_PARAMETER 4107 // Error value of the parameter for the function of working with charts. -#define ERR_CHART_CANNOT_CREATE_TIMER 4108 // Failed to create timer. -#define ERR_CHART_WRONG_PROPERTY 4109 // Wrong chart property ID. -#define ERR_CHART_SCREENSHOT_FAILED 4110 // Error creating screenshots. -#define ERR_CHART_NAVIGATE_FAILED 4111 // Error navigating through chart. -#define ERR_CHART_TEMPLATE_FAILED 4112 // Error applying template. -#define ERR_CHART_WINDOW_NOT_FOUND 4113 // Subwindow containing the indicator was not found. -#define ERR_CHART_INDICATOR_CANNOT_ADD 4114 // Error adding an indicator to chart. -#define ERR_CHART_INDICATOR_CANNOT_DEL 4115 // Error deleting an indicator from the chart. -#define ERR_CHART_INDICATOR_NOT_FOUND 4116 // Indicator not found on the specified chart. +#define ERR_CHART_NO_EXPERT 4104 // No Expert Advisor in the chart that could handle the event. +#define ERR_CHART_CANNOT_OPEN 4105 // Chart opening error. +#define ERR_CHART_CANNOT_CHANGE 4106 // Failed to change chart symbol and period. +#define ERR_CHART_WRONG_PARAMETER 4107 // Error value of the parameter for the function of working with charts. +#define ERR_CHART_CANNOT_CREATE_TIMER 4108 // Failed to create timer. +#define ERR_CHART_WRONG_PROPERTY 4109 // Wrong chart property ID. +#define ERR_CHART_SCREENSHOT_FAILED 4110 // Error creating screenshots. +#define ERR_CHART_NAVIGATE_FAILED 4111 // Error navigating through chart. +#define ERR_CHART_TEMPLATE_FAILED 4112 // Error applying template. +#define ERR_CHART_WINDOW_NOT_FOUND 4113 // Subwindow containing the indicator was not found. +#define ERR_CHART_INDICATOR_CANNOT_ADD 4114 // Error adding an indicator to chart. +#define ERR_CHART_INDICATOR_CANNOT_DEL 4115 // Error deleting an indicator from the chart. +#define ERR_CHART_INDICATOR_NOT_FOUND 4116 // Indicator not found on the specified chart. // Graphical Objects. -#define ERR_OBJECT_ERROR 4201 // Error working with a graphical object. -#define ERR_OBJECT_NOT_FOUND 4202 // Graphical object was not found. -#define ERR_OBJECT_WRONG_PROPERTY 4203 // Wrong ID of a graphical object property. -#define ERR_OBJECT_GETDATE_FAILED 4204 // Unable to get date corresponding to the value. -#define ERR_OBJECT_GETVALUE_FAILED 4205 // Unable to get value corresponding to the date. +#define ERR_OBJECT_ERROR 4201 // Error working with a graphical object. +#define ERR_OBJECT_NOT_FOUND 4202 // Graphical object was not found. +#define ERR_OBJECT_WRONG_PROPERTY 4203 // Wrong ID of a graphical object property. +#define ERR_OBJECT_GETDATE_FAILED 4204 // Unable to get date corresponding to the value. +#define ERR_OBJECT_GETVALUE_FAILED 4205 // Unable to get value corresponding to the date. // MarketInfo. -#define ERR_MARKET_UNKNOWN_SYMBOL 4301 // Unknown symbol. -#define ERR_MARKET_NOT_SELECTED 4302 // Symbol is not selected in MarketWatch. -#define ERR_MARKET_WRONG_PROPERTY 4303 // Wrong identifier of a symbol property. -#define ERR_MARKET_LASTTIME_UNKNOWN 4304 // Time of the last tick is not known (no ticks). -#define ERR_MARKET_SELECT_ERROR 4305 // Error adding or deleting a symbol in MarketWatch. +#define ERR_MARKET_UNKNOWN_SYMBOL 4301 // Unknown symbol. +#define ERR_MARKET_NOT_SELECTED 4302 // Symbol is not selected in MarketWatch. +#define ERR_MARKET_WRONG_PROPERTY 4303 // Wrong identifier of a symbol property. +#define ERR_MARKET_LASTTIME_UNKNOWN 4304 // Time of the last tick is not known (no ticks). +#define ERR_MARKET_SELECT_ERROR 4305 // Error adding or deleting a symbol in MarketWatch. // History Access. -#define ERR_HISTORY_NOT_FOUND 4401 // Requested history not found. -#define ERR_HISTORY_WRONG_PROPERTY 4402 // Wrong ID of the history property. -#define ERR_HISTORY_TIMEOUT 4403 // Exceeded history request timeout. -#define ERR_HISTORY_BARS_LIMIT 4404 // Number of requested bars limited by terminal settings. -#define ERR_HISTORY_LOAD_ERRORS 4405 // Multiple errors when loading history. -#define ERR_HISTORY_SMALL_BUFFER 4407 // Receiving array is too small to store all requested data. +#define ERR_HISTORY_NOT_FOUND 4401 // Requested history not found. +#define ERR_HISTORY_WRONG_PROPERTY 4402 // Wrong ID of the history property. +#define ERR_HISTORY_TIMEOUT 4403 // Exceeded history request timeout. +#define ERR_HISTORY_BARS_LIMIT 4404 // Number of requested bars limited by terminal settings. +#define ERR_HISTORY_LOAD_ERRORS 4405 // Multiple errors when loading history. +#define ERR_HISTORY_SMALL_BUFFER 4407 // Receiving array is too small to store all requested data. // Global_Variables. -#define ERR_GLOBALVARIABLE_NOT_FOUND 4501 // Global variable of the client terminal is not found. -#define ERR_GLOBALVARIABLE_EXISTS 4502 // Global variable of the client terminal with the same name already exists. -#define ERR_MAIL_SEND_FAILED 4510 // Email sending failed. -#define ERR_PLAY_SOUND_FAILED 4511 // Sound playing failed. -#define ERR_MQL5_WRONG_PROPERTY 4512 // Wrong identifier of the program property. -#define ERR_TERMINAL_WRONG_PROPERTY 4513 // Wrong identifier of the terminal property. -#define ERR_FTP_SEND_FAILED 4514 // File sending via ftp failed. -#define ERR_NOTIFICATION_SEND_FAILED 4515 // Failed to send a notification. -#define ERR_NOTIFICATION_WRONG_PARAMETER 4516 // Invalid parameter for sending a notification - an empty string or NULL has been passed to the SendNotification() function. -#define ERR_NOTIFICATION_WRONG_SETTINGS 4517 // Wrong settings of notifications in the terminal (ID is not specified or permission is not set). +#define ERR_GLOBALVARIABLE_NOT_FOUND 4501 // Global variable of the client terminal is not found. +#define ERR_GLOBALVARIABLE_EXISTS 4502 // Global variable of the client terminal with the same name already exists. +#define ERR_MAIL_SEND_FAILED 4510 // Email sending failed. +#define ERR_PLAY_SOUND_FAILED 4511 // Sound playing failed. +#define ERR_MQL5_WRONG_PROPERTY 4512 // Wrong identifier of the program property. +#define ERR_TERMINAL_WRONG_PROPERTY 4513 // Wrong identifier of the terminal property. +#define ERR_FTP_SEND_FAILED 4514 // File sending via ftp failed. +#define ERR_NOTIFICATION_SEND_FAILED 4515 // Failed to send a notification. +#define ERR_NOTIFICATION_WRONG_PARAMETER \ + 4516 // Invalid parameter for sending a notification - an empty string or NULL has been passed to the + // SendNotification() function. +#define ERR_NOTIFICATION_WRONG_SETTINGS \ + 4517 // Wrong settings of notifications in the terminal (ID is not specified or permission is not set). #ifndef ERR_NOTIFICATION_TOO_FREQUENT -#define ERR_NOTIFICATION_TOO_FREQUENT 4518 // Too frequent sending of notifications. +#define ERR_NOTIFICATION_TOO_FREQUENT 4518 // Too frequent sending of notifications. #endif #ifndef ERR_FTP_NOSERVER -#define ERR_FTP_NOSERVER 4519 // FTP server is not specified. +#define ERR_FTP_NOSERVER 4519 // FTP server is not specified. #endif #ifndef ERR_FTP_NOLOGIN -#define ERR_FTP_NOLOGIN 4520 // FTP login is not specified. +#define ERR_FTP_NOLOGIN 4520 // FTP login is not specified. #endif #ifndef ERR_FTP_FILE_ERROR -#define ERR_FTP_FILE_ERROR 4521 // File not found in the MQL5\Files directory to send on FTP server. +#define ERR_FTP_FILE_ERROR 4521 // File not found in the MQL5\Files directory to send on FTP server. #endif #ifndef ERR_FTP_CONNECT_FAILED -#define ERR_FTP_CONNECT_FAILED 4522 // FTP connection failed. +#define ERR_FTP_CONNECT_FAILED 4522 // FTP connection failed. #endif #ifndef ERR_FTP_CHANGEDIR -#define ERR_FTP_CHANGEDIR 4523 // FTP path not found on server. +#define ERR_FTP_CHANGEDIR 4523 // FTP path not found on server. #endif #ifndef ERR_FTP_CLOSED -#define ERR_FTP_CLOSED 4524 // FTP connection closed. +#define ERR_FTP_CLOSED 4524 // FTP connection closed. #endif // Custom Indicator Buffers. -#define ERR_BUFFERS_NO_MEMORY 4601 // Not enough memory for the distribution of indicator buffers. -#define ERR_BUFFERS_WRONG_INDEX 4602 // Wrong indicator buffer index. +#define ERR_BUFFERS_NO_MEMORY 4601 // Not enough memory for the distribution of indicator buffers. +#define ERR_BUFFERS_WRONG_INDEX 4602 // Wrong indicator buffer index. // Custom Indicator Properties. -#define ERR_CUSTOM_WRONG_PROPERTY 4603 // Wrong ID of the custom indicator property. +#define ERR_CUSTOM_WRONG_PROPERTY 4603 // Wrong ID of the custom indicator property. // Account. -#define ERR_ACCOUNT_WRONG_PROPERTY 4701 // Wrong account property ID. -#define ERR_TRADE_WRONG_PROPERTY 4751 // Wrong trade property ID. +#define ERR_ACCOUNT_WRONG_PROPERTY 4701 // Wrong account property ID. +#define ERR_TRADE_WRONG_PROPERTY 4751 // Wrong trade property ID. #ifndef ERR_TRADE_DISABLED -#define ERR_TRADE_DISABLED 4752 // Trading by Expert Advisors prohibited. +#define ERR_TRADE_DISABLED 4752 // Trading by Expert Advisors prohibited. #endif -#define ERR_TRADE_POSITION_NOT_FOUND 4753 // Position not found. -#define ERR_TRADE_ORDER_NOT_FOUND 4754 // Order not found. -#define ERR_TRADE_DEAL_NOT_FOUND 4755 // Deal not found. -#define ERR_TRADE_SEND_FAILED 4756 // Trade request sending failed. +#define ERR_TRADE_POSITION_NOT_FOUND 4753 // Position not found. +#define ERR_TRADE_ORDER_NOT_FOUND 4754 // Order not found. +#define ERR_TRADE_DEAL_NOT_FOUND 4755 // Deal not found. +#define ERR_TRADE_SEND_FAILED 4756 // Trade request sending failed. // Indicators. -#define ERR_INDICATOR_UNKNOWN_SYMBOL 4801 // Unknown symbol. -#define ERR_INDICATOR_CANNOT_CREATE 4802 // Indicator cannot be created. -#define ERR_INDICATOR_NO_MEMORY 4803 // Not enough memory to add the indicator. -#define ERR_INDICATOR_CANNOT_APPLY 4804 // The indicator cannot be applied to another indicator. -#define ERR_INDICATOR_CANNOT_ADD 4805 // Error applying an indicator to chart. -#define ERR_INDICATOR_DATA_NOT_FOUND 4806 // Requested data not found. -#define ERR_INDICATOR_WRONG_HANDLE 4807 // Wrong indicator handle. -#define ERR_INDICATOR_WRONG_PARAMETERS 4808 // Wrong number of parameters when creating an indicator. -#define ERR_INDICATOR_PARAMETERS_MISSING 4809 // No parameters when creating an indicator. -#define ERR_INDICATOR_CUSTOM_NAME 4810 // The first parameter in the array must be the name of the custom indicator. -#define ERR_INDICATOR_PARAMETER_TYPE 4811 // Invalid parameter type in the array when creating an indicator. -#define ERR_INDICATOR_WRONG_INDEX 4812 // Wrong index of the requested indicator buffer. +#define ERR_INDICATOR_UNKNOWN_SYMBOL 4801 // Unknown symbol. +#define ERR_INDICATOR_CANNOT_CREATE 4802 // Indicator cannot be created. +#define ERR_INDICATOR_NO_MEMORY 4803 // Not enough memory to add the indicator. +#define ERR_INDICATOR_CANNOT_APPLY 4804 // The indicator cannot be applied to another indicator. +#define ERR_INDICATOR_CANNOT_ADD 4805 // Error applying an indicator to chart. +#define ERR_INDICATOR_DATA_NOT_FOUND 4806 // Requested data not found. +#define ERR_INDICATOR_WRONG_HANDLE 4807 // Wrong indicator handle. +#define ERR_INDICATOR_WRONG_PARAMETERS 4808 // Wrong number of parameters when creating an indicator. +#define ERR_INDICATOR_PARAMETERS_MISSING 4809 // No parameters when creating an indicator. +#define ERR_INDICATOR_CUSTOM_NAME 4810 // The first parameter in the array must be the name of the custom indicator. +#define ERR_INDICATOR_PARAMETER_TYPE 4811 // Invalid parameter type in the array when creating an indicator. +#define ERR_INDICATOR_WRONG_INDEX 4812 // Wrong index of the requested indicator buffer. // Depth of Market. -#define ERR_BOOKS_CANNOT_ADD 4901 // Depth Of Market can not be added. -#define ERR_BOOKS_CANNOT_DELETE 4902 // Depth Of Market can not be removed. -#define ERR_BOOKS_CANNOT_GET 4903 // The data from Depth Of Market can not be obtained. -#define ERR_BOOKS_CANNOT_SUBSCRIBE 4904 // Error in subscribing to receive new data from Depth Of Market. +#define ERR_BOOKS_CANNOT_ADD 4901 // Depth Of Market can not be added. +#define ERR_BOOKS_CANNOT_DELETE 4902 // Depth Of Market can not be removed. +#define ERR_BOOKS_CANNOT_GET 4903 // The data from Depth Of Market can not be obtained. +#define ERR_BOOKS_CANNOT_SUBSCRIBE 4904 // Error in subscribing to receive new data from Depth Of Market. // File Operations. -#define ERR_TOO_MANY_FILES 5001 // More than 64 files cannot be opened at the same time. -#define ERR_WRONG_FILENAME 5002 // Invalid file name. -#define ERR_TOO_LONG_FILENAME 5003 // Too long file name. +#define ERR_TOO_MANY_FILES 5001 // More than 64 files cannot be opened at the same time. +#define ERR_WRONG_FILENAME 5002 // Invalid file name. +#define ERR_TOO_LONG_FILENAME 5003 // Too long file name. #ifndef ERR_CANNOT_OPEN_FILE -#define ERR_CANNOT_OPEN_FILE 5004 // File opening error. +#define ERR_CANNOT_OPEN_FILE 5004 // File opening error. #endif -#define ERR_FILE_CACHEBUFFER_ERROR 5005 // Not enough memory for cache to read. -#define ERR_CANNOT_DELETE_FILE 5006 // File deleting error. -#define ERR_INVALID_FILEHANDLE 5007 // A file with this handle was closed, or was not opening at all. -#define ERR_WRONG_FILEHANDLE 5008 // Wrong file handle. -#define ERR_FILE_NOTTOWRITE 5009 // The file must be opened for writing. -#define ERR_FILE_NOTTOREAD 5010 // The file must be opened for reading. -#define ERR_FILE_NOTBIN 5011 // The file must be opened as a binary one. -#define ERR_FILE_NOTTXT 5012 // The file must be opened as a text. -#define ERR_FILE_NOTTXTORCSV 5013 // The file must be opened as a text or CSV. -#define ERR_FILE_NOTCSV 5014 // The file must be opened as CSV. -#define ERR_FILE_READERROR 5015 // File reading error. -#define ERR_FILE_BINSTRINGSIZE 5016 // String size must be specified, because the file is opened as binary. -#define ERR_INCOMPATIBLE_FILE 5017 // A text file must be for string arrays, for other arrays - binary. +#define ERR_FILE_CACHEBUFFER_ERROR 5005 // Not enough memory for cache to read. +#define ERR_CANNOT_DELETE_FILE 5006 // File deleting error. +#define ERR_INVALID_FILEHANDLE 5007 // A file with this handle was closed, or was not opening at all. +#define ERR_WRONG_FILEHANDLE 5008 // Wrong file handle. +#define ERR_FILE_NOTTOWRITE 5009 // The file must be opened for writing. +#define ERR_FILE_NOTTOREAD 5010 // The file must be opened for reading. +#define ERR_FILE_NOTBIN 5011 // The file must be opened as a binary one. +#define ERR_FILE_NOTTXT 5012 // The file must be opened as a text. +#define ERR_FILE_NOTTXTORCSV 5013 // The file must be opened as a text or CSV. +#define ERR_FILE_NOTCSV 5014 // The file must be opened as CSV. +#define ERR_FILE_READERROR 5015 // File reading error. +#define ERR_FILE_BINSTRINGSIZE 5016 // String size must be specified, because the file is opened as binary. +#define ERR_INCOMPATIBLE_FILE 5017 // A text file must be for string arrays, for other arrays - binary. #ifndef ERR_FILE_IS_DIRECTORY -#define ERR_FILE_IS_DIRECTORY 5018 // This is not a file, this is a directory. +#define ERR_FILE_IS_DIRECTORY 5018 // This is not a file, this is a directory. #endif #ifndef ERR_FILE_NOT_EXIST -#define ERR_FILE_NOT_EXIST 5019 // File does not exist. +#define ERR_FILE_NOT_EXIST 5019 // File does not exist. #endif #ifndef ERR_FILE_CANNOT_REWRITE -#define ERR_FILE_CANNOT_REWRITE 5020 // File can not be rewritten. +#define ERR_FILE_CANNOT_REWRITE 5020 // File can not be rewritten. #endif -#define ERR_WRONG_DIRECTORYNAME 5021 // Wrong directory name. -#define ERR_DIRECTORY_NOT_EXIST 5022 // Directory does not exist. -#define ERR_FILE_ISNOT_DIRECTORY 5023 // This is a file, not a directory. -#define ERR_CANNOT_DELETE_DIRECTORY 5024 // The directory cannot be removed. -#define ERR_CANNOT_CLEAN_DIRECTORY 5025 // Failed to clear the directory (probably one or more files are blocked and removal operation failed). -#define ERR_FILE_WRITEERROR 5026 // Failed to write a resource to a file. -#define ERR_FILE_ENDOFFILE 5027 // Unable to read the next piece of data from a CSV file (FileReadString, FileReadNumber, FileReadDatetime, FileReadBool), since the end of file is reached. +#define ERR_WRONG_DIRECTORYNAME 5021 // Wrong directory name. +#define ERR_DIRECTORY_NOT_EXIST 5022 // Directory does not exist. +#define ERR_FILE_ISNOT_DIRECTORY 5023 // This is a file, not a directory. +#define ERR_CANNOT_DELETE_DIRECTORY 5024 // The directory cannot be removed. +#define ERR_CANNOT_CLEAN_DIRECTORY \ + 5025 // Failed to clear the directory (probably one or more files are blocked and removal operation failed). +#define ERR_FILE_WRITEERROR 5026 // Failed to write a resource to a file. +#define ERR_FILE_ENDOFFILE \ + 5027 // Unable to read the next piece of data from a CSV file (FileReadString, FileReadNumber, FileReadDatetime, + // FileReadBool), since the end of file is reached. // String Casting. -#define ERR_NO_STRING_DATE 5030 // No date in the string. -#define ERR_WRONG_STRING_DATE 5031 // Wrong date in the string. -#define ERR_WRONG_STRING_TIME 5032 // Wrong time in the string. -#define ERR_STRING_TIME_ERROR 5033 // Error converting string to date. -#define ERR_STRING_OUT_OF_MEMORY 5034 // Not enough memory for the string. -#define ERR_STRING_SMALL_LEN 5035 // The string length is less than expected. -#define ERR_STRING_TOO_BIGNUMBER 5036 // Too large number, more than ULONG_MAX. -#define ERR_WRONG_FORMATSTRING 5037 // Invalid format string. -#define ERR_TOO_MANY_FORMATTERS 5038 // Amount of format specifiers more than the parameters. -#define ERR_TOO_MANY_PARAMETERS 5039 // Amount of parameters more than the format specifiers. -#define ERR_WRONG_STRING_PARAMETER 5040 // Damaged parameter of string type. -#define ERR_STRINGPOS_OUTOFRANGE 5041 // Position outside the string. -#define ERR_STRING_ZEROADDED 5042 // 0 added to the string end, a useless operation. -#define ERR_STRING_UNKNOWNTYPE 5043 // Unknown data type when converting to a string. -#define ERR_WRONG_STRING_OBJECT 5044 // Damaged string object. +#define ERR_NO_STRING_DATE 5030 // No date in the string. +#define ERR_WRONG_STRING_DATE 5031 // Wrong date in the string. +#define ERR_WRONG_STRING_TIME 5032 // Wrong time in the string. +#define ERR_STRING_TIME_ERROR 5033 // Error converting string to date. +#define ERR_STRING_OUT_OF_MEMORY 5034 // Not enough memory for the string. +#define ERR_STRING_SMALL_LEN 5035 // The string length is less than expected. +#define ERR_STRING_TOO_BIGNUMBER 5036 // Too large number, more than ULONG_MAX. +#define ERR_WRONG_FORMATSTRING 5037 // Invalid format string. +#define ERR_TOO_MANY_FORMATTERS 5038 // Amount of format specifiers more than the parameters. +#define ERR_TOO_MANY_PARAMETERS 5039 // Amount of parameters more than the format specifiers. +#define ERR_WRONG_STRING_PARAMETER 5040 // Damaged parameter of string type. +#define ERR_STRINGPOS_OUTOFRANGE 5041 // Position outside the string. +#define ERR_STRING_ZEROADDED 5042 // 0 added to the string end, a useless operation. +#define ERR_STRING_UNKNOWNTYPE 5043 // Unknown data type when converting to a string. +#define ERR_WRONG_STRING_OBJECT 5044 // Damaged string object. // Operations with Array. #ifndef ERR_INCOMPATIBLE_ARRAYS -#define ERR_INCOMPATIBLE_ARRAYS 5050 // Copying incompatible arrays. String array can be copied only to a string array, and a numeric array - in numeric array only. +#define ERR_INCOMPATIBLE_ARRAYS \ + 5050 // Copying incompatible arrays. String array can be copied only to a string array, and a numeric array - in + // numeric array only. #endif -#define ERR_SMALL_ASSERIES_ARRAY 5051 // The receiving array is declared as AS_SERIES, and it is of insufficient size. -#define ERR_SMALL_ARRAY 5052 // Too small array, the starting position is outside the array. -#define ERR_ZEROSIZE_ARRAY 5053 // An array of zero length. -#define ERR_NUMBER_ARRAYS_ONLY 5054 // Must be a numeric array. -#define ERR_ONEDIM_ARRAYS_ONLY 5055 // Must be a one-dimensional array. -#define ERR_SERIES_ARRAY 5056 // Timeseries cannot be used. -#define ERR_DOUBLE_ARRAY_ONLY 5057 // Must be an array of type double. -#define ERR_FLOAT_ARRAY_ONLY 5058 // Must be an array of type float. -#define ERR_LONG_ARRAY_ONLY 5059 // Must be an array of type long. -#define ERR_INT_ARRAY_ONLY 5060 // Must be an array of type int. -#define ERR_SHORT_ARRAY_ONLY 5061 // Must be an array of type short. -#define ERR_CHAR_ARRAY_ONLY 5062 // Must be an array of type char. +#define ERR_SMALL_ASSERIES_ARRAY 5051 // The receiving array is declared as AS_SERIES, and it is of insufficient size. +#define ERR_SMALL_ARRAY 5052 // Too small array, the starting position is outside the array. +#define ERR_ZEROSIZE_ARRAY 5053 // An array of zero length. +#define ERR_NUMBER_ARRAYS_ONLY 5054 // Must be a numeric array. +#define ERR_ONEDIM_ARRAYS_ONLY 5055 // Must be a one-dimensional array. +#define ERR_SERIES_ARRAY 5056 // Timeseries cannot be used. +#define ERR_DOUBLE_ARRAY_ONLY 5057 // Must be an array of type double. +#define ERR_FLOAT_ARRAY_ONLY 5058 // Must be an array of type float. +#define ERR_LONG_ARRAY_ONLY 5059 // Must be an array of type int64. +#define ERR_INT_ARRAY_ONLY 5060 // Must be an array of type int. +#define ERR_SHORT_ARRAY_ONLY 5061 // Must be an array of type short. +#define ERR_CHAR_ARRAY_ONLY 5062 // Must be an array of type char. // Operations with OpenCL. -#define ERR_OPENCL_NOT_SUPPORTED 5100 // OpenCL functions are not supported on this computer. -#define ERR_OPENCL_INTERNAL 5101 // Internal error occurred when running OpenCL. -#define ERR_OPENCL_INVALID_HANDLE 5102 // Invalid OpenCL handle. -#define ERR_OPENCL_CONTEXT_CREATE 5103 // Error creating the OpenCL context. -#define ERR_OPENCL_QUEUE_CREATE 5104 // Failed to create a run queue in OpenCL. -#define ERR_OPENCL_PROGRAM_CREATE 5105 // Error occurred when compiling an OpenCL program. -#define ERR_OPENCL_TOO_LONG_KERNEL_NAME 5106 // Too long kernel name (OpenCL kernel). -#define ERR_OPENCL_KERNEL_CREATE 5107 // Error creating an OpenCL kernel. -#define ERR_OPENCL_SET_KERNEL_PARAMETER 5108 // Error occurred when setting parameters for the OpenCL kernel. -#define ERR_OPENCL_EXECUTE 5109 // OpenCL program runtime error. -#define ERR_OPENCL_WRONG_BUFFER_SIZE 5110 // Invalid size of the OpenCL buffer. -#define ERR_OPENCL_WRONG_BUFFER_OFFSET 5111 // Invalid offset in the OpenCL buffer. -#define ERR_OPENCL_BUFFER_CREATE 5112 // Failed to create an OpenCL buffer. +#define ERR_OPENCL_NOT_SUPPORTED 5100 // OpenCL functions are not supported on this computer. +#define ERR_OPENCL_INTERNAL 5101 // Internal error occurred when running OpenCL. +#define ERR_OPENCL_INVALID_HANDLE 5102 // Invalid OpenCL handle. +#define ERR_OPENCL_CONTEXT_CREATE 5103 // Error creating the OpenCL context. +#define ERR_OPENCL_QUEUE_CREATE 5104 // Failed to create a run queue in OpenCL. +#define ERR_OPENCL_PROGRAM_CREATE 5105 // Error occurred when compiling an OpenCL program. +#define ERR_OPENCL_TOO_LONG_KERNEL_NAME 5106 // Too long kernel name (OpenCL kernel). +#define ERR_OPENCL_KERNEL_CREATE 5107 // Error creating an OpenCL kernel. +#define ERR_OPENCL_SET_KERNEL_PARAMETER 5108 // Error occurred when setting parameters for the OpenCL kernel. +#define ERR_OPENCL_EXECUTE 5109 // OpenCL program runtime error. +#define ERR_OPENCL_WRONG_BUFFER_SIZE 5110 // Invalid size of the OpenCL buffer. +#define ERR_OPENCL_WRONG_BUFFER_OFFSET 5111 // Invalid offset in the OpenCL buffer. +#define ERR_OPENCL_BUFFER_CREATE 5112 // Failed to create an OpenCL buffer. // Operations with WebRequest. #ifndef ERR_WEBREQUEST_INVALID_ADDRESS -#define ERR_WEBREQUEST_INVALID_ADDRESS 5200 // Invalid URL. +#define ERR_WEBREQUEST_INVALID_ADDRESS 5200 // Invalid URL. #endif #ifndef ERR_WEBREQUEST_CONNECT_FAILED -#define ERR_WEBREQUEST_CONNECT_FAILED 5201 // Failed to connect to specified URL. +#define ERR_WEBREQUEST_CONNECT_FAILED 5201 // Failed to connect to specified URL. #endif #ifndef ERR_WEBREQUEST_TIMEOUT -#define ERR_WEBREQUEST_TIMEOUT 5202 // Timeout exceeded. +#define ERR_WEBREQUEST_TIMEOUT 5202 // Timeout exceeded. #endif #ifndef ERR_WEBREQUEST_REQUEST_FAILED -#define ERR_WEBREQUEST_REQUEST_FAILED 5203 // HTTP request failed. +#define ERR_WEBREQUEST_REQUEST_FAILED 5203 // HTTP request failed. #endif // User-Defined Errors. #ifndef ERR_USER_ERROR_FIRST -#define ERR_USER_ERROR_FIRST 65536 // User defined errors start with this code. +#define ERR_USER_ERROR_FIRST 65536 // User defined errors start with this code. #endif -#endif // MQL5_MQH +#endif // MQL5_MQH diff --git a/Platform/Order.h b/Platform/Order.h index d15186ff5..b7c84a5c7 100644 --- a/Platform/Order.h +++ b/Platform/Order.h @@ -117,7 +117,7 @@ class Order : public SymbolInfo { #ifndef __MQL4__ // Used for order selection in MQL5 & C++. - static unsigned long selected_ticket_id; + static uint64 selected_ticket_id; static ENUM_ORDER_SELECT_TYPE selected_ticket_type; #endif @@ -126,7 +126,7 @@ class Order : public SymbolInfo { * Class constructors. */ Order() {} - Order(long _ticket_no) { + Order(int64 _ticket_no) { odata.Set(ORDER_PROP_TICKET, _ticket_no); Refresh(true); } @@ -265,7 +265,7 @@ class Order : public SymbolInfo { /** * Sets an order property integer value. */ - void Set(ENUM_ORDER_PROPERTY_INTEGER _prop, long _value) { odata.Set(_prop, _value); } + void Set(ENUM_ORDER_PROPERTY_INTEGER _prop, int64 _value) { odata.Set(_prop, _value); } /** * Sets an order property string value. @@ -278,15 +278,15 @@ class Order : public SymbolInfo { * Is order is open. */ bool IsClosed(bool _refresh = false) { - if (odata.Get(ORDER_PROP_TIME_CLOSED) == 0) { + if (odata.Get(ORDER_PROP_TIME_CLOSED) == 0) { if (_refresh || ShouldRefresh()) { if (Order::TryOrderSelect(Order::OrderTicket(), SELECT_BY_TICKET, MODE_HISTORY)) { - odata.Set(ORDER_PROP_TIME_CLOSED, Order::OrderCloseTime()); + odata.Set(ORDER_PROP_TIME_CLOSED, Order::OrderCloseTime()); odata.Set(ORDER_PROP_REASON_CLOSE, ORDER_REASON_CLOSED_UNKNOWN); } } } - return odata.Get(ORDER_PROP_TIME_CLOSED) > 0; + return odata.Get(ORDER_PROP_TIME_CLOSED) > 0; } /** @@ -307,7 +307,7 @@ class Order : public SymbolInfo { for (int _ci = 0; _ci < _num; _ci++) { ENUM_ORDER_CONDITION _cond = oparams.Get(ORDER_PARAM_COND_CLOSE, _ci); ARRAY(DataParamEntry, _cond_args); - DataParamEntry _item0 = oparams.Get(ORDER_PARAM_COND_CLOSE_ARG_VALUE, _ci); + DataParamEntry _item0 = oparams.Get(ORDER_PARAM_COND_CLOSE_ARG_VALUE, _ci); ArrayPushObject(_cond_args, _item0); _result |= Order::CheckCondition(_cond, _cond_args); } @@ -322,7 +322,7 @@ class Order : public SymbolInfo { * Returns true when order values can be refreshed, otherwise false. */ bool ShouldRefresh() { - return odata.Get(ORDER_PROP_TIME_LAST_REFRESH) + oparams.Get(ORDER_PARAM_REFRESH_FREQ) <= + return odata.Get(ORDER_PROP_TIME_LAST_REFRESH) + oparams.Get(ORDER_PARAM_REFRESH_FREQ) <= TimeCurrent(); } @@ -333,7 +333,7 @@ class Order : public SymbolInfo { * Returns true when order stops can be updated, otherwise false. */ bool ShouldUpdate() { - return odata.Get(ORDER_PROP_TIME_LAST_UPDATE) + oparams.Get(ORDER_PARAM_UPDATE_FREQ) <= + return odata.Get(ORDER_PROP_TIME_LAST_UPDATE) + oparams.Get(ORDER_PARAM_UPDATE_FREQ) <= TimeCurrent(); } @@ -343,13 +343,13 @@ class Order : public SymbolInfo { * Check whether order is selected and it is same as the class one. */ bool IsSelected() { - unsigned long ticket_id = Order::OrderTicket(); + uint64 ticket_id = Order::OrderTicket(); bool is_selected; if (IsDummy()) { is_selected = true; } else { - is_selected = (odata.Get(ORDER_PROP_TICKET) > 0 && ticket_id == odata.Get(ORDER_PROP_TICKET)); + is_selected = (odata.Get(ORDER_PROP_TICKET) > 0 && ticket_id == odata.Get(ORDER_PROP_TICKET)); } ResetLastError(); @@ -374,7 +374,7 @@ class Order : public SymbolInfo { // and only for the symbols with Market or Exchange execution. // In case of partial filling a market or limit order with remaining volume is not canceled but processed further. ENUM_ORDER_TYPE_FILLING _result = ORDER_FILLING_RETURN; - const long _filling_mode = SymbolInfoStatic::GetFillingMode(_symbol); + const int64 _filling_mode = SymbolInfoStatic::GetFillingMode(_symbol); if ((_filling_mode & SYMBOL_FILLING_IOC) == SYMBOL_FILLING_IOC) { // Execute a deal with the volume maximally available in the market within that indicated in the order. // In case the order cannot be filled completely, the available volume of the order will be filled, and the @@ -401,10 +401,10 @@ class Order : public SymbolInfo { /** * Get allowed order filling modes. */ - static ENUM_ORDER_TYPE_FILLING GetOrderFilling(const string _symbol, const long _type) { + static ENUM_ORDER_TYPE_FILLING GetOrderFilling(const string _symbol, const int64 _type) { const ENUM_SYMBOL_TRADE_EXECUTION _exe_mode = (ENUM_SYMBOL_TRADE_EXECUTION)SymbolInfoStatic::SymbolInfoInteger(_symbol, SYMBOL_TRADE_EXEMODE); - const long _filling_mode = SymbolInfoStatic::GetFillingMode(_symbol); + const int64 _filling_mode = SymbolInfoStatic::GetFillingMode(_symbol); return ((_filling_mode == 0 || (_type >= ORDER_FILLING_RETURN) || ((_filling_mode & (_type + 1)) != _type + 1)) ? (((_exe_mode == SYMBOL_TRADE_EXECUTION_EXCHANGE) || (_exe_mode == SYMBOL_TRADE_EXECUTION_INSTANT)) ? ORDER_FILLING_RETURN @@ -431,7 +431,7 @@ class Order : public SymbolInfo { if (Order::TryOrderSelect(Order::OrderTicket(), SELECT_BY_TICKET, MODE_HISTORY)) { for (int i = HistoryDealsTotal() - 1; i >= 0; i--) { // https://www.mql5.com/en/docs/trading/historydealgetticket - const unsigned long _deal_ticket = HistoryDealGetTicket(i); + const uint64 _deal_ticket = HistoryDealGetTicket(i); const ENUM_DEAL_ENTRY _deal_entry = (ENUM_DEAL_ENTRY)HistoryDealGetInteger(_deal_ticket, DEAL_ENTRY); if (_deal_entry == DEAL_ENTRY_OUT || _deal_entry == DEAL_ENTRY_OUT_BY) { _result = HistoryDealGetDouble(_deal_ticket, DEAL_PRICE); @@ -456,11 +456,11 @@ class Order : public SymbolInfo { // http://docs.mql4.com/trading/orderopentime return (datetime)Order::OrderGetInteger(ORDER_TIME_SETUP); #else - long _result = 0; + int64 _result = 0; if (Order::TryOrderSelect(Order::OrderTicket(), SELECT_BY_TICKET, MODE_HISTORY)) { for (int i = HistoryDealsTotal() - 1; i >= 0; i--) { // https://www.mql5.com/en/docs/trading/historydealgetticket - const unsigned long _deal_ticket = HistoryDealGetTicket(i); + const uint64 _deal_ticket = HistoryDealGetTicket(i); const ENUM_DEAL_ENTRY _deal_entry = (ENUM_DEAL_ENTRY)HistoryDealGetInteger(_deal_ticket, DEAL_ENTRY); if (_deal_entry == DEAL_ENTRY_IN) { _result = HistoryDealGetInteger(_deal_ticket, DEAL_TIME); @@ -490,11 +490,11 @@ class Order : public SymbolInfo { return ::OrderCloseTime(); #else // __MQL5__ // @docs https://www.mql5.com/en/docs/trading/historydealgetinteger - long _result = 0; + int64 _result = 0; if (Order::TryOrderSelect(Order::OrderTicket(), SELECT_BY_TICKET, MODE_HISTORY)) { for (int i = HistoryDealsTotal() - 1; i >= 0; i--) { // https://www.mql5.com/en/docs/trading/historydealgetticket - const unsigned long _deal_ticket = HistoryDealGetTicket(i); + const uint64 _deal_ticket = HistoryDealGetTicket(i); const ENUM_DEAL_ENTRY _deal_entry = (ENUM_DEAL_ENTRY)HistoryDealGetInteger(_deal_ticket, DEAL_ENTRY); if (_deal_entry == DEAL_ENTRY_OUT || _deal_entry == DEAL_ENTRY_OUT_BY) { _result = HistoryDealGetInteger(_deal_ticket, DEAL_TIME); @@ -531,7 +531,7 @@ class Order : public SymbolInfo { if (Order::TryOrderSelect(Order::OrderTicket(), SELECT_BY_TICKET, MODE_HISTORY)) { for (int i = HistoryDealsTotal() - 1; i >= 0; i--) { // https://www.mql5.com/en/docs/trading/historydealgetticket - const unsigned long _deal_ticket = HistoryDealGetTicket(i); + const uint64 _deal_ticket = HistoryDealGetTicket(i); _result += _deal_ticket > 0 ? HistoryDealGetDouble(_deal_ticket, DEAL_COMMISSION) : 0; } } @@ -559,7 +559,7 @@ class Order : public SymbolInfo { if (Order::TryOrderSelect(Order::OrderTicket(), SELECT_BY_TICKET, MODE_HISTORY)) { for (int i = HistoryDealsTotal() - 1; i >= 0; i--) { // https://www.mql5.com/en/docs/trading/historydealgetticket - const unsigned long _deal_ticket = HistoryDealGetTicket(i); + const uint64 _deal_ticket = HistoryDealGetTicket(i); if (_deal_ticket > 0) { _result += HistoryDealGetDouble(_deal_ticket, DEAL_COMMISSION); _result += HistoryDealGetDouble(_deal_ticket, DEAL_FEE); @@ -613,8 +613,8 @@ class Order : public SymbolInfo { * - http://docs.mql4.com/trading/ordermagicnumber * - https://www.mql5.com/en/docs/trading/ordergetinteger */ - static long OrderMagicNumber() { return Order::OrderGetInteger(ORDER_MAGIC); } - unsigned long GetMagicNumber() { return orequest.magic; } + static int64 OrderMagicNumber() { return Order::OrderGetInteger(ORDER_MAGIC); } + uint64 GetMagicNumber() { return orequest.magic; } /** * Returns open price of the currently selected order/position. @@ -646,7 +646,7 @@ class Order : public SymbolInfo { if (Order::TryOrderSelect(Order::OrderTicket(), SELECT_BY_TICKET, MODE_HISTORY)) { for (int i = HistoryDealsTotal() - 1; i >= 0; i--) { // https://www.mql5.com/en/docs/trading/historydealgetticket - const unsigned long _deal_ticket = HistoryDealGetTicket(i); + const uint64 _deal_ticket = HistoryDealGetTicket(i); _result += _deal_ticket > 0 ? HistoryDealGetDouble(_deal_ticket, DEAL_PROFIT) : 0; } } @@ -714,7 +714,7 @@ class Order : public SymbolInfo { if (Order::TryOrderSelect(Order::OrderTicket(), SELECT_BY_TICKET, MODE_HISTORY)) { for (int i = HistoryDealsTotal() - 1; i >= 0; i--) { // https://www.mql5.com/en/docs/trading/historydealgetticket - const unsigned long _deal_ticket = HistoryDealGetTicket(i); + const uint64 _deal_ticket = HistoryDealGetTicket(i); _result += _deal_ticket > 0 ? HistoryDealGetDouble(_deal_ticket, DEAL_SWAP) : 0; } } @@ -755,14 +755,14 @@ class Order : public SymbolInfo { * @see https://docs.mql4.com/trading/orderticket * @see https://www.mql5.com/en/docs/trading/ordergetticket */ - static unsigned long OrderTicket() { + static uint64 OrderTicket() { #ifdef __MQL4__ return ::OrderTicket(); #else return selected_ticket_id; #endif } - // unsigned long GetTicket() const { return odata.Get(ORDER_PROP_TICKET); } + // uint64 GetTicket() const { return odata.Get(ORDER_PROP_TICKET); } /** * Returns order operation type of the currently selected order/position. @@ -798,9 +798,9 @@ class Order : public SymbolInfo { * Each executed order results in a deal that opens or modifies an already existing position. * The identifier of exactly this position is set to the executed order at this moment. */ - static unsigned long OrderGetPositionID() { + static uint64 OrderGetPositionID() { #ifdef __MQL4__ - unsigned long _ticket = ::OrderTicket(); + uint64 _ticket = ::OrderTicket(); for (int _pos = 0; _pos < OrdersTotal(); _pos++) { if (::OrderSelect(_pos, SELECT_BY_POS, MODE_TRADES) && ::OrderTicket() == _ticket) { return _pos; @@ -812,14 +812,14 @@ class Order : public SymbolInfo { #endif } /* @todo - unsigned long GetPositionID() { + uint64 GetPositionID() { #ifdef ORDER_POSITION_ID if (odata.position_id == 0) { OrderSelect(); Refresh(ORDER_POSITION_ID); } #endif - return odata.Get(ORDER_POSITION_ID); + return odata.Get(ORDER_POSITION_ID); } */ @@ -832,7 +832,7 @@ class Order : public SymbolInfo { * - https://www.mql5.com/en/docs/constants/structures/mqltraderequest * - https://www.mql5.com/en/docs/constants/tradingconstants/orderproperties */ - static unsigned long OrderGetPositionBy() { + static uint64 OrderGetPositionBy() { #ifdef __MQL4__ // @todo /* @@ -848,14 +848,14 @@ class Order : public SymbolInfo { #endif } /* @todo - unsigned long GetOrderPositionBy() { + uint64 GetOrderPositionBy() { #ifdef ORDER_POSITION_BY_ID if (odata.position_by_id == 0) { OrderSelect(); Refresh(ORDER_POSITION_BY_ID); } #endif - return odata.Get(ORDER_POSITION_BY_ID); + return odata.Get(ORDER_POSITION_BY_ID); } */ @@ -864,7 +864,7 @@ class Order : public SymbolInfo { * * @see https://www.mql5.com/en/docs/trading/positiongetticket */ - unsigned long PositionGetTicket(int _index) { + uint64 PositionGetTicket(int _index) { #ifdef __MQL4__ if (::OrderSelect(_index, SELECT_BY_POS, MODE_TRADES)) { return ::OrderTicket(); @@ -888,9 +888,9 @@ class Order : public SymbolInfo { * Returns true if successful, otherwise false. * To get details about error, call the GetLastError() function. */ - static bool OrderClose(unsigned long _ticket, // Unique number of the order ticket. - double _lots, // Number of lots. - double _price, // Closing price. + static bool OrderClose(uint64 _ticket, // Unique number of the order ticket. + double _lots, // Number of lots. + double _price, // Closing price. int _deviation, // Maximal possible deviation/slippage from the requested price (in points). color _arrow_color = CLR_NONE // Color of the closing arrow on the chart. ) { @@ -971,7 +971,7 @@ class Order : public SymbolInfo { /** * Closes a position by an opposite one. */ - static bool OrderCloseBy(long _ticket, long _opposite, color _color) { + static bool OrderCloseBy(int64 _ticket, int64 _opposite, color _color) { #ifdef __MQL4__ return ::OrderCloseBy((int)_ticket, (int)_opposite, _color); #else @@ -994,8 +994,8 @@ class Order : public SymbolInfo { /** * Closes a position by an opposite one. */ - bool OrderCloseBy(long _opposite, color _color) { - bool _result = OrderCloseBy(odata.Get(ORDER_PROP_TICKET), _opposite, _color); + bool OrderCloseBy(int64 _opposite, color _color) { + bool _result = OrderCloseBy(odata.Get(ORDER_PROP_TICKET), _opposite, _color); if (_result) { odata.Set(ORDER_PROP_REASON_CLOSE, ORDER_REASON_CLOSED_BY_OPPOSITE); } @@ -1007,7 +1007,7 @@ class Order : public SymbolInfo { * * @see: https://docs.mql4.com/trading/orderdelete */ - static bool OrderDelete(unsigned long _ticket, color _color = color()) { + static bool OrderDelete(uint64 _ticket, color _color = color()) { #ifdef __MQL4__ return ::OrderDelete((int)_ticket, _color); #else @@ -1022,7 +1022,7 @@ class Order : public SymbolInfo { #endif } bool OrderDelete(ENUM_ORDER_REASON_CLOSE _reason = ORDER_REASON_CLOSED_UNKNOWN) { - bool _result = Order::OrderDelete(odata.Get(ORDER_PROP_TICKET)); + bool _result = Order::OrderDelete(odata.Get(ORDER_PROP_TICKET)); if (_result) { odata.Set(ORDER_PROP_REASON_CLOSE, _reason); } @@ -1034,7 +1034,7 @@ class Order : public SymbolInfo { * * @see http://docs.mql4.com/trading/ordermodify */ - static bool OrderModify(unsigned long _ticket, // Ticket of the position. + static bool OrderModify(uint64 _ticket, // Ticket of the position. double _price, // Price. double _stoploss, // Stop loss. double _takeprofit, // Take profit. @@ -1061,7 +1061,7 @@ class Order : public SymbolInfo { #endif } bool OrderModify(double _sl, double _tp, double _price = 0, datetime _expiration = 0) { - if (odata.Get(ORDER_PROP_TIME_CLOSED) > 0) { + if (odata.Get(ORDER_PROP_TIME_CLOSED) > 0) { // Ignore change for already closed orders. return false; } else if (_sl == odata.Get(ORDER_SL) && _tp == odata.Get(ORDER_TP) && @@ -1069,8 +1069,8 @@ class Order : public SymbolInfo { // Ignore change for the same values. return false; } - bool _result = Order::OrderModify(odata.Get(ORDER_PROP_TICKET), _price, _sl, _tp, _expiration); - long _last_error = GetLastError(); + bool _result = Order::OrderModify(odata.Get(ORDER_PROP_TICKET), _price, _sl, _tp, _expiration); + int64 _last_error = GetLastError(); if (_result && OrderSelect()) { // Updating expected values. odata.Set(ORDER_SL, _sl); @@ -1084,9 +1084,10 @@ class Order : public SymbolInfo { if (IsClosed()) { Refresh(); } else { - GetLogger() PTR_DEREF Warning(StringFormat("Failed to modify order (#%d/p:%g/sl:%g/tp:%g/code:%d).", - odata.Get(ORDER_PROP_TICKET), _price, _sl, _tp, _last_error), - __FUNCTION_LINE__, ToCSV()); + GetLogger() + PTR_DEREF Warning(StringFormat("Failed to modify order (#%d/p:%g/sl:%g/tp:%g/code:%d).", + odata.Get(ORDER_PROP_TICKET), _price, _sl, _tp, _last_error), + __FUNCTION_LINE__, ToCSV()); Refresh(ORDER_SL); Refresh(ORDER_TP); // TODO: Refresh(ORDER_PRI) @@ -1098,7 +1099,7 @@ class Order : public SymbolInfo { _result = false; } else { ologger.Error(StringFormat("Error: %d! Failed to modify non-existing order (#%d/p:%g/sl:%g/tp:%g).", - _last_error, odata.Get(ORDER_PROP_TICKET), _price, _sl, _tp), + _last_error, odata.Get(ORDER_PROP_TICKET), _price, _sl, _tp), __FUNCTION_LINE__, ToCSV()); } } @@ -1161,17 +1162,17 @@ class Order : public SymbolInfo { * Returns number of the ticket assigned to the order by the trade server * or -1 if it fails. */ - static long OrderSend(string _symbol, // Symbol. - int _cmd, // Operation. - double _volume, // Volume. - double _price, // Price. - unsigned long _deviation, // Deviation. - double _stoploss, // Stop loss. - double _takeprofit, // Take profit. - string _comment = NULL_STRING, // Comment. - unsigned long _magic = 0, // Magic number. - datetime _expiration = 0, // Pending order expiration. - color _arrow_color = clrNONE // Color. + static int64 OrderSend(string _symbol, // Symbol. + int _cmd, // Operation. + double _volume, // Volume. + double _price, // Price. + uint64 _deviation, // Deviation. + double _stoploss, // Stop loss. + double _takeprofit, // Take profit. + string _comment = NULL_STRING, // Comment. + uint64 _magic = 0, // Magic number. + datetime _expiration = 0, // Pending order expiration. + color _arrow_color = clrNONE // Color. ) { #ifdef __MQL4__ #ifdef __debug__ @@ -1211,7 +1212,7 @@ class Order : public SymbolInfo { if (!Order::OrderSend(_request, _result)) { return -1; } - return (long)_result.order; + return (int64)_result.order; #endif } static bool OrderSend(const MqlTradeRequest &_request, MqlTradeResult &_result, MqlTradeCheckResult &_result_check, @@ -1337,8 +1338,8 @@ class Order : public SymbolInfo { MqlTradeCheckResult _result_check = {0}; return Order::OrderSend(_request, _result, _result_check); } - long OrderSend() { - long _result = -1; + int64 OrderSend() { + int64 _result = -1; odata.ResetError(); #ifdef __MQL4__ _result = Order::OrderSend(orequest.symbol, // Symbol. @@ -1369,8 +1370,8 @@ class Order : public SymbolInfo { // However, this is not a sign of successful execution of a trade operation. // @see: https://www.mql5.com/en/docs/trading/ordersend // In order to obtain information about the error, call the GetLastError() function. - odata.Set(ORDER_PROP_TICKET, oresult.order); - _result = (long)oresult.order; + odata.Set(ORDER_PROP_TICKET, oresult.order); + _result = (int64)oresult.order; } else { // The function execution result is placed to structure MqlTradeResult, // whose retcode field contains the trade server return code. @@ -1422,7 +1423,7 @@ class Order : public SymbolInfo { * @return * Returns number of the fake ticket assigned to the order. */ - long OrderSendDummy() { + int64 OrderSendDummy() { static int _dummy_order_id = 0; odata.ResetError(); orequest.type_filling = orequest.type_filling ? orequest.type_filling : GetOrderFilling(orequest.symbol); @@ -1441,13 +1442,13 @@ class Order : public SymbolInfo { oresult.retcode = TRADE_RETCODE_DONE; // Mark trade operation as done. oresult.comment = orequest.comment; // Order comment. oresult.order = ++_dummy_order_id; // Assign sequential order id. Starts from 1. - odata.Set(ORDER_PROP_TICKET, oresult.order); + odata.Set(ORDER_PROP_TICKET, oresult.order); RefreshDummy(); odata.Set(ORDER_PROP_LAST_ERROR, oresult.retcode); // @todo Register order in a static dictionary order_id -> order for further select. - return (long)oresult.order; + return (int64)oresult.order; } /** @@ -1504,7 +1505,7 @@ class Order : public SymbolInfo { * * @see http://docs.mql4.com/trading/orderselect */ - static bool OrderSelect(unsigned long _index, int select, int pool = MODE_TRADES) { + static bool OrderSelect(uint64 _index, int select, int pool = MODE_TRADES) { ResetLastError(); #ifdef __MQL4__ return ::OrderSelect((int)_index, select, pool); @@ -1526,7 +1527,7 @@ class Order : public SymbolInfo { // HistoryOrderSelect(ticket) function, which clears the cache and re-fill it with only one order, in the // case of success. Recall that the value, returned from HistoryOrdersTotal() depends on the number of orders // in the cache. - unsigned long _ticket_id = HistoryOrderGetTicket((int)_index); + uint64 _ticket_id = HistoryOrderGetTicket((int)_index); if (_ticket_id != 0) { selected_ticket_type = ORDER_SELECT_TYPE_HISTORY; } else if (::HistoryOrderSelect(_ticket_id)) { @@ -1588,27 +1589,27 @@ class Order : public SymbolInfo { * * @see http://docs.mql4.com/trading/orderselect */ - static bool TryOrderSelect(unsigned long _index, int select, int pool = MODE_TRADES) { + static bool TryOrderSelect(uint64 _index, int select, int pool = MODE_TRADES) { bool result = OrderSelect(_index, select, pool); ResetLastError(); return result; } - static bool OrderSelectByTicket(unsigned long _ticket) { + static bool OrderSelectByTicket(uint64 _ticket) { return Order::OrderSelect(_ticket, SELECT_BY_TICKET, MODE_TRADES) || Order::OrderSelect(_ticket, SELECT_BY_TICKET, MODE_HISTORY); } - static bool TryOrderSelectByTicket(unsigned long _ticket) { + static bool TryOrderSelectByTicket(uint64 _ticket) { return Order::TryOrderSelect(_ticket, SELECT_BY_TICKET, MODE_TRADES) || Order::TryOrderSelect(_ticket, SELECT_BY_TICKET, MODE_HISTORY); } - bool OrderSelect() { return !IsSelected() ? Order::OrderSelectByTicket(odata.Get(ORDER_PROP_TICKET)) : true; } + bool OrderSelect() { return !IsSelected() ? Order::OrderSelectByTicket(odata.Get(ORDER_PROP_TICKET)) : true; } bool TryOrderSelect() { - return !IsSelected() ? Order::TryOrderSelectByTicket(odata.Get(ORDER_PROP_TICKET)) : true; + return !IsSelected() ? Order::TryOrderSelectByTicket(odata.Get(ORDER_PROP_TICKET)) : true; } - bool OrderSelectHistory() { return OrderSelect(odata.Get(ORDER_PROP_TICKET), MODE_HISTORY); } + bool OrderSelectHistory() { return OrderSelect(odata.Get(ORDER_PROP_TICKET), MODE_HISTORY); } /* Setters */ @@ -1631,7 +1632,7 @@ class Order : public SymbolInfo { ResetLastError(); // Checks if order is updated for the first time. - bool _is_init = odata.Get(ORDER_PRICE_OPEN) == 0 || odata.Get(ORDER_TIME_SETUP) == 0; + bool _is_init = odata.Get(ORDER_PRICE_OPEN) == 0 || odata.Get(ORDER_TIME_SETUP) == 0; // Update integer values. if (_is_init) { @@ -1666,9 +1667,9 @@ class Order : public SymbolInfo { } // Updates whether order is open or closed. - if (odata.Get(ORDER_PROP_TIME_CLOSED) == 0) { + if (odata.Get(ORDER_PROP_TIME_CLOSED) == 0) { // Updates close time. - odata.Set(ORDER_PROP_TIME_CLOSED, Order::OrderCloseTime()); + odata.Set(ORDER_PROP_TIME_CLOSED, Order::OrderCloseTime()); } if (IsOpen()) { @@ -1701,7 +1702,7 @@ class Order : public SymbolInfo { odata.ProcessLastError(); ResetLastError(); } - odata.Set(ORDER_PROP_TIME_LAST_REFRESH, TimeCurrent()); + odata.Set(ORDER_PROP_TIME_LAST_REFRESH, TimeCurrent()); return _result && _last_error == ERR_NO_ERROR; } @@ -1736,7 +1737,7 @@ class Order : public SymbolInfo { // @todo: More RefreshDummy(XXX); odata.ResetError(); - odata.Set(ORDER_PROP_TIME_LAST_REFRESH, TimeCurrent()); + odata.Set(ORDER_PROP_TIME_LAST_REFRESH, TimeCurrent()); odata.ProcessLastError(); return _result && GetLastError() == ERR_NO_ERROR; } @@ -1888,7 +1889,7 @@ class Order : public SymbolInfo { */ bool Refresh(ENUM_ORDER_PROPERTY_INTEGER _prop_id) { bool _result = false; - long _value = WRONG_VALUE; + int64 _value = WRONG_VALUE; ResetLastError(); switch (_prop_id) { case ORDER_MAGIC: @@ -2092,9 +2093,9 @@ class Order : public SymbolInfo { * - https://www.mql5.com/en/docs/trading/ordergetinteger * */ - static long OrderGetInteger(ENUM_ORDER_PROPERTY_INTEGER property_id) { + static int64 OrderGetInteger(ENUM_ORDER_PROPERTY_INTEGER property_id) { ResetLastError(); - long _result = 0; + int64 _result = 0; #ifdef __MQL4__ #ifdef __debug__ Print("OrderGetInteger(", EnumToString(property_id), ")..."); @@ -2183,9 +2184,9 @@ class Order : public SymbolInfo { return OrderGetParam(property_id, selected_ticket_type, ORDER_SELECT_DATA_TYPE_INTEGER, _result); #endif } - static bool OrderGetInteger(ENUM_ORDER_PROPERTY_INTEGER property_id, long &_out) { + static bool OrderGetInteger(ENUM_ORDER_PROPERTY_INTEGER property_id, int64 &_out) { #ifdef __MQL4__ - _out = (long)OrderGetInteger(property_id); + _out = (int64)OrderGetInteger(property_id); return true; #else return OrderGetParam(property_id, selected_ticket_type, ORDER_SELECT_DATA_TYPE_INTEGER, _out) >= 0; @@ -2334,15 +2335,15 @@ class Order : public SymbolInfo { * @param ENUM_ORDER_SELECT_TYPE type * Identifier of a property. * - * @param long& _out + * @param int64& _out * Reference to output value (the same as returned from the function). * - * @return long + * @return int64 * Returns the value of the property (same as for `_out` variable). * In case of error, information can be obtained using GetLastError() function. * */ - static long OrderGetValue(int property_id, ENUM_ORDER_SELECT_TYPE type, long &_out) { + static int64 OrderGetValue(int property_id, ENUM_ORDER_SELECT_TYPE type, int64 &_out) { switch (type) { case ORDER_SELECT_TYPE_NONE: return 0; @@ -2462,7 +2463,7 @@ class Order : public SymbolInfo { template static X OrderGetParam(int _prop_id, ENUM_ORDER_SELECT_TYPE _type, ENUM_ORDER_SELECT_DATA_TYPE _data_type, X &_out) { #ifndef __MQL4__ - long _long; + int64 _long; string _string; switch (selected_ticket_type) { case ORDER_SELECT_TYPE_NONE: @@ -2705,12 +2706,12 @@ class Order : public SymbolInfo { * Returns true when the condition is met. */ bool CheckCondition(ENUM_ORDER_CONDITION _cond, ARRAY_REF(DataParamEntry, _args)) { - // float _profit = (float)Get(ORDER_PROP_PROFIT_PIPS); + // float _profit = (float)Get(ORDER_PROP_PROFIT_PIPS); switch (_cond) { case ORDER_COND_IN_LOSS: - return Get(ORDER_PROP_PROFIT_PIPS) < (ArraySize(_args) > 0 ? -DataParamEntry::ToDouble(_args[0]) : 0); + return Get(ORDER_PROP_PROFIT_PIPS) < (ArraySize(_args) > 0 ? -DataParamEntry::ToDouble(_args[0]) : 0); case ORDER_COND_IN_PROFIT: - return Get(ORDER_PROP_PROFIT_PIPS) > (ArraySize(_args) > 0 ? DataParamEntry::ToDouble(_args[0]) : 0); + return Get(ORDER_PROP_PROFIT_PIPS) > (ArraySize(_args) > 0 ? DataParamEntry::ToDouble(_args[0]) : 0); case ORDER_COND_IS_CLOSED: return IsClosed(); case ORDER_COND_IS_OPEN: @@ -2718,7 +2719,7 @@ class Order : public SymbolInfo { case ORDER_COND_LIFETIME_GT_ARG: case ORDER_COND_LIFETIME_LT_ARG: if (ArraySize(_args) > 0) { - long _arg_value = DataParamEntry::ToInteger(_args[0]); + int64 _arg_value = DataParamEntry::ToInteger(_args[0]); switch (_cond) { case ORDER_COND_LIFETIME_GT_ARG: return TimeCurrent() - odata.Get(ORDER_TIME_SETUP) > _arg_value; @@ -2733,7 +2734,7 @@ class Order : public SymbolInfo { case ORDER_COND_PROP_LT_ARG: { if (ArraySize(_args) >= 2) { // First argument is enum value (order property). - long _prop_id = _args[0].integer_value; + int64 _prop_id = _args[0].integer_value; // Second argument is the actual value with compare with. switch (_args[1].type) { case TYPE_DOUBLE: @@ -2852,7 +2853,7 @@ class Order : public SymbolInfo { /** * Returns order details in text. */ - string ToString(ARRAY_REF(long, _props), ENUM_DATATYPE _type = TYPE_DOUBLE, string _dlm = ";") { + string ToString(ARRAY_REF(int64, _props), ENUM_DATATYPE _type = TYPE_DOUBLE, string _dlm = ";") { int i = 0; string _output = ""; switch (_type) { @@ -2863,7 +2864,7 @@ class Order : public SymbolInfo { break; case TYPE_LONG: for (i = 0; i < Array::ArraySize(_props); i++) { - _output += StringFormat("%d%s", odata.Get((ENUM_ORDER_PROPERTY_INTEGER)_props[i]), C_STR(_dlm)); + _output += StringFormat("%d%s", odata.Get((ENUM_ORDER_PROPERTY_INTEGER)_props[i]), C_STR(_dlm)); } break; case TYPE_STRING: @@ -2908,5 +2909,5 @@ class Order : public SymbolInfo { #ifdef __MQL5__ // Assigns values to static variables. ENUM_ORDER_SELECT_TYPE Order::selected_ticket_type = ORDER_SELECT_TYPE_NONE; -unsigned long Order::selected_ticket_id = 0; +uint64 Order::selected_ticket_id = 0; #endif diff --git a/Platform/Order.struct.h b/Platform/Order.struct.h index a1773c1bb..f35b63a8a 100644 --- a/Platform/Order.struct.h +++ b/Platform/Order.struct.h @@ -59,29 +59,29 @@ struct MqlTradeCheckResult { // @see: https://www.mql5.com/en/docs/constants/structures/mqltraderequest struct MqlTradeRequest { ENUM_TRADE_REQUEST_ACTIONS action; // Trade operation type. - unsigned long magic; // Expert Advisor ID (magic number). - unsigned long order; // Order ticket. + uint64 magic; // Expert Advisor ID (magic number). + uint64 order; // Order ticket. string symbol; // Trade symbol. double volume; // Requested volume for a deal in lots. double price; // Price. double stoplimit; // StopLimit level of the order. double sl; // Stop Loss level of the order. double tp; // Take Profit level of the order. - unsigned long deviation; // Maximal possible deviation from the requested price. + uint64 deviation; // Maximal possible deviation from the requested price. ENUM_ORDER_TYPE type; // Order type. ENUM_ORDER_TYPE_FILLING type_filling; // Order execution type. ENUM_ORDER_TYPE_TIME type_time; // Order expiration type. datetime expiration; // Order expiration time (for the orders of ORDER_TIME_SPECIFIED type. string comment; // Order comment. - unsigned long position; // Position ticket. - unsigned long position_by; // The ticket of an opposite position. + uint64 position; // Position ticket. + uint64 position_by; // The ticket of an opposite position. }; // @see: https://www.mql5.com/en/docs/constants/structures/mqltraderesult struct MqlTradeResult { unsigned int retcode; // Operation return code. - unsigned long deal; // Deal ticket, if it is performed. - unsigned long order; // Order ticket, if it is placed. + uint64 deal; // Deal ticket, if it is performed. + uint64 order; // Order ticket, if it is placed. double volume; // Deal volume, confirmed by broker. double price; // Deal price, confirmed by broker. double bid; // Current Bid price. @@ -232,10 +232,10 @@ struct OrderParams { */ struct OrderData { protected: - unsigned long magic; // Magic number. - unsigned long position_id; // Position ID. - unsigned long position_by_id; // Position By ID. - unsigned long ticket; // Ticket number. + uint64 magic; // Magic number. + uint64 position_id; // Position ID. + uint64 position_by_id; // Position By ID. + uint64 ticket; // Ticket number. ENUM_ORDER_STATE state; // State. string comment; // Comment. double commission; // Commission. @@ -248,12 +248,12 @@ struct OrderData { double swap; // Order cumulative swap. datetime time_closed; // Closed time. datetime time_done; // Execution/cancellation time. - long time_done_msc; // The time of execution/cancellation time (in msc). + int64 time_done_msc; // The time of execution/cancellation time (in msc). datetime time_expiration; // Order expiration time (for the orders of ORDER_TIME_SPECIFIED type). datetime time_last_refresh; // Last refresh of order values. datetime time_last_update; // Last update of order stops. datetime time_setup; // Setup time. - long time_setup_msc; // The time of placing the order (in msc). + int64 time_setup_msc; // The time of placing the order (in msc). double total_fees; // Total fees. double sl; // Current Stop loss level of the order. double tp; // Current Take Profit level of the order. @@ -373,13 +373,13 @@ struct OrderData { case ORDER_STATE: return (T)state; case ORDER_TIME_EXPIRATION: - return (T)(long)time_expiration; + return (T)(int64)time_expiration; case ORDER_TIME_DONE: - return (T)(long)time_done; + return (T)(int64)time_done; case ORDER_TIME_DONE_MSC: return (T)time_done_msc; case ORDER_TIME_SETUP: - return (T)(long)time_setup; + return (T)(int64)time_setup; case ORDER_TIME_SETUP_MSC: return (T)time_setup_msc; case ORDER_TYPE_FILLING: @@ -507,10 +507,10 @@ struct OrderData { profit = (double)_value; return; case ORDER_PROP_REASON_CLOSE: - reason_close = (ENUM_ORDER_REASON_CLOSE)(long)_value; + reason_close = (ENUM_ORDER_REASON_CLOSE)(int64)_value; return; case ORDER_PROP_TICKET: - ticket = (unsigned long)_value; + ticket = (uint64)_value; return; case ORDER_PROP_TIME_CLOSED: time_closed = (datetime)_value; @@ -559,7 +559,7 @@ struct OrderData { } SetUserError(ERR_INVALID_PARAMETER); } - void Set(ENUM_ORDER_PROPERTY_INTEGER _prop_name, long _value) { + void Set(ENUM_ORDER_PROPERTY_INTEGER _prop_name, int64 _value) { switch (_prop_name) { case ORDER_TYPE: type = (ENUM_ORDER_TYPE)_value; @@ -626,7 +626,7 @@ struct OrderData { } /* template - T Set(long _prop_name) { + T Set(int64 _prop_name) { // MQL4 back-compatibility version for non-enum properties. return Set((ENUM_ORDER_PROPERTY_INTEGER)_prop_name); } @@ -878,7 +878,7 @@ struct OrderStatic { * @return * Identifying (magic) number of the currently selected order/position. */ - static long MagicNumber() { + static int64 MagicNumber() { #ifdef __MQL4__ return ::OrderMagicNumber(); #else @@ -945,7 +945,7 @@ struct OrderStatic { * - https://docs.mql4.com/trading/orderticket * - https://www.mql5.com/en/docs/trading/positiongetticket */ - static unsigned long Ticket() { + static uint64 Ticket() { #ifdef __MQL4__ return ::OrderTicket(); #else diff --git a/Platform/OrderQuery.h b/Platform/OrderQuery.h index c76f485e5..ad27efbbc 100644 --- a/Platform/OrderQuery.h +++ b/Platform/OrderQuery.h @@ -38,7 +38,7 @@ class OrderQuery : public Dynamic { protected: - DictStruct> *orders; + DictStruct> *orders; public: // Enumeration of comparison operators. @@ -53,7 +53,7 @@ class OrderQuery : public Dynamic { }; OrderQuery() {} - OrderQuery(DictStruct> &_orders) : orders(GetPointer(_orders)) {} + OrderQuery(DictStruct> &_orders) : orders(GetPointer(_orders)) {} /** * Calculates sum of order's value based on the property's enum. @@ -67,7 +67,7 @@ class OrderQuery : public Dynamic { template T CalcSumByProp(E _prop) { T _sum = 0; - for (DictStructIterator> iter = orders PTR_DEREF Begin(); iter.IsValid(); ++iter) { + for (DictStructIterator> iter = orders PTR_DEREF Begin(); iter.IsValid(); ++iter) { _sum += iter.Value() REF_DEREF Get(_prop); } return _sum; @@ -82,7 +82,7 @@ class OrderQuery : public Dynamic { template T CalcSumByPropWithCond(E _prop, ECT _prop_cond_type, ECV _prop_cond_value) { T _sum = 0; - for (DictStructIterator> iter = orders PTR_DEREF Begin(); iter.IsValid(); ++iter) { + for (DictStructIterator> iter = orders PTR_DEREF Begin(); iter.IsValid(); ++iter) { Order *_order = iter.Value().Ptr(); if (_order PTR_DEREF Get(_prop_cond_type) == _prop_cond_value) { _sum += _order PTR_DEREF Get(_prop); @@ -105,7 +105,7 @@ class OrderQuery : public Dynamic { return _order_ref_found; } _order_ref_found = orders PTR_DEREF Begin().Value(); - for (DictStructIterator> iter = orders PTR_DEREF Begin(); iter.IsValid(); ++iter) { + for (DictStructIterator> iter = orders PTR_DEREF Begin(); iter.IsValid(); ++iter) { Ref _order_ref = iter.Value(); if (Compare(_order_ref REF_DEREF Get(_prop), _op, _order_ref_found REF_DEREF Get(_prop))) { _order_ref_found = _order_ref; @@ -127,7 +127,7 @@ class OrderQuery : public Dynamic { if (orders PTR_DEREF Size() == 0) { return _order_ref_found; } - for (DictStructIterator> iter = orders PTR_DEREF Begin(); iter.IsValid(); ++iter) { + for (DictStructIterator> iter = orders PTR_DEREF Begin(); iter.IsValid(); ++iter) { Ref _order_ref = iter.Value(); if (Compare(_order_ref REF_DEREF Get(_prop), _op, _value)) { _order_ref_found = _order_ref; @@ -197,5 +197,5 @@ class OrderQuery : public Dynamic { * @return * Returns a pointer to the new instance. */ - static OrderQuery *GetInstance(DictStruct> &_orders) { return new OrderQuery(_orders); } + static OrderQuery *GetInstance(DictStruct> &_orders) { return new OrderQuery(_orders); } }; diff --git a/Platform/Orders.h b/Platform/Orders.h index 42279c9fd..dceeb1d7a 100644 --- a/Platform/Orders.h +++ b/Platform/Orders.h @@ -124,9 +124,9 @@ class Orders { /** * Finds order in the selected pool. */ - Order *SelectOrder(unsigned long _ticket) { + Order *SelectOrder(uint64 _ticket) { for (unsigned int _pos = ArraySize(orders); _pos >= 0; _pos--) { - if (orders[_pos] PTR_DEREF Get(ORDER_PROP_TICKET) == _ticket) { + if (orders[_pos] PTR_DEREF Get(ORDER_PROP_TICKET) == _ticket) { return orders[_pos]; } } @@ -136,7 +136,7 @@ class Orders { /** * Select order object by ticket. */ - Order *SelectByTicket(unsigned long _ticket) { + Order *SelectByTicket(uint64 _ticket) { Order *_order = SelectOrder(_ticket); if (_order != NULL) { return _order; @@ -155,7 +155,7 @@ class Orders { /** * Calculate number of lots for open positions. */ - static double GetOpenLots(string _symbol = NULL_STRING, long magic_number = 0, int magic_range = 0) { + static double GetOpenLots(string _symbol = NULL_STRING, int64 magic_number = 0, int magic_range = 0) { double total_lots = 0; // @todo: Convert to MQL5. _symbol = _symbol != NULL_STRING ? _symbol : _Symbol; diff --git a/Platform/Platform.enum.h b/Platform/Platform.enum.h new file mode 100644 index 000000000..edd657855 --- /dev/null +++ b/Platform/Platform.enum.h @@ -0,0 +1,44 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 . + * + */ + +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + +#ifndef __MQL4__ +// @note Values differ from the documentation at +// https://www.mql5.com/en/docs/matrix/matrix_initialization/matrix_copyticks +// @see https://www.mql5.com/en/forum/448933 +enum ENUM_COPY_TICKS { + COPY_TICKS_INFO = 1, + COPY_TICKS_TRADE = 2, + COPY_TICKS_ALL = 3, + COPY_TICKS_VERTICAL = 32768, + COPY_TICKS_TIME_MS = 65536, + COPY_TICKS_BID = 131072, + COPY_TICKS_ASK = 262144, + COPY_TICKS_LAST = 524288, + COPY_TICKS_VOLUME = 1048576, + COPY_TICKS_FLAGS = 2097152 +}; +#endif \ No newline at end of file diff --git a/Platform/Platform.extern.h b/Platform/Platform.extern.h index b9c93db05..538725218 100644 --- a/Platform/Platform.extern.h +++ b/Platform/Platform.extern.h @@ -80,7 +80,12 @@ extern int CopyLow(string symbol_name, ENUM_TIMEFRAMES timeframe, int start_pos, extern int CopyClose(string symbol_name, ENUM_TIMEFRAMES timeframe, int start_pos, int count, ARRAY_REF(double, close_array)); -extern unsigned int64 PositionGetTicket(int _index); +extern double iOpen(string symbol, int timeframe, int shift); +extern double iHigh(string symbol, int timeframe, int shift); +extern double iLow(string symbol, int timeframe, int shift); +extern double iClose(string symbol, int timeframe, int shift); + +extern uint64 PositionGetTicket(int _index); extern int64 PositionGetInteger(ENUM_POSITION_PROPERTY_INTEGER property_id); @@ -90,13 +95,13 @@ extern string PositionGetString(ENUM_POSITION_PROPERTY_STRING property_id); extern int HistoryDealsTotal(); -extern unsigned int64 HistoryDealGetTicket(int index); +extern uint64 HistoryDealGetTicket(int index); -extern int64 HistoryDealGetInteger(unsigned int64 ticket_number, ENUM_DEAL_PROPERTY_INTEGER property_id); +extern int64 HistoryDealGetInteger(uint64 ticket_number, ENUM_DEAL_PROPERTY_INTEGER property_id); -extern double HistoryDealGetDouble(unsigned int64 ticket_number, ENUM_DEAL_PROPERTY_DOUBLE property_id); +extern double HistoryDealGetDouble(uint64 ticket_number, ENUM_DEAL_PROPERTY_DOUBLE property_id); -extern string HistoryDealGetString(unsigned int64 ticket_number, ENUM_DEAL_PROPERTY_STRING property_id); +extern string HistoryDealGetString(uint64 ticket_number, ENUM_DEAL_PROPERTY_STRING property_id); extern bool OrderSelect(int index); @@ -108,25 +113,25 @@ extern bool OrderSend(const MqlTradeRequest& request, MqlTradeResult& result); extern bool OrderCheck(const MqlTradeRequest& request, MqlTradeCheckResult& result); -extern unsigned int64 OrderGetTicket(int index); +extern uint64 OrderGetTicket(int index); -extern unsigned int64 HistoryOrderGetTicket(int index); +extern uint64 HistoryOrderGetTicket(int index); extern bool HistorySelectByPosition(int64 position_id); -extern bool HistoryDealSelect(unsigned int64 ticket); +extern bool HistoryDealSelect(uint64 ticket); extern int64 OrderGetInteger(ENUM_ORDER_PROPERTY_INTEGER property_id); -extern int64 HistoryOrderGetInteger(unsigned int64 ticket_number, ENUM_ORDER_PROPERTY_INTEGER property_id); +extern int64 HistoryOrderGetInteger(uint64 ticket_number, ENUM_ORDER_PROPERTY_INTEGER property_id); extern double OrderGetDouble(ENUM_ORDER_PROPERTY_DOUBLE property_id); -extern double HistoryOrderGetDouble(unsigned int64 ticket_number, ENUM_ORDER_PROPERTY_DOUBLE property_id); +extern double HistoryOrderGetDouble(uint64 ticket_number, ENUM_ORDER_PROPERTY_DOUBLE property_id); string OrderGetString(ENUM_ORDER_PROPERTY_STRING property_id); -string HistoryOrderGetString(unsigned int64 ticket_number, ENUM_ORDER_PROPERTY_STRING property_id); +string HistoryOrderGetString(uint64 ticket_number, ENUM_ORDER_PROPERTY_STRING property_id); extern int PositionsTotal(); diff --git a/Platform/Platform.h b/Platform/Platform.h index 67d33153b..9fbbc7ae9 100644 --- a/Platform/Platform.h +++ b/Platform/Platform.h @@ -78,10 +78,10 @@ class Platform { static bool time_clear_flags; // List of added indicators. - static DictStruct> indis; + static DictStruct> indis; // List of default Candle/Tick indicators. - static DictStruct> indis_dflt; + static DictStruct> indis_dflt; // Result of the last tick. static bool last_tick_result; @@ -121,7 +121,7 @@ class Platform { // Checking starting periods and updating time to current one. time_flags = time.GetStartedPeriods(); - DictStructIterator> _iter; + DictStructIterator> _iter; last_tick_result = false; @@ -173,7 +173,7 @@ class Platform { /** * Returns dictionary of added indicators (keyed by unique id). */ - static DictStruct> *GetIndicators() { return &indis; } + static DictStruct> *GetIndicators() { return &indis; } /** * Adds indicator to be processed by platform. @@ -181,7 +181,7 @@ class Platform { static void Add(IndicatorData *_indi) { Ref _ref = _indi; - DictStructIterator> _iter; + DictStructIterator> _iter; for (_iter = indis_dflt.Begin(); _iter.IsValid(); ++_iter) { if (_iter.Value() == _ref) { Alert("Warning: ", _indi PTR_DEREF GetFullName(), @@ -411,7 +411,7 @@ class Platform { */ static string IndicatorsToString(int _shift = 0) { string _result; - for (DictStructIterator> _iter = indis.Begin(); _iter.IsValid(); ++_iter) { + for (DictStructIterator> _iter = indis.Begin(); _iter.IsValid(); ++_iter) { IndicatorDataEntry _entry = _iter.Value() REF_DEREF GetEntry(_shift); _result += _iter.Value() REF_DEREF GetFullName() + " = " + _entry.ToString() + "\n"; } @@ -492,8 +492,8 @@ bool Platform::time_clear_flags = true; int Platform::global_tick_index = 0; string Platform::symbol = PLATFORM_WRONG_SYMBOL; ENUM_TIMEFRAMES Platform::period = PLATFORM_WRONG_TIMEFRAME; -DictStruct> Platform::indis; -DictStruct> Platform::indis_dflt; +DictStruct> Platform::indis; +DictStruct> Platform::indis_dflt; #ifndef __MQL__ // Following methods must be there are they're externed in Platform.extern.h @@ -517,7 +517,7 @@ int CopyBuffer(int indicator_handle, int buffer_num, int start_pos, int count, A return 0; } -unsigned int64 PositionGetTicket(int _index) { +uint64 PositionGetTicket(int _index) { Print("Not yet implemented: ", __FUNCTION__, " returns 0."); return 0; } @@ -542,22 +542,22 @@ int HistoryDealsTotal() { return 0; } -unsigned int64 HistoryDealGetTicket(int index) { +uint64 HistoryDealGetTicket(int index) { Print("Not yet implemented: ", __FUNCTION__, " returns 0."); return 0; } -int64 HistoryDealGetInteger(unsigned int64 ticket_number, ENUM_DEAL_PROPERTY_INTEGER property_id) { +int64 HistoryDealGetInteger(uint64 ticket_number, ENUM_DEAL_PROPERTY_INTEGER property_id) { Print("Not yet implemented: ", __FUNCTION__, " returns 0."); return 0; } -double HistoryDealGetDouble(unsigned int64 ticket_number, ENUM_DEAL_PROPERTY_DOUBLE property_id) { +double HistoryDealGetDouble(uint64 ticket_number, ENUM_DEAL_PROPERTY_DOUBLE property_id) { Print("Not yet implemented: ", __FUNCTION__, " returns 0."); return 0; } -string HistoryDealGetString(unsigned int64 ticket_number, ENUM_DEAL_PROPERTY_STRING property_id) { +string HistoryDealGetString(uint64 ticket_number, ENUM_DEAL_PROPERTY_STRING property_id) { Print("Not yet implemented: ", __FUNCTION__, " returns empty string."); return 0; } @@ -587,12 +587,12 @@ bool OrderCheck(const MqlTradeRequest &request, MqlTradeCheckResult &result) { return false; } -unsigned int64 OrderGetTicket(int index) { +uint64 OrderGetTicket(int index) { Print("Not yet implemented: ", __FUNCTION__, " returns 0."); return 0; } -unsigned int64 HistoryOrderGetTicket(int index) { +uint64 HistoryOrderGetTicket(int index) { Print("Not yet implemented: ", __FUNCTION__, " returns 0."); return 0; } @@ -602,7 +602,7 @@ bool HistorySelectByPosition(int64 position_id) { return false; } -bool HistoryDealSelect(unsigned int64 ticket) { +bool HistoryDealSelect(uint64 ticket) { Print("Not yet implemented: ", __FUNCTION__, " returns false."); return false; } @@ -612,7 +612,7 @@ int64 OrderGetInteger(ENUM_ORDER_PROPERTY_INTEGER property_id) { return 0; } -int64 HistoryOrderGetInteger(unsigned int64 ticket_number, ENUM_ORDER_PROPERTY_INTEGER property_id) { +int64 HistoryOrderGetInteger(uint64 ticket_number, ENUM_ORDER_PROPERTY_INTEGER property_id) { Print("Not yet implemented: ", __FUNCTION__, " returns 0."); return 0; } @@ -622,7 +622,7 @@ double OrderGetDouble(ENUM_ORDER_PROPERTY_DOUBLE property_id) { return 0; } -double HistoryOrderGetDouble(unsigned int64 ticket_number, ENUM_ORDER_PROPERTY_DOUBLE property_id) { +double HistoryOrderGetDouble(uint64 ticket_number, ENUM_ORDER_PROPERTY_DOUBLE property_id) { Print("Not yet implemented: ", __FUNCTION__, " returns 0."); return 0; } @@ -632,7 +632,7 @@ string OrderGetString(ENUM_ORDER_PROPERTY_STRING property_id) { return 0; } -string HistoryOrderGetString(unsigned int64 ticket_number, ENUM_ORDER_PROPERTY_STRING property_id) { +string HistoryOrderGetString(uint64 ticket_number, ENUM_ORDER_PROPERTY_STRING property_id) { Print("Not yet implemented: ", __FUNCTION__, " returns empty string."); return 0; } @@ -687,6 +687,26 @@ int CopyRealVolume(string symbol_name, ENUM_TIMEFRAMES timeframe, int start_pos, return 0; } +double iOpen(string symbol, int timeframe, int shift) { + Print("Not yet implemented: ", __FUNCTION__, " returns 1.0."); + return 1.0; +} + +double iHigh(string symbol, int timeframe, int shift) { + Print("Not yet implemented: ", __FUNCTION__, " returns 1.0."); + return 1.0; +} + +double iLow(string symbol, int timeframe, int shift) { + Print("Not yet implemented: ", __FUNCTION__, " returns 1.0."); + return 1.0; +} + +double iClose(string symbol, int timeframe, int shift) { + Print("Not yet implemented: ", __FUNCTION__, " returns 1.0."); + return 1.0; +} + int ChartID() { return Platform::ChartID(); } bool OrderCalcMargin(ENUM_ORDER_TYPE _action, string _symbol, double _volume, double _price, double &_margin) { diff --git a/Platform/Plot.h b/Platform/Plot.h index d2f8aa64e..427f488cb 100644 --- a/Platform/Plot.h +++ b/Platform/Plot.h @@ -73,14 +73,14 @@ class Plot; class Plot : public Object { protected: // Variables. - long chart_id; + int64 chart_id; // Class variables. public: /** * Class constructor. */ - Plot(long _chart_id = 0) : chart_id(_chart_id != 0 ? _chart_id : ::ChartID()) {} + Plot(int64 _chart_id = 0) : chart_id(_chart_id != 0 ? _chart_id : ::ChartID()) {} /* Graphic object related methods */ @@ -92,7 +92,7 @@ class Plot : public Object { * @return * Name of the object is returned in case of success. */ - static string ObjectName(long _chart_id, int _pos, int _sub_window = -1, int _type = -1) { + static string ObjectName(int64 _chart_id, int _pos, int _sub_window = -1, int _type = -1) { return ::ObjectName(_chart_id, _pos, _sub_window, _type); } static string ObjectName(int _index) { return Plot::ObjectName(0, _index); } @@ -104,7 +104,7 @@ class Plot : public Object { * @return * The number of objects. */ - static int ObjectsTotal(long chart_id, int type = EMPTY, int window = -1) { + static int ObjectsTotal(int64 chart_id, int type = EMPTY, int window = -1) { #ifdef __MQL4__ return ::ObjectsTotal(chart_id, window, type); #else @@ -159,7 +159,7 @@ class Plot : public Object { * - https://docs.mql4.com/objects/objectset * - https://docs.mql4.com/constants/objectconstants/enum_object_property */ - static bool ObjectSet(string name, int prop_id, double prop_value, long chart_id = 0) { + static bool ObjectSet(string name, int prop_id, double prop_value, int64 chart_id = 0) { #ifdef __MQL4__ return ::ObjectSet(name, prop_id, prop_value); #else // __MQL5__ @@ -170,10 +170,10 @@ class Plot : public Object { return ObjectSetDouble(chart_id, name, (ENUM_OBJECT_PROPERTY_DOUBLE)prop_id, (double)prop_value); case OBJPROP_RAY: // Boolean value to set/get ray flag of object. - return ObjectSetInteger(chart_id, name, OBJPROP_RAY_RIGHT, (long)prop_value); + return ObjectSetInteger(chart_id, name, OBJPROP_RAY_RIGHT, (int64)prop_value); case OBJPROP_FIBOLEVELS: // Integer value to set/get Fibonacci object level count. Can be from 0 to 32. - return ObjectSetInteger(chart_id, name, OBJPROP_LEVELS, (long)prop_value); + return ObjectSetInteger(chart_id, name, OBJPROP_LEVELS, (int64)prop_value); case OBJPROP_ARROWCODE: // Arrow code for the Arrow object (char). case OBJPROP_BACK: // Boolean value to set/get background drawing flag for object. case OBJPROP_COLOR: // Color value to set/get object color. @@ -188,7 +188,7 @@ class Plot : public Object { case OBJPROP_WIDTH: // Integer value to set/get object line width. Can be from 1 to 5. case OBJPROP_XDISTANCE: // The distance in pixels along the X axis from the binding corner (int). case OBJPROP_YDISTANCE: // The distance in pixels along the Y axis from the binding corner (int). - return ObjectSetInteger(chart_id, name, (ENUM_OBJECT_PROPERTY_INTEGER)prop_id, (long)prop_value); + return ObjectSetInteger(chart_id, name, (ENUM_OBJECT_PROPERTY_INTEGER)prop_id, (int64)prop_value); default: break; } @@ -197,13 +197,13 @@ class Plot : public Object { switch (prop_id) { // Datetime value to set/get first coordinate time part. case OBJPROP_TIME1: - return ObjectSetInteger(chart_id, name, OBJPROP_TIME, (long)prop_value); + return ObjectSetInteger(chart_id, name, OBJPROP_TIME, (int64)prop_value); // Datetime value to set/get second coordinate time part. case OBJPROP_TIME2: - return ObjectSetInteger(chart_id, name, OBJPROP_TIME, 1, (long)prop_value); + return ObjectSetInteger(chart_id, name, OBJPROP_TIME, 1, (int64)prop_value); // Datetime value to set/get third coordinate time part. case OBJPROP_TIME3: - return ObjectSetInteger(chart_id, name, OBJPROP_TIME, 2, (long)prop_value); + return ObjectSetInteger(chart_id, name, OBJPROP_TIME, 2, (int64)prop_value); // Double value to set/get first coordinate price part. case OBJPROP_PRICE1: return ObjectSetDouble(chart_id, name, OBJPROP_PRICE, (double)prop_value); @@ -224,7 +224,7 @@ class Plot : public Object { /** * Creates an object with the specified name, type, and the initial coordinates. */ - static bool ObjectCreate(long _cid, string _name, ENUM_OBJECT _otype, int _swindow, datetime _t1, double _p1) { + static bool ObjectCreate(int64 _cid, string _name, ENUM_OBJECT _otype, int _swindow, datetime _t1, double _p1) { #ifdef __MQL4__ // https://docs.mql4.com/objects/objectcreate return ::ObjectCreate(_name, _otype, _swindow, _t1, _p1); @@ -233,7 +233,7 @@ class Plot : public Object { return ::ObjectCreate(_cid, _name, _otype, _swindow, _t1, _p1); #endif } - static bool ObjectCreate(long _cid, string _name, ENUM_OBJECT _otype, int _swindow, datetime _t1, double _p1, + static bool ObjectCreate(int64 _cid, string _name, ENUM_OBJECT _otype, int _swindow, datetime _t1, double _p1, datetime _t2, double _p2) { #ifdef __MQL4__ // https://docs.mql4.com/objects/objectcreate @@ -258,7 +258,7 @@ class Plot : public Object { /** * Deletes object via name. */ - static bool ObjectDelete(long chart_id, string name) { + static bool ObjectDelete(int64 chart_id, string name) { #ifdef __MQL4__ // https://docs.mql4.com/objects/objectdelete return ::ObjectDelete(name); diff --git a/Platform/Terminal.h b/Platform/Terminal.h index f720c9e00..09f308823 100644 --- a/Platform/Terminal.h +++ b/Platform/Terminal.h @@ -874,8 +874,8 @@ class Terminal : public Object { * Returns true when the condition is met. */ bool CheckCondition(ENUM_TERMINAL_CONDITION _cond, ARRAY_REF(DataParamEntry, _args)) { - // long _arg1l = ArraySize(_args) > 0 ? DataParamEntry::ToInteger(_args[0]) : WRONG_VALUE; - // long _arg2l = ArraySize(_args) > 1 ? DataParamEntry::ToInteger(_args[1]) : WRONG_VALUE; + // int64 _arg1l = ArraySize(_args) > 0 ? DataParamEntry::ToInteger(_args[0]) : WRONG_VALUE; + // int64 _arg2l = ArraySize(_args) > 1 ? DataParamEntry::ToInteger(_args[1]) : WRONG_VALUE; switch (_cond) { case TERMINAL_COND_IS_CONNECTED: return !IsConnected(); @@ -884,7 +884,7 @@ class Terminal : public Object { return false; } } - bool CheckCondition(ENUM_TERMINAL_CONDITION _cond, long _arg1) { + bool CheckCondition(ENUM_TERMINAL_CONDITION _cond, int64 _arg1) { ARRAY(DataParamEntry, _args); DataParamEntry _param1 = _arg1; ArrayPushObject(_args, _param1); @@ -908,9 +908,9 @@ class Terminal : public Object { * Returns true when the condition is met. */ bool ExecuteAction(ENUM_TERMINAL_ACTION _action, ARRAY_REF(MqlParam, _args)) { - // long _arg1l = ArraySize(_args) > 0 ? DataParamEntry::ToInteger(_args[0]) : WRONG_VALUE; - // long _arg2l = ArraySize(_args) > 1 ? DataParamEntry::ToInteger(_args[1]) : WRONG_VALUE; - // long _arg3l = ArraySize(_args) > 2 ? DataParamEntry::ToInteger(_args[2]) : WRONG_VALUE; + // int64 _arg1l = ArraySize(_args) > 0 ? DataParamEntry::ToInteger(_args[0]) : WRONG_VALUE; + // int64 _arg2l = ArraySize(_args) > 1 ? DataParamEntry::ToInteger(_args[1]) : WRONG_VALUE; + // int64 _arg3l = ArraySize(_args) > 2 ? DataParamEntry::ToInteger(_args[2]) : WRONG_VALUE; switch (_action) { case TERMINAL_ACTION_CRASH: delete THIS_PTR; diff --git a/Platform/tests/Order.test.mq5 b/Platform/tests/Order.test.mq5 index 99f10111b..c80c3c14e 100644 --- a/Platform/tests/Order.test.mq5 +++ b/Platform/tests/Order.test.mq5 @@ -25,12 +25,12 @@ */ // Includes. -#include "../Chart/Chart.h" -#include "../Order.h" -#include "../Platform.h" #include "../../Serializer/SerializerConverter.h" #include "../../Serializer/SerializerJson.h" #include "../../Test.mqh" +#include "../Chart/Chart.h" +#include "../Order.h" +#include "../Platform.h" // Global defines. #define MAX_ORDERS 10 @@ -86,7 +86,7 @@ void OnTick() { break; } assertFalseOrExit(_order.IsOpen(true), StringFormat("Order %d not closed!", _order.OrderTicket())); - assertTrueOrExit(_order.Get(ORDER_PROP_TIME_CLOSED) > 0, + assertTrueOrExit(_order.Get(ORDER_PROP_TIME_CLOSED) > 0, StringFormat("Order %d close time not correct!", _order.OrderTicket())); } bar_processed++; diff --git a/Platform/tests/OrderQuery.test.mq5 b/Platform/tests/OrderQuery.test.mq5 index 0e7e02065..df761c664 100644 --- a/Platform/tests/OrderQuery.test.mq5 +++ b/Platform/tests/OrderQuery.test.mq5 @@ -25,13 +25,13 @@ */ // Includes. -#include "../OrderQuery.h" #include "../../Test.mqh" +#include "../OrderQuery.h" bool Test01() { bool _result = true; // Initialize orders. - DictStruct> orders; + DictStruct> orders; // Populate orders. for (int i = -10; i <= 10; i++) { OrderData _odata; diff --git a/Profiler.mqh b/Profiler.mqh index fed207d91..685bba105 100644 --- a/Profiler.mqh +++ b/Profiler.mqh @@ -48,7 +48,7 @@ class Profiler { public: // Variables. static Collection *timers; - static unsigned long min_time; + static uint64 min_time; /* Class methods */ @@ -62,4 +62,4 @@ class Profiler { // Initialize static global variables. Collection *Profiler::timers = new Collection(MQLInfoString(MQL_PROGRAM_NAME)); -unsigned long Profiler::min_time = 1; +uint64 Profiler::min_time = 1; diff --git a/Serializer/SerializerBinary.h b/Serializer/SerializerBinary.h index e5e94e9e5..7edc3ae48 100644 --- a/Serializer/SerializerBinary.h +++ b/Serializer/SerializerBinary.h @@ -38,7 +38,7 @@ enum ENUM_SERIALIZER_BINARY_FLAGS { SERIALIZER_BINARY_INCLUDE_VERSION }; union SerializerBinaryValue { unsigned char Bytes[8]; double Double; - long Long; + int64 Long; int Integer; short Short; }; diff --git a/Serializer/SerializerConversions.h b/Serializer/SerializerConversions.h index 20f1269a1..61f65548c 100644 --- a/Serializer/SerializerConversions.h +++ b/Serializer/SerializerConversions.h @@ -31,9 +31,9 @@ #endif #include "../Convert.extern.h" +#include "../Refs.struct.h" #include "../Storage/DateTime.extern.h" #include "../Storage/Object.h" -#include "../Refs.struct.h" class SerializerConversions { public: @@ -53,7 +53,7 @@ class SerializerConversions { return string(includeQuotes ? "\"" : "") + IntegerToString(value) + (includeQuotes ? "\"" : ""); } - static string ValueToString(long value, bool includeQuotes = false, bool escape = true, int _fp_precision = 8) { + static string ValueToString(int64 value, bool includeQuotes = false, bool escape = true, int _fp_precision = 8) { return string(includeQuotes ? "\"" : "") + IntegerToString(value) + (includeQuotes ? "\"" : ""); } diff --git a/Serializer/SerializerNodeParam.h b/Serializer/SerializerNodeParam.h index c5718a179..14a7268fd 100644 --- a/Serializer/SerializerNodeParam.h +++ b/Serializer/SerializerNodeParam.h @@ -49,7 +49,7 @@ class SerializerNodeParam { */ union USerializerNodeValue { bool _bool; - long _long; + int64 _long; double _double; } _integral; @@ -72,12 +72,12 @@ class SerializerNodeParam { /** * Returns new SerializerNodeParam object from given source value. */ - static SerializerNodeParam* FromBool(long value); + static SerializerNodeParam* FromBool(int64 value); /** * Returns new SerializerNodeParam object from given source value. */ - static SerializerNodeParam* FromLong(long value); + static SerializerNodeParam* FromLong(int64 value); /** * Returns new SerializerNodeParam object from given source value. @@ -122,7 +122,7 @@ class SerializerNodeParam { /** * Returns new SerializerNodeParam object from given source value. */ - static SerializerNodeParam* FromValue(long value) { return FromLong(value); } + static SerializerNodeParam* FromValue(int64 value) { return FromLong(value); } /** * Returns new SerializerNodeParam object from given source value. @@ -147,7 +147,7 @@ class SerializerNodeParam { /** * Returns new SerializerNodeParam object from given source value. */ - static SerializerNodeParam* FromValue(unsigned long value) { return FromLong(value); } + static SerializerNodeParam* FromValue(uint64 value) { return FromLong(value); } /** * Returns new SerializerNodeParam object from given source value. @@ -182,7 +182,7 @@ class SerializerNodeParam { */ SerializerNodeParamType GetType() { return _type; } - long ToBool() { + int64 ToBool() { switch (_type) { case SerializerNodeParamBool: return _integral._bool; @@ -216,18 +216,18 @@ class SerializerNodeParam { return 0; } - long ToLong() { + int64 ToLong() { switch (_type) { case SerializerNodeParamBool: return _integral._bool ? 1 : 0; case SerializerNodeParamLong: return _integral._long; case SerializerNodeParamDouble: - return (long)_integral._double; + return (int64)_integral._double; case SerializerNodeParamString: return StringToInteger(_string); default: - Alert("Internal Error. Cannot convert source type to long"); + Alert("Internal Error. Cannot convert source type to int64"); } return 0; @@ -286,7 +286,7 @@ class SerializerNodeParam { int ConvertTo(int) { return ToInt(); } - long ConvertTo(long) { return ToInt(); } + int64 ConvertTo(int64) { return ToInt(); } float ConvertTo(float) { return ToFloat(); } @@ -298,7 +298,7 @@ class SerializerNodeParam { /** * Returns new SerializerNodeParam object from given source value. */ -SerializerNodeParam* SerializerNodeParam::FromBool(long value) { +SerializerNodeParam* SerializerNodeParam::FromBool(int64 value) { SerializerNodeParam* param = new SerializerNodeParam(); PTR_ATTRIB(param, _type) = SerializerNodeParamBool; PTR_ATTRIB(param, _integral)._bool = value; @@ -308,7 +308,7 @@ SerializerNodeParam* SerializerNodeParam::FromBool(long value) { /** * Returns new SerializerNodeParam object from given source value. */ -SerializerNodeParam* SerializerNodeParam::FromLong(long value) { +SerializerNodeParam* SerializerNodeParam::FromLong(int64 value) { SerializerNodeParam* param = new SerializerNodeParam(); PTR_ATTRIB(param, _type) = SerializerNodeParamLong; PTR_ATTRIB(param, _integral)._long = value; diff --git a/Stats.mqh b/Stats.mqh index 0580ae986..14c455844 100644 --- a/Stats.mqh +++ b/Stats.mqh @@ -34,8 +34,8 @@ */ class Stats { public: - unsigned long total_bars; - unsigned long total_ticks; + uint64 total_bars; + uint64 total_ticks; int curr_period; // int custom_int[]; // double custom_dbl[]; @@ -60,7 +60,7 @@ class Stats { * Update stats on tick. */ void OnTick() { - static long _last_bar_time = 0; + static int64 _last_bar_time = 0; total_ticks++; if (_last_bar_time != Platform::Timestamp()) { _last_bar_time = Platform::Timestamp(); @@ -78,22 +78,22 @@ class Stats { /** * Get number of counted bars. */ - unsigned long GetTotalBars() { return (total_bars); } + uint64 GetTotalBars() { return (total_bars); } /** * Get number of counted ticks. */ - unsigned long GetTotalTicks() { return (total_ticks); } + uint64 GetTotalTicks() { return (total_ticks); } /** * Get number of ticks per bar. */ - unsigned long GetTicksPerBar() { return (total_bars > 0 ? (total_ticks / total_bars) : 0); } + uint64 GetTicksPerBar() { return (total_bars > 0 ? (total_ticks / total_bars) : 0); } /** * Get number of ticks per minute. */ - unsigned long GetTicksPerMin() { return (total_bars > 0 ? (total_ticks / total_bars / curr_period) : 0); } + uint64 GetTicksPerMin() { return (total_bars > 0 ? (total_ticks / total_bars / curr_period) : 0); } /** * Get number of ticks per second. @@ -103,10 +103,10 @@ class Stats { /** * Get number of ticks per given time period. */ - unsigned long GetTicksPerPeriod(int period = PERIOD_H1) { return (GetTicksPerMin() * period); } + uint64 GetTicksPerPeriod(int period = PERIOD_H1) { return (GetTicksPerMin() * period); } /** * Get number of bars per given time period. */ - unsigned long GetBarsPerPeriod(int period = PERIOD_H1) { return (total_bars / period); } + uint64 GetBarsPerPeriod(int period = PERIOD_H1) { return (total_bars / period); } }; diff --git a/Std.h b/Std.h index f5d05f864..a27bef3b4 100644 --- a/Std.h +++ b/Std.h @@ -61,6 +61,7 @@ #define nullptr NULL #define REF_DEREF .Ptr(). #define int64 long +#define uint64 unsigned long #define VOID_DATA(N) void*& N[] #else #define THIS_ATTR this-> @@ -74,6 +75,7 @@ #define MAKE_REF_FROM_PTR(TYPE, NAME, PTR) TYPE& NAME = PTR #define REF_DEREF .Ptr()-> #define int64 long long +#define uint64 unsigned long long #define VOID_DATA(N) void* N #endif diff --git a/Storage/Array.h b/Storage/Array.h index 392ad263a..44fa76f47 100644 --- a/Storage/Array.h +++ b/Storage/Array.h @@ -555,12 +555,12 @@ static int GetLowestArrDoubleValue(double& arr[][], int key) { * - https://www.mql5.com/en/docs/array/arrayprint */ template - void ArrayPrint(ARRAY_REF(T, _arr), // Printed array. - int _digits = 0, // Number of decimal places. - const string _dlm = NULL, // Separator of the structure field values. - long _start = 0, // First printed element index. - long _count = WHOLE_ARRAY, // Number of printed elements. - long _flags = NULL) { + void ArrayPrint(ARRAY_REF(T, _arr), // Printed array. + int _digits = 0, // Number of decimal places. + const string _dlm = NULL, // Separator of the structure field values. + int64 _start = 0, // First printed element index. + int64 _count = WHOLE_ARRAY, // Number of printed elements. + int64 _flags = NULL) { #ifdef __MQL5__ ::ArrayPrint(_arr, _digits, _dlm, _start, _count, _flags); #else diff --git a/Storage/Collection.h b/Storage/Collection.h index f88820a34..89d76d1ee 100644 --- a/Storage/Collection.h +++ b/Storage/Collection.h @@ -141,7 +141,7 @@ class Collection { /** * Returns object item by object id. */ - X *GetById(long _id) { + X *GetById(int64 _id) { int i; X *_object = GetSize() > 0 ? data[0].Ptr() : NULL; for (i = 0; i < ArraySize(data); i++) { diff --git a/Storage/Data.enum.h b/Storage/Data.enum.h index a3f7c1f19..212a57b2d 100644 --- a/Storage/Data.enum.h +++ b/Storage/Data.enum.h @@ -45,12 +45,12 @@ enum ENUM_DATATYPE { TYPE_DOUBLE, // double TYPE_FLOAT, // float TYPE_INT, // int - TYPE_LONG, // long + TYPE_LONG, // int64 TYPE_SHORT, // short TYPE_STRING, // string TYPE_UCHAR, // unsigned char TYPE_UINT, // unsigned int - TYPE_ULONG, // unsigned long + TYPE_ULONG, // uint64 TYPE_USHORT, // unsigned short }; #endif diff --git a/Storage/Data.struct.h b/Storage/Data.struct.h index 028f560be..dbc4a8563 100644 --- a/Storage/Data.struct.h +++ b/Storage/Data.struct.h @@ -54,7 +54,7 @@ struct MqlRates; struct MqlParam { ENUM_DATATYPE type; // Type of the input parameter, value of ENUM_DATATYPE. union { - long integer_value; // Field to store an integer type. + int64 integer_value; // Field to store an integer type. double double_value; // Field to store a double type. string string_value; // Field to store a string type. }; @@ -88,7 +88,7 @@ struct MqlParam { return THIS_REF; } - MqlParam(long _value) { + MqlParam(int64 _value) { type = ENUM_DATATYPE::TYPE_LONG; integer_value = _value; } @@ -122,7 +122,7 @@ struct MqlParam { struct DataParamEntry : public MqlParam { public: DataParamEntry() { type = InvalidEnumValue::value(); } - DataParamEntry(ENUM_DATATYPE _type, long _integer_value, double _double_value, string _string_value) { + DataParamEntry(ENUM_DATATYPE _type, int64 _integer_value, double _double_value, string _string_value) { type = _type; integer_value = _integer_value; double_value = _double_value; @@ -154,13 +154,13 @@ struct DataParamEntry : public MqlParam { type = TYPE_UINT; integer_value = _value; } - DataParamEntry(long _value) { + DataParamEntry(int64 _value) { type = TYPE_LONG; integer_value = _value; } - DataParamEntry(unsigned long _value) { + DataParamEntry(uint64 _value) { type = TYPE_ULONG; - integer_value = (long)_value; + integer_value = (int64)_value; } // Struct operators. @@ -188,13 +188,13 @@ struct DataParamEntry : public MqlParam { type = TYPE_UINT; integer_value = _value; } - void operator=(long _value) { + void operator=(int64 _value) { type = TYPE_LONG; integer_value = _value; } - void operator=(unsigned long _value) { + void operator=(uint64 _value) { type = TYPE_ULONG; - integer_value = (long)_value; + integer_value = (int64)_value; } bool operator==(const DataParamEntry &_s) { @@ -206,7 +206,7 @@ struct DataParamEntry : public MqlParam { /* DataParamEntry() {} - DataParamEntry(ENUM_DATATYPE _type, long _int, double _dbl, string _str) { + DataParamEntry(ENUM_DATATYPE _type, int64 _int, double _dbl, string _str) { type = _type; integer_value = _int; double_value = _dbl; @@ -277,10 +277,10 @@ struct DataParamEntry : public MqlParam { } /** - * Gets DataParamEntry struct based on the value of long type. + * Gets DataParamEntry struct based on the value of int64 type. * */ - static DataParamEntry FromValue(long _value) { + static DataParamEntry FromValue(int64 _value) { DataParamEntry _dpe; _dpe.type = TYPE_LONG; _dpe.integer_value = _value; @@ -332,7 +332,7 @@ struct DataParamEntry : public MqlParam { * Converts MqlParam struct to integer. * */ - static long ToInteger(MqlParam ¶m) { + static int64 ToInteger(MqlParam ¶m) { switch (param.type) { case TYPE_BOOL: return param.integer_value ? 1 : 0; diff --git a/Storage/Database.h b/Storage/Database.h index 65a96b745..4e200832f 100644 --- a/Storage/Database.h +++ b/Storage/Database.h @@ -216,7 +216,7 @@ class Database { _cols = StringSubstr(_cols, 0, StringLen(_cols) - 1); // Removes extra comma. #ifndef __MQL4__ if (DatabaseTransactionBegin(handle)) { - for (DictStructIterator iter = _bstruct.Begin(); iter.IsValid(); ++iter) { + for (DictStructIterator iter = _bstruct.Begin(); iter.IsValid(); ++iter) { _query = StringFormat("INSERT INTO %s(%s) VALUES (%s)", _name, _cols, iter.Value().ToCSV()); _result &= DatabaseExecute(handle, _query); } diff --git a/Storage/Dict/Buffer/Buffer.h b/Storage/Dict/Buffer/Buffer.h index 2f25b79f4..a372690ec 100644 --- a/Storage/Dict/Buffer/Buffer.h +++ b/Storage/Dict/Buffer/Buffer.h @@ -32,14 +32,14 @@ * Class to store data values. */ template -class Buffer : public Dict { +class Buffer : public Dict { public: Buffer() {} /** * Adds new value. */ - void Add(T _value, long _dt = 0) { + void Add(T _value, int64 _dt = 0) { _dt = _dt > 0 ? _dt : TimeCurrent(); Set(_dt, _value); } @@ -50,7 +50,7 @@ class Buffer : public Dict { T GetMin() { T min = NULL; - for (DictIterator iter = Begin(); iter.IsValid(); ++iter) + for (DictIterator iter = Begin(); iter.IsValid(); ++iter) if (min == NULL || min > iter.Value()) min = iter.Value(); return min; @@ -62,7 +62,7 @@ class Buffer : public Dict { T GetMax() { T max = NULL; - for (DictIterator iter = Begin(); iter.IsValid(); ++iter) + for (DictIterator iter = Begin(); iter.IsValid(); ++iter) if (max == NULL || max < iter.Value()) max = iter.Value(); return max; @@ -75,7 +75,7 @@ class Buffer : public Dict { T sum = 0; unsigned int numValues = 0; - for (DictIterator iter = Begin(); iter.IsValid(); ++iter) { + for (DictIterator iter = Begin(); iter.IsValid(); ++iter) { sum += iter.Value(); ++numValues; } @@ -91,7 +91,7 @@ class Buffer : public Dict { ArrayResize(array, Size()); - for (DictIterator iter = Begin(); iter.IsValid(); ++iter) { + for (DictIterator iter = Begin(); iter.IsValid(); ++iter) { array[iter.Index()] = iter.Value(); } diff --git a/Storage/Dict/Buffer/BufferFXT.h b/Storage/Dict/Buffer/BufferFXT.h index f4985aa31..ebb43b3bf 100644 --- a/Storage/Dict/Buffer/BufferFXT.h +++ b/Storage/Dict/Buffer/BufferFXT.h @@ -69,7 +69,7 @@ struct BufferFXTEntry { double high; double low; double close; - long volume; + int64 volume; int ctm; // The current time within a bar. int flag; // Flag to launch an expert (0 - bar will be modified, but the expert will not be launched). @@ -262,7 +262,7 @@ string ToJSON(BufferFXTEntry &_value, const bool, const unsigned int) { return _ /** * Implements class to store tick data. */ -class BufferFXT : public DictStruct { +class BufferFXT : public DictStruct { protected: BufferFXTParams params; @@ -281,7 +281,7 @@ class BufferFXT : public DictStruct { /** * Adds new entry. */ - void Add(BufferFXTEntry &_value, long _dt = 0) { + void Add(BufferFXTEntry &_value, int64 _dt = 0) { _dt = _dt > 0 ? _dt : TimeCurrent(); Set(_dt, _value); } diff --git a/Storage/Dict/Buffer/BufferStruct.h b/Storage/Dict/Buffer/BufferStruct.h index 5db539b6f..e38de8b08 100644 --- a/Storage/Dict/Buffer/BufferStruct.h +++ b/Storage/Dict/Buffer/BufferStruct.h @@ -54,9 +54,9 @@ bool BufferStructOverflowListener(ENUM_DICT_OVERFLOW_REASON _reason, int _size, * Class to store struct data. */ template -class BufferStruct : public DictStruct { +class BufferStruct : public DictStruct { protected: - long min, max; + int64 min, max; public: /* Constructors */ @@ -73,8 +73,8 @@ class BufferStruct : public DictStruct { /** * Adds new value. */ - void Add(TStruct& _value, long _dt = 0) { - _dt = _dt > 0 ? _dt : (long)TimeCurrent(); + void Add(TStruct& _value, int64 _dt = 0) { + _dt = _dt > 0 ? _dt : (int64)TimeCurrent(); if (THIS_ATTR Set(_dt, _value)) { min = _dt < min ? _dt : min; max = _dt > max ? _dt : max; @@ -84,12 +84,12 @@ class BufferStruct : public DictStruct { /** * Clear entries older than given timestamp. */ - void Clear(long _dt = 0, bool _older = true) { + void Clear(int64 _dt = 0, bool _older = true) { min = INT_MAX; max = INT_MIN; if (_dt > 0) { - for (DictStructIterator iter(THIS_ATTR Begin()); iter.IsValid(); ++iter) { - long _time = iter.Key(); + for (DictStructIterator iter(THIS_ATTR Begin()); iter.IsValid(); ++iter) { + int64 _time = iter.Key(); if (_older && _time < _dt) { Unset(iter.Key()); continue; @@ -101,7 +101,7 @@ class BufferStruct : public DictStruct { max = _time > max ? _time : max; } } else { - DictStruct::Clear(); + DictStruct::Clear(); } } @@ -110,10 +110,10 @@ class BufferStruct : public DictStruct { /** * Gets the newest timestamp. */ - long GetMax() { return max; } + int64 GetMax() { return max; } /** * Gets the oldest timestamp. */ - long GetMin() { return min; } + int64 GetMin() { return min; } }; diff --git a/Storage/Dict/DictBase.h b/Storage/Dict/DictBase.h index 34e4b011b..082fbe377 100644 --- a/Storage/Dict/DictBase.h +++ b/Storage/Dict/DictBase.h @@ -389,5 +389,5 @@ class DictBase { /** * Specialization of hashing function. */ - unsigned int Hash(float x) { return (unsigned int)((unsigned long)x * 10000 % 10000); } + unsigned int Hash(float x) { return (unsigned int)((uint64)x * 10000 % 10000); } }; diff --git a/Storage/Dict/DictStruct.h b/Storage/Dict/DictStruct.h index fd1ca79c6..08981389b 100644 --- a/Storage/Dict/DictStruct.h +++ b/Storage/Dict/DictStruct.h @@ -71,7 +71,7 @@ class DictStruct : public DictBase { Clear(); Resize(right.GetSlotCount()); for (unsigned int i = 0; i < (unsigned int)ArraySize(right._DictSlots_ref.DictSlots); ++i) { - this PTR_DEREF _DictSlots_ref PTR_DEREF DictSlots[i] = right._DictSlots_ref.DictSlots[i]; + THIS_ATTR _DictSlots_ref.DictSlots[i] = right._DictSlots_ref.DictSlots[i]; } THIS_ATTR _DictSlots_ref._num_used = right._DictSlots_ref._num_used; THIS_ATTR _current_id = right._current_id; diff --git a/Storage/ItemsHistory.h b/Storage/ItemsHistory.h index c5454b894..74458b095 100644 --- a/Storage/ItemsHistory.h +++ b/Storage/ItemsHistory.h @@ -58,7 +58,7 @@ class ItemsHistoryItemProvider : public Dynamic { * Retrieves given number of items starting from the given microseconds or index (inclusive). "_dir" identifies if we * want previous or next items from selected starting point. */ - void GetItems(ItemsHistory>* _history, long _from_time_ms, + void GetItems(ItemsHistory>* _history, int64 _from_time_ms, ENUM_ITEMS_HISTORY_DIRECTION _dir, int _num_items, ARRAY_REF(IV, _out_arr)) { // Method is called if there is a missing item (candle) in the history. We need to regenerate it. Print("Error: Retrieving items by this item provider is not implemented!"); @@ -68,10 +68,10 @@ class ItemsHistoryItemProvider : public Dynamic { /** * Time of the first possible item/candle/tick. */ - virtual long GetInitialTimeMs() { + virtual int64 GetInitialTimeMs() { // Item's provider does not implement GetInitialTimeMs(), but it should. We'll use current time for the time of the // first item. - return (long)TimeCurrent() * 1000; + return (int64)TimeCurrent() * 1000; } /** @@ -150,7 +150,7 @@ class ItemsHistory { * Gets time in milliseconds of the last(oldest) item's time in current history time or 0. */ /* - long GetLastValidTimeInCache() { + int64 GetLastValidTimeInCache() { return history.GetByKey(last_valid_index).GetTime(); } */ @@ -173,7 +173,7 @@ class ItemsHistory { ArrayResize(_items, 0); int _item_count = _to_index - _from_index + 1; - long _from_time_ms; + int64 _from_time_ms; IV _item; // Calculating time to be passed to GetItems(). @@ -196,9 +196,9 @@ class ItemsHistory { _from_time_ms = _item.GetTimeMs() + _item.GetLengthMs() + 1; } - // long _current_time_ms = TimeCurrent() * 1000; + // int64 _current_time_ms = TimeCurrent() * 1000; - if (_from_time_ms > (long)TimeCurrent() * 1000) { + if (_from_time_ms > (int64)TimeCurrent() * 1000) { // There won't be items in the future. return; } @@ -441,7 +441,7 @@ class ItemsHistory { /** * Returns item time in milliseconds for the given shift. */ - long GetItemTimeByShiftMsc(int _shift) { + int64 GetItemTimeByShiftMsc(int _shift) { if (!EnsureShiftExists(_shift)) { // There won't be item at given shift. return (datetime)0; diff --git a/Storage/Object.h b/Storage/Object.h index cf9feaf40..8d5f9a3bf 100644 --- a/Storage/Object.h +++ b/Storage/Object.h @@ -38,14 +38,14 @@ class Object : public Dynamic { protected: void *obj; - long id; + int64 id; public: /** * Class constructor. */ Object() : obj(THIS_PTR), id(rand()) {} - Object(void *_obj, long _id = __LINE__) { + Object(void *_obj, int64 _id = __LINE__) { obj = _obj; id = _id; } @@ -55,14 +55,14 @@ class Object : public Dynamic { /** * Get ID of the object. */ - virtual long GetId() { return id; } + virtual int64 GetId() { return id; } /* Setters */ /** * Set ID of the object. */ - void SetId(long _id) { id = _id; } + void SetId(int64 _id) { id = _id; } /** * Get the object handler. diff --git a/Storage/String.extern.h b/Storage/String.extern.h index 924c2d79c..b8de543b2 100644 --- a/Storage/String.extern.h +++ b/Storage/String.extern.h @@ -65,7 +65,7 @@ int StringSplit(const string& string_value, const unsigned short separator, ARRA } return result.size(); } -long StringToInteger(string value) { return std::stol(value); } +int64 StringToInteger(string value) { return std::stol(value); } string IntegerToString(int64 number, int str_len = 0, unsigned short fill_symbol = ' ') { return std::to_string(number); } diff --git a/Storage/ValueStorage.h b/Storage/ValueStorage.h index 07cbbc449..7c7707741 100644 --- a/Storage/ValueStorage.h +++ b/Storage/ValueStorage.h @@ -47,15 +47,15 @@ enum ENUM_IPEAK { IPEAK_LOWEST, IPEAK_HIGHEST }; #define INDICATOR_CALCULATE_PARAMS_LONG \ ValueStorage &_time, ValueStorage &_open, ValueStorage &_high, ValueStorage &_low, \ - ValueStorage &_close, ValueStorage &_tick_volume, ValueStorage &_volume, \ - ValueStorage &_spread + ValueStorage &_close, ValueStorage &_tick_volume, ValueStorage &_volume, \ + ValueStorage &_spread #define INDICATOR_CALCULATE_PARAMS_SHORT ValueStorage &_price #define INDICATOR_CALCULATE_METHOD_PARAMS_LONG \ const int rates_total, const int prev_calculated, ValueStorage &time, ValueStorage &open, \ ValueStorage &high, ValueStorage &low, ValueStorage &close, \ - ValueStorage &tick_volume, ValueStorage &volume, ValueStorage &spread + ValueStorage &tick_volume, ValueStorage &volume, ValueStorage &spread #define INDICATOR_CALCULATE_METHOD_PARAMS_SHORT \ const int rates_total, const int prev_calculated, const int begin, ValueStorage &price @@ -103,14 +103,14 @@ enum ENUM_IPEAK { IPEAK_LOWEST, IPEAK_HIGHEST }; REF_TO(ValueStorage) \ _time = REF_CAST(ValueStorage) \ PTR_TO_REF(_suitable_ds PTR_DEREF GetSpecificValueStorage(INDI_DATA_VS_TYPE_TIME)); \ - REF_TO(ValueStorage) \ - _tick_volume = REF_CAST(ValueStorage) \ + REF_TO(ValueStorage) \ + _tick_volume = REF_CAST(ValueStorage) \ PTR_TO_REF(_suitable_ds PTR_DEREF GetSpecificValueStorage(INDI_DATA_VS_TYPE_TICK_VOLUME)); \ - REF_TO(ValueStorage) \ - _volume = REF_CAST(ValueStorage) \ + REF_TO(ValueStorage) \ + _volume = REF_CAST(ValueStorage) \ PTR_TO_REF(_suitable_ds PTR_DEREF GetSpecificValueStorage(INDI_DATA_VS_TYPE_VOLUME)); \ - REF_TO(ValueStorage) \ - _spread = REF_CAST(ValueStorage) \ + REF_TO(ValueStorage) \ + _spread = REF_CAST(ValueStorage) \ PTR_TO_REF(_suitable_ds PTR_DEREF GetSpecificValueStorage(INDI_DATA_VS_TYPE_SPREAD)); \ REF_TO(ValueStorage) \ _price_open = REF_CAST(ValueStorage) \ diff --git a/Storage/ValueStorage.spread.h b/Storage/ValueStorage.spread.h index 4b18fe614..3dfccfb8e 100644 --- a/Storage/ValueStorage.spread.h +++ b/Storage/ValueStorage.spread.h @@ -36,20 +36,20 @@ /** * Storage to retrieve spread. */ -class SpreadValueStorage : public HistoryValueStorage { +class SpreadValueStorage : public HistoryValueStorage { public: /** * Constructor. */ - SpreadValueStorage(IndicatorBase *_indi_candle) : HistoryValueStorage(_indi_candle) {} + SpreadValueStorage(IndicatorBase *_indi_candle) : HistoryValueStorage(_indi_candle) {} /** * Copy constructor. */ - SpreadValueStorage(SpreadValueStorage &_r) : HistoryValueStorage(_r.indi_candle.Ptr()) {} + SpreadValueStorage(SpreadValueStorage &_r) : HistoryValueStorage(_r.indi_candle.Ptr()) {} /** * Fetches value from a given shift. Takes into consideration as-series flag. */ - long Fetch(int _rel_shift) override { return indi_candle REF_DEREF GetSpread(RealShift(_rel_shift)); } + int64 Fetch(int _rel_shift) override { return indi_candle REF_DEREF GetSpread(RealShift(_rel_shift)); } }; diff --git a/Storage/ValueStorage.tick_volume.h b/Storage/ValueStorage.tick_volume.h index 61e9845e4..649c0fcf3 100644 --- a/Storage/ValueStorage.tick_volume.h +++ b/Storage/ValueStorage.tick_volume.h @@ -36,20 +36,20 @@ /** * Storage to retrieve tick volume. */ -class TickVolumeValueStorage : public HistoryValueStorage { +class TickVolumeValueStorage : public HistoryValueStorage { public: /** * Constructor. */ - TickVolumeValueStorage(IndicatorBase *_indi_candle) : HistoryValueStorage(_indi_candle) {} + TickVolumeValueStorage(IndicatorBase *_indi_candle) : HistoryValueStorage(_indi_candle) {} /** * Copy constructor. */ - TickVolumeValueStorage(TickVolumeValueStorage &_r) : HistoryValueStorage(_r.indi_candle.Ptr()) {} + TickVolumeValueStorage(TickVolumeValueStorage &_r) : HistoryValueStorage(_r.indi_candle.Ptr()) {} /** * Fetches value from a given shift. Takes into consideration as-series flag. */ - long Fetch(int _rel_shift) override { return indi_candle REF_DEREF GetVolume(RealShift(_rel_shift)); } + int64 Fetch(int _rel_shift) override { return indi_candle REF_DEREF GetVolume(RealShift(_rel_shift)); } }; diff --git a/Storage/ValueStorage.volume.h b/Storage/ValueStorage.volume.h index dc3d07690..f76b08424 100644 --- a/Storage/ValueStorage.volume.h +++ b/Storage/ValueStorage.volume.h @@ -36,24 +36,24 @@ /** * Storage to retrieve volume. */ -class VolumeValueStorage : public HistoryValueStorage { +class VolumeValueStorage : public HistoryValueStorage { public: /** * Constructor. */ - VolumeValueStorage(IndicatorBase *_indi_candle) : HistoryValueStorage(_indi_candle) {} + VolumeValueStorage(IndicatorBase *_indi_candle) : HistoryValueStorage(_indi_candle) {} /** * Copy constructor. */ - VolumeValueStorage(VolumeValueStorage &_r) : HistoryValueStorage(_r.indi_candle.Ptr()) {} + VolumeValueStorage(VolumeValueStorage &_r) : HistoryValueStorage(_r.indi_candle.Ptr()) {} /** * Fetches value from a given shift. Takes into consideration as-series flag. */ - long Fetch(int _rel_shift) override { + int64 Fetch(int _rel_shift) override { ResetLastError(); - long _volume = indi_candle REF_DEREF GetVolume(RealShift(_rel_shift)); + int64 _volume = indi_candle REF_DEREF GetVolume(RealShift(_rel_shift)); if (_LastError != ERR_NO_ERROR) { Print("Cannot fetch iVolume! Error: ", _LastError); DebugBreak(); diff --git a/Strategy.mqh b/Strategy.mqh index 6cd991674..b322ff805 100644 --- a/Strategy.mqh +++ b/Strategy.mqh @@ -28,14 +28,14 @@ class Trade; // Includes. -#include "Storage/Data.struct.h" -#include "Storage/Dict/Dict.h" #include "Indicator/Indicator.h" #include "Market.mqh" +#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 "Storage/String.h" #include "Task/TaskManager.h" #include "Task/Taskable.h" #include "Trade.mqh" @@ -113,9 +113,9 @@ class Strategy : public Taskable { // Base variables. string name; // Other variables. - int filter_method[]; // Filter method to consider the trade REF_DEREF - int open_condition[]; // Open conditions. - int close_condition[]; // Close conditions. + ARRAY(int, filter_method); // Filter method to consider the trade REF_DEREF + ARRAY(int, open_condition); // Open conditions. + ARRAY(int, close_condition); // Close conditions. public: /* Special methods */ @@ -123,11 +123,12 @@ class Strategy : public Taskable { /** * Class constructor. */ - Strategy(StgParams &_sparams, TradeParams &_tparams, IndicatorBase *_indi_source, string _name = "") + Strategy(StgParams &_sparams, TradeParams &_tparams, IndicatorData *_indi_source, string _name = "") : sparams(_sparams), trade(new Trade(_tparams, _indi_source)), indi_source(_indi_source) { // Initialize variables. name = _name; - MqlTick _tick = {0}; + MqlTick _tick; + _tick.time = (datetime)0; last_tick = _tick; // Link log instances. @@ -208,7 +209,7 @@ class Strategy : public Taskable { /** * Returns handler to the strategy's indicator class. */ - IndicatorBase *GetIndicator(int _id = 0) { + IndicatorData *GetIndicator(int _id = 0) { if (indicators.KeyExists(_id)) { return indicators[_id].Ptr(); } @@ -260,8 +261,8 @@ class Strategy : public Taskable { */ StgEntry GetEntry() { StgEntry _entry; - for (ENUM_STRATEGY_STATS_PERIOD _p = EA_STATS_DAILY; _p < FINAL_ENUM_STRATEGY_STATS_PERIOD; _p++) { - _entry.SetStats(stats_period[(int)_p], _p); + for (int _p = EA_STATS_DAILY; _p < FINAL_ENUM_STRATEGY_STATS_PERIOD; _p++) { + _entry.SetStats(stats_period[_p], (ENUM_STRATEGY_STATS_PERIOD)_p); } return _entry; } @@ -285,7 +286,7 @@ class Strategy : public Taskable { * Executes OnTick() on every attached indicator. */ void Tick(int _global_tick_index) { - for (DictIterator> it = indicators.Begin(); it.IsValid(); ++it) { + for (DictStructIterator> it = indicators.Begin(); it.IsValid(); ++it) { it.Value() REF_DEREF Tick(_global_tick_index); } } @@ -298,7 +299,7 @@ class Strategy : public Taskable { /** * Get strategy's ID. */ - virtual long GetId() { return sparams.id; } + virtual int64 GetId() { return sparams.id; } /** * Get strategy's signal open method. @@ -454,9 +455,9 @@ class Strategy : public Taskable { /** * Sets strategy's ID. */ - void SetId(long _id) { + void SetId(int64 _id) { sparams.id = _id; - ((Object *)GetPointer(this)).SetId(_id); + ((Object *)THIS_PTR) PTR_DEREF SetId(_id); } /** @@ -480,9 +481,9 @@ class Strategy : public Taskable { /** * Sets custom data. */ - void SetData(Dict *_ddata) { ddata = _ddata; } - void SetData(Dict *_fdata) { fdata = _fdata; } - void SetData(Dict *_idata) { idata = _idata; } + void SetData(Dict *_ddata) { ddata = PTR_TO_REF(_ddata); } + void SetData(Dict *_fdata) { fdata = PTR_TO_REF(_fdata); } + void SetData(Dict *_idata) { idata = PTR_TO_REF(_idata); } /** * Sets reference to indicator. @@ -687,8 +688,8 @@ class Strategy : public Taskable { ENUM_TIMEFRAMES _stf = GetSource() PTR_DEREF GetTf(); unsigned int _stf_secs = ChartTf::TfToSeconds(_stf); if (sparams.order_close_time != 0) { - long _close_time_arg = sparams.order_close_time > 0 ? sparams.order_close_time * 60 - : (int)round(-sparams.order_close_time * _stf_secs); + int64 _close_time_arg = sparams.order_close_time > 0 ? sparams.order_close_time * 60 + : MathRound(-sparams.order_close_time * _stf_secs); _oparams.Set(ORDER_PARAM_COND_CLOSE, ORDER_COND_LIFETIME_GT_ARG, _index); _oparams.Set(ORDER_PARAM_COND_CLOSE_ARG_VALUE, _close_time_arg, _index); _index++; @@ -734,7 +735,7 @@ class Strategy : public Taskable { if ((_periods & DATETIME_DAY) != 0) { // New day started. #ifndef __optimize__ - GetLogger().Flush(); + GetLogger() PTR_DEREF Flush(); #endif } if ((_periods & DATETIME_WEEK) != 0) { @@ -767,7 +768,7 @@ class Strategy : public Taskable { bool _res = _method >= 0; bool _val; - int _method_abs = fabs(_method); + int _method_abs = MathAbs(_method); if (_method_abs != 0) { if (METHOD(_method_abs, 0)) { // 1 // Process on every minute. @@ -1026,7 +1027,7 @@ class Strategy : public Taskable { return (float)_result; } float _trade_dist = trade REF_DEREF GetTradeDistanceInValue(); - int _count = (int)fmax(fabs(_level), fabs(_method)); + int _count = (int)fmax(MathAbs(_level), MathAbs(_method)); int _direction = Order::OrderDirection(_cmd, _mode); IndicatorData *_data_source = trade REF_DEREF GetSource(); IndicatorData *_indi = GetIndicators().Begin().Value().Ptr(); @@ -1034,7 +1035,7 @@ class Strategy : public Taskable { _psm.SetCandleSource(_data_source); if (Object::IsValid(_indi)) { int _ishift = 12; // @todo: Make it dynamic or as variable. - double _value = _indi.GetValuePrice(_ishift, 0, _direction > 0 ? PRICE_HIGH : PRICE_LOW); + double _value = _indi PTR_DEREF GetValuePrice(_ishift, 0, _direction > 0 ? PRICE_HIGH : PRICE_LOW); _value = _value + (float)Math::ChangeByPct(fabs(_value - SymbolInfoStatic::GetCloseOffer(_Symbol, _cmd)), _level) * _direction; @@ -1048,7 +1049,8 @@ class Strategy : public Taskable { */ _result = _psm.GetValue(_ishift, _direction, _trade_dist); } else { - int _pshift = _direction > 0 ? _data_source.GetHighest(_count) : _data_source.GetLowest(_count); + int _pshift = + _direction > 0 ? _data_source PTR_DEREF GetHighest(_count) : _data_source PTR_DEREF GetLowest(_count); _result = _psm.GetValue(_pshift, _direction, _trade_dist); } return (float)_result; @@ -1068,14 +1070,14 @@ class Strategy : public Taskable { float _result = 0; IndicatorData *_data_source = trade REF_DEREF GetSource(); - BarOHLC _bar1 = _data_source.GetOHLC(_shift); + BarOHLC _bar1 = _data_source PTR_DEREF GetOHLC(_shift); if (!_bar1.IsValid()) { return 0; } float _range = (float)_bar1.GetRange(); if (_range > 0) { - float _open = (float)_data_source.GetOpen(_tf); + float _open = (float)_data_source PTR_DEREF GetOpen(_tf); float _pp = (float)_bar1.GetPivot(); _result = 1 / _range * (_open - _pp); _result = fmin(1, fmax(-1, _result)); @@ -1127,7 +1129,7 @@ class Strategy : public Taskable { return SignalOpen(_entry.GetArg(0).ToValue(), _entry.GetArg(1).ToValue(), _entry.GetArg(2).ToValue()); default: - GetLogger().Error(StringFormat("Invalid EA condition: %d!", _entry.GetId(), __FUNCTION_LINE__)); + GetLogger() PTR_DEREF Error(StringFormat("Invalid EA condition: %d at %s!", _entry.GetId(), __FUNCTION_LINE__)); SetUserError(ERR_INVALID_PARAMETER); break; } @@ -1169,7 +1171,8 @@ class Strategy : public Taskable { sparams.Suspended(false); return true; default: - GetLogger().Error(StringFormat("Invalid Strategy action: %d!", _entry.GetId(), __FUNCTION_LINE__)); + GetLogger() + PTR_DEREF Error(StringFormat("Invalid Strategy action: %d at %s!", _entry.GetId(), __FUNCTION_LINE__)); SetUserError(ERR_INVALID_PARAMETER); break; } diff --git a/Strategy.struct.h b/Strategy.struct.h index d7e852c04..160c43980 100644 --- a/Strategy.struct.h +++ b/Strategy.struct.h @@ -47,7 +47,7 @@ struct StgParams { bool is_suspended; // State of the strategy (whether suspended or not) bool is_boosted; // State of the boost feature (to increase lot size). float weight; // Weight of the strategy. - long order_close_time; // Order close time in mins (>0) or bars (<0). + int64 order_close_time; // Order close time in mins (>0) or bars (<0). float order_close_loss; // Order close loss (in pips). float order_close_profit; // Order close profit (in pips). int signal_open_method; // Signal open method. @@ -72,7 +72,7 @@ struct StgParams { int tp_max; // Hard limit on maximum take profit (in pips). int sl_max; // Hard limit on maximum stop loss (in pips). int type; // Strategy type (@see: ENUM_STRATEGY). - long id; // Unique identifier of the strategy. + int64 id; // Unique identifier of the strategy. datetime refresh_time; // Order refresh frequency (in sec). short shift; // Shift (relative to the current bar, 0 - default) ChartTf tf; // Main timeframe where strategy operates on. @@ -142,7 +142,7 @@ struct StgParams { sl_max(0), type(0), refresh_time(0) {} - StgParams(StgParams &_stg_params) { this = _stg_params; } + StgParams(const StgParams &_stg_params) { THIS_REF = _stg_params; } // Deconstructor. ~StgParams() {} @@ -212,7 +212,7 @@ struct StgParams { void Set(ENUM_STRATEGY_PARAM _param, T _value) { switch (_param) { case STRAT_PARAM_ID: // ID (magic number). - id = (long)_value; + id = (int64)_value; return; case STRAT_PARAM_LS: // Lot size lot_size = (float)_value; @@ -248,7 +248,7 @@ struct StgParams { order_close_profit = (float)_value; return; case STRAT_PARAM_OCT: // Order close time - order_close_time = (long)_value; + order_close_time = (int64)_value; return; case STRAT_PARAM_SOM: // Signal open method signal_open_method = (int)_value; @@ -297,7 +297,7 @@ struct StgParams { Set(_enum_param, _mql_param.integer_value); } } - void SetId(long _id) { id = _id; } + void SetId(int64 _id) { id = _id; } void SetStops(Strategy *_sl = NULL, Strategy *_tp = NULL) { // @todo: To remove. } diff --git a/Strategy.struct.pricestop.h b/Strategy.struct.pricestop.h index 240ef01b3..3f935ef2d 100644 --- a/Strategy.struct.pricestop.h +++ b/Strategy.struct.pricestop.h @@ -56,7 +56,7 @@ struct StrategyPriceStop { float ivalue; // Indicator price value. unsigned int method; // Store price stop methods (@see: ENUM_STRATEGY_PRICE_STOP). // unsigned int mode[2]; // Indicator modes to use. - Ref indi_candle; + Ref indi_candle; // IndicatorDataEntry idata[]; // IndicatorParams iparams; @@ -103,7 +103,7 @@ struct StrategyPriceStop { return (float)_result; } /* Setters */ - void SetCandleSource(IndicatorBase* _indi_candle) { indi_candle = _indi_candle; } + void SetCandleSource(IndicatorData* _indi_candle) { indi_candle = _indi_candle; } void SetIndicatorPriceValue(float _ivalue) { ivalue = _ivalue; } /* void SetIndicatorDataEntry(IndicatorDataEntry &_data[]) { @@ -143,7 +143,8 @@ struct StrategyPriceStop { int _size = sizeof(int) * 8; for (int i = 0; i < _size; i++) { int _value = CheckMethod(1 << i) ? 1 : 0; - _s.Pass(this, (string)(i + 1), _value, SERIALIZER_FIELD_FLAG_DYNAMIC | SERIALIZER_FIELD_FLAG_FEATURE); + _s.Pass(THIS_REF, IntegerToString(i + 1), _value, + (int)(SERIALIZER_FIELD_FLAG_DYNAMIC | SERIALIZER_FIELD_FLAG_FEATURE)); } return SerializerNodeObject; } diff --git a/Task/Task.struct.h b/Task/Task.struct.h index 8b9544ce0..bf87e10bf 100644 --- a/Task/Task.struct.h +++ b/Task/Task.struct.h @@ -32,6 +32,7 @@ // Includes. #include "../Platform/Terminal.define.h" +#include "../Serializer/Serializer.h" #include "Task.enum.h" #include "TaskAction.struct.h" #include "TaskCondition.struct.h" diff --git a/Task/tests/TaskAction.test.mq5 b/Task/tests/TaskAction.test.mq5 index 5523bbfd7..2c12f7eee 100644 --- a/Task/tests/TaskAction.test.mq5 +++ b/Task/tests/TaskAction.test.mq5 @@ -36,11 +36,11 @@ enum ENUM_TASK_ACTION_TEST { class TaskActionTest01 : public TaskActionBase { protected: - long sum; + int64 sum; public: TaskActionTest01() : sum(0){}; - long GetSum() { return sum; } + int64 GetSum() { return sum; } bool Run(const TaskActionEntry &_entry) { sum += _entry.GetId(); PrintFormat("%s; sum=%d", __FUNCSIG__, sum); @@ -50,11 +50,11 @@ class TaskActionTest01 : public TaskActionBase { class TaskActionTest02 : public TaskActionBase { protected: - long sum; + int64 sum; public: TaskActionTest02() : sum(0){}; - long GetSum() { return sum; } + int64 GetSum() { return sum; } bool Run(const TaskActionEntry &_entry) { sum += _entry.GetId(); PrintFormat("%s; sum=%d", __FUNCSIG__, sum); diff --git a/Task/tests/TaskCondition.test.mq5 b/Task/tests/TaskCondition.test.mq5 index 0af6e94da..231ac5e33 100644 --- a/Task/tests/TaskCondition.test.mq5 +++ b/Task/tests/TaskCondition.test.mq5 @@ -36,11 +36,11 @@ enum ENUM_TASK_CONDITION_TEST { class TaskConditionTest01 : public TaskConditionBase { protected: - long sum; + int64 sum; public: TaskConditionTest01() : sum(0){}; - long GetSum() { return sum; } + int64 GetSum() { return sum; } bool Check(const TaskConditionEntry &_entry) { sum += _entry.GetId(); PrintFormat("%s; sum=%d", __FUNCSIG__, sum); @@ -50,11 +50,11 @@ class TaskConditionTest01 : public TaskConditionBase { class TaskConditionTest02 : public TaskConditionBase { protected: - long sum; + int64 sum; public: TaskConditionTest02() : sum(0){}; - long GetSum() { return sum; } + int64 GetSum() { return sum; } bool Check(const TaskConditionEntry &_entry) { sum += _entry.GetId(); PrintFormat("%s; sum=%d", __FUNCSIG__, sum); diff --git a/Task/tests/TaskGetter.test.mq5 b/Task/tests/TaskGetter.test.mq5 index fe2a72d0e..ee41b0c80 100644 --- a/Task/tests/TaskGetter.test.mq5 +++ b/Task/tests/TaskGetter.test.mq5 @@ -47,7 +47,7 @@ class TaskGetterTest01 : public TaskGetter { public: TaskGetterTest01(){}; - // long GetSum() { return sum; } + // int64 GetSum() { return sum; } TaskGetterTest01Data Get() { return TaskGetter::Get(); } TaskGetterTest01Data Get(const TaskGetterEntry &_entry) { data.SetValue(_entry.GetId()); diff --git a/Tick/Tick.struct.h b/Tick/Tick.struct.h index 3308089e8..1f790b999 100644 --- a/Tick/Tick.struct.h +++ b/Tick/Tick.struct.h @@ -30,8 +30,8 @@ #endif // Includes. -#include "../Storage/DateTime.extern.h" #include "../Std.h" +#include "../Storage/DateTime.extern.h" #ifndef __MQL__ /** @@ -40,14 +40,14 @@ * https://www.mql5.com/en/docs/constants/structures/mqltick */ struct MqlTick { - datetime time; // Time of the last prices update. - double ask; // Current Ask price. - double bid; // Current Bid price. - double last; // Price of the last deal (last). - double volume_real; // Volume for the current last price with greater accuracy. - int64 time_msc; // Time of a price last update in milliseconds. - unsigned int flags; // Tick flags. - unsigned int64 volume; // Volume for the current last price. + datetime time; // Time of the last prices update. + double ask; // Current Ask price. + double bid; // Current Bid price. + double last; // Price of the last deal (last). + double volume_real; // Volume for the current last price with greater accuracy. + int64 time_msc; // Time of a price last update in milliseconds. + unsigned int flags; // Tick flags. + uint64 volume; // Volume for the current last price. // Default constructor. MqlTick() {} diff --git a/Ticker.mqh b/Ticker.mqh index a1d90d55c..0658f348a 100644 --- a/Ticker.mqh +++ b/Ticker.mqh @@ -28,9 +28,9 @@ class Chart; // Includes. -#include "Platform/Chart/Chart.h" -#include "Log.mqh" #include "Exchange/SymbolInfo/SymbolInfo.h" +#include "Log.mqh" +#include "Platform/Chart/Chart.h" //#include "Market.mqh" // Define an assert macros. @@ -48,7 +48,7 @@ class Ticker { }; protected: - unsigned long total_added, total_ignored, total_processed, total_saved; + uint64 total_added, total_ignored, total_processed, total_saved; // Struct variables. MqlTick data[]; // Class variables. @@ -85,22 +85,22 @@ class Ticker { /** * Get number of added ticks. */ - unsigned long GetTotalAdded() { return total_added; } + uint64 GetTotalAdded() { return total_added; } /** * Get number of ignored ticks. */ - unsigned long GetTotalIgnored() { return total_ignored; } + uint64 GetTotalIgnored() { return total_ignored; } /** * Get number of parsed ticks. */ - unsigned long GetTotalProcessed() { return total_processed; } + uint64 GetTotalProcessed() { return total_processed; } /** * Get number of saved ticks. */ - unsigned long GetTotalSaved() { return total_saved; } + uint64 GetTotalSaved() { return total_saved; } /* Other methods */ diff --git a/Timer.mqh b/Timer.mqh index c15d89314..e5eec1a08 100644 --- a/Timer.mqh +++ b/Timer.mqh @@ -39,7 +39,7 @@ class Timer : public Object { int index; unsigned int data[]; unsigned int start, end; - unsigned long max; + uint64 max; public: /** @@ -78,7 +78,7 @@ class Timer : public Object { /** * Print the current timer times when maximum value is reached. */ - Timer *PrintOnMax(unsigned long _min = 1) { + Timer *PrintOnMax(uint64 _min = 1) { return data[index] > _min && data[this PTR_DEREF index] >= this PTR_DEREF max ? PrintSummary() : GetPointer(this); } @@ -98,9 +98,9 @@ class Timer : public Object { /** * Get the sum of all values. */ - unsigned long GetSum() { + uint64 GetSum() { unsigned int _size = ArraySize(this PTR_DEREF data); - unsigned long _sum = 0; + uint64 _sum = 0; for (unsigned int _i = 0; _i < _size; _i++) { _sum += data[_i]; } diff --git a/Trade.mqh b/Trade.mqh index 3bea5a760..c39d2fb49 100644 --- a/Trade.mqh +++ b/Trade.mqh @@ -30,14 +30,14 @@ class Trade; #define TRADE_MQH // Includes. -#include "Exchange/Account/AccountMt.h" #include "Convert.mqh" -#include "Storage/Dict/DictStruct.h" +#include "Exchange/Account/AccountMt.h" #include "Indicator/IndicatorData.h" #include "Math/Math.h" -#include "Storage/Object.h" #include "Platform/Order.h" #include "Platform/OrderQuery.h" +#include "Storage/Dict/DictStruct.h" +#include "Storage/Object.h" #include "Task/TaskManager.h" #include "Task/Taskable.h" #include "Trade.enum.h" @@ -47,9 +47,9 @@ class Trade : public Taskable { public: AccountMt account; Ref indi_candle; - DictStruct> orders_active; - DictStruct> orders_history; - DictStruct> orders_pending; + DictStruct> orders_active; + DictStruct> orders_history; + DictStruct> orders_pending; Log logger; // Trade logger. TaskManager tasks; // Tasks. TradeParams tparams; // Trade parameters. @@ -170,7 +170,7 @@ class Trade : public Taskable { * @return * Returns DictStruct's of active orders. */ - DictStruct> *GetOrdersActive() { return &orders_active; } + DictStruct> *GetOrdersActive() { return &orders_active; } /** * Gets list of history orders. @@ -178,7 +178,7 @@ class Trade : public Taskable { * @return * Returns DictStruct's of orders from history. */ - DictStruct> *GetOrdersHistory() { return &orders_history; } + DictStruct> *GetOrdersHistory() { return &orders_history; } /** * Gets list of pending orders. @@ -186,7 +186,7 @@ class Trade : public Taskable { * @return * Returns DictStruct's of pending orders. */ - DictStruct> *GetOrdersPending() { return &orders_pending; } + DictStruct> *GetOrdersPending() { return &orders_pending; } /** * Get a trade request. @@ -194,13 +194,14 @@ class Trade : public Taskable { * @return * Returns true on successful request. */ - MqlTradeRequest GetTradeOpenRequest(ENUM_ORDER_TYPE _type, float _volume = 0, long _magic = 0, string _comment = "") { + MqlTradeRequest GetTradeOpenRequest(ENUM_ORDER_TYPE _type, float _volume = 0, int64 _magic = 0, + string _comment = "") { // Create a request. MqlTradeRequest _request = {(ENUM_TRADE_REQUEST_ACTIONS)0}; _request.action = TRADE_ACTION_DEAL; _request.comment = _comment; _request.deviation = 10; - _request.magic = _magic > 0 ? _magic : tparams.Get(TRADE_PARAM_MAGIC_NO); + _request.magic = _magic > 0 ? _magic : tparams.Get(TRADE_PARAM_MAGIC_NO); _request.symbol = GetSource() PTR_DEREF GetSymbol(); _request.price = GetSource() PTR_DEREF GetOpenOffer(_type); _request.type = _type; @@ -337,15 +338,15 @@ class Trade : public Taskable { Ref _order = order_last; if (_order.IsSet() && _order REF_DEREF Get(ORDER_TYPE) == _cmd && - _order REF_DEREF Get(ORDER_TIME_SETUP) > GetSource() PTR_DEREF GetBarTime()) { + _order REF_DEREF Get(ORDER_TIME_SETUP) > GetSource() PTR_DEREF GetBarTime()) { _result |= true; } if (!_result) { - for (DictStructIterator> iter = orders_active.Begin(); iter.IsValid(); ++iter) { + for (DictStructIterator> iter = orders_active.Begin(); iter.IsValid(); ++iter) { _order = iter.Value(); if (_order REF_DEREF Get(ORDER_TYPE) == _cmd) { - long _time_opened = _order REF_DEREF Get(ORDER_TIME_SETUP); + int64 _time_opened = _order REF_DEREF Get(ORDER_TIME_SETUP); _result |= _shift > 0 && _time_opened < GetSource() PTR_DEREF GetBarTime(_shift - 1); _result |= _time_opened >= GetSource() PTR_DEREF GetBarTime(_shift); if (_result) { @@ -383,7 +384,7 @@ class Trade : public Taskable { } if (!_result) { - for (DictStructIterator> iter = orders_active.Begin(); iter.IsValid() && !_result; ++iter) { + for (DictStructIterator> iter = orders_active.Begin(); iter.IsValid() && !_result; ++iter) { _order = iter.Value(); if (_order.IsSet() && _order REF_DEREF IsOpen()) { if (_odata.Get(ORDER_TYPE) == _cmd) { @@ -421,7 +422,7 @@ class Trade : public Taskable { } if (!_result) { - for (DictStructIterator> iter = orders_active.Begin(); iter.IsValid() && !_result; ++iter) { + for (DictStructIterator> iter = orders_active.Begin(); iter.IsValid() && !_result; ++iter) { _order = iter.Value(); if (_order.IsSet()) { _result = _odata.Get(ORDER_TYPE) != _cmd; @@ -678,7 +679,7 @@ HistorySelect(0, TimeCurrent()); // Select history for access. tstats.Add(TRADE_STAT_ORDERS_ERRORS); // Pass-through. case ERR_NO_ERROR: // 0 - orders_active.Set(_order PTR_DEREF Get(ORDER_PROP_TICKET), _ref_order); + orders_active.Set(_order PTR_DEREF Get(ORDER_PROP_TICKET), _ref_order); order_last = _order; tstates.AddState(TRADE_STATE_ORDERS_ACTIVE); tstats.Add(TRADE_STAT_ORDERS_OPENED); @@ -711,9 +712,9 @@ HistorySelect(0, TimeCurrent()); // Select history for access. */ bool OrderMoveToHistory(Order *_order) { _order PTR_DEREF Refresh(true); - orders_active.Unset(_order PTR_DEREF Get(ORDER_PROP_TICKET)); + orders_active.Unset(_order PTR_DEREF Get(ORDER_PROP_TICKET)); Ref _ref_order = _order; - bool result = orders_history.Set(_order PTR_DEREF Get(ORDER_PROP_TICKET), _ref_order); + bool result = orders_history.Set(_order PTR_DEREF Get(ORDER_PROP_TICKET), _ref_order); /* @todo if (strategy != NULL) { strategy.OnOrderClose(_order); @@ -727,7 +728,7 @@ HistorySelect(0, TimeCurrent()); // Select history for access. tstates.RemoveState(TRADE_STATE_ORDERS_MAX_SOFT); return result; } - bool OrderMoveToHistory(unsigned long _ticket) { + bool OrderMoveToHistory(uint64 _ticket) { Ref _order = orders_active.GetByKey(_ticket); return OrderMoveToHistory(_order.Ptr()); } @@ -737,7 +738,7 @@ HistorySelect(0, TimeCurrent()); // Select history for access. */ bool RefreshActiveOrders(bool _force = false, bool _first_close = false) { bool _result = true; - for (DictStructIterator> iter = orders_active.Begin(); iter.IsValid(); ++iter) { + for (DictStructIterator> iter = orders_active.Begin(); iter.IsValid(); ++iter) { Ref _order = iter.Value(); if (_order.IsSet() && _order REF_DEREF IsOpen(true)) { _order REF_DEREF Refresh(_force); @@ -757,7 +758,7 @@ HistorySelect(0, TimeCurrent()); // Select history for access. template bool RefreshActiveOrdersByProp(E _prop, bool _force = false) { bool _result = true; - for (DictStructIterator> iter = orders_active.Begin(); iter.IsValid(); ++iter) { + for (DictStructIterator> iter = orders_active.Begin(); iter.IsValid(); ++iter) { Ref _order = iter.Value(); if (_order.IsSet() && _order REF_DEREF IsOpen(true)) { if (_force || _order REF_DEREF ShouldRefresh()) { @@ -815,9 +816,9 @@ HistorySelect(0, TimeCurrent()); // Select history for access. Ref _order_ref = _order; if (_order PTR_DEREF IsOpen()) { // @todo: _order.IsPending()? - _result &= orders_active.Set(_order PTR_DEREF Get(ORDER_PROP_TICKET), _order_ref); + _result &= orders_active.Set(_order PTR_DEREF Get(ORDER_PROP_TICKET), _order_ref); } else { - _result &= orders_history.Set(_order PTR_DEREF Get(ORDER_PROP_TICKET), _order_ref); + _result &= orders_history.Set(_order PTR_DEREF Get(ORDER_PROP_TICKET), _order_ref); } return _result && GetLastError() == ERR_NO_ERROR; } @@ -825,13 +826,13 @@ HistorySelect(0, TimeCurrent()); // Select history for access. /** * Loads active orders by magic number. */ - bool OrdersLoadByMagic(unsigned long _magic_no) { + bool OrdersLoadByMagic(uint64 _magic_no) { ResetLastError(); int _total_active = TradeStatic::TotalActive(); for (int pos = 0; pos < _total_active; pos++) { if (OrderStatic::SelectByPosition(pos)) { if (OrderStatic::MagicNumber() == _magic_no) { - unsigned long _ticket = OrderStatic::Ticket(); + uint64 _ticket = OrderStatic::Ticket(); Ref _order = new Order(_ticket); orders_active.Set(_ticket, _order); } @@ -870,7 +871,7 @@ HistorySelect(0, TimeCurrent()); // Select history for access. int _closed = 0; Ref _order; _comment = _comment != "" ? _comment : __FUNCTION__; - for (DictStructIterator> iter = orders_active.Begin(); iter.IsValid(); ++iter) { + for (DictStructIterator> iter = orders_active.Begin(); iter.IsValid(); ++iter) { _order = iter.Value(); if (_order REF_DEREF IsOpen(true)) { if (_order REF_DEREF OrderClose(_reason, _comment)) { @@ -878,7 +879,7 @@ HistorySelect(0, TimeCurrent()); // Select history for access. OrderMoveToHistory(_order.Ptr()); order_last = _order; } else { - logger.AddLastError(__FUNCTION_LINE__, _order REF_DEREF Get(ORDER_PROP_LAST_ERROR)); + logger.AddLastError(__FUNCTION_LINE__, _order REF_DEREF Get(ORDER_PROP_LAST_ERROR)); return -1; } } else { @@ -900,7 +901,7 @@ HistorySelect(0, TimeCurrent()); // Select history for access. int _closed = 0; Ref _order; _comment = _comment != "" ? _comment : __FUNCTION__; - for (DictStructIterator> iter = orders_active.Begin(); iter.IsValid(); ++iter) { + for (DictStructIterator> iter = orders_active.Begin(); iter.IsValid(); ++iter) { _order = iter.Value(); if (_order REF_DEREF IsOpen(true)) { _order REF_DEREF Refresh(); @@ -911,7 +912,7 @@ HistorySelect(0, TimeCurrent()); // Select history for access. order_last = _order; } else { logger.Error("Error while closing order!", __FUNCTION_LINE__, - StringFormat("Code: %d", _order REF_DEREF Get(ORDER_PROP_LAST_ERROR))); + StringFormat("Code: %d", _order REF_DEREF Get(ORDER_PROP_LAST_ERROR))); return -1; } order_last = _order; @@ -938,7 +939,7 @@ HistorySelect(0, TimeCurrent()); // Select history for access. int _closed = 0; Ref _order; _comment = _comment != "" ? _comment : __FUNCTION__; - for (DictStructIterator> iter = orders_active.Begin(); iter.IsValid(); ++iter) { + for (DictStructIterator> iter = orders_active.Begin(); iter.IsValid(); ++iter) { _order = iter.Value(); if (_order REF_DEREF IsOpen(true)) { _order REF_DEREF Refresh((E)_prop); @@ -948,7 +949,7 @@ HistorySelect(0, TimeCurrent()); // Select history for access. OrderMoveToHistory(_order.Ptr()); order_last = _order; } else { - logger.AddLastError(__FUNCTION_LINE__, _order REF_DEREF Get(ORDER_PROP_LAST_ERROR)); + logger.AddLastError(__FUNCTION_LINE__, _order REF_DEREF Get(ORDER_PROP_LAST_ERROR)); return -1; } } @@ -974,7 +975,7 @@ HistorySelect(0, TimeCurrent()); // Select history for access. int _closed = 0; Ref _order; _comment = _comment != "" ? _comment : __FUNCTION__; - for (DictStructIterator> iter = orders_active.Begin(); iter.IsValid(); ++iter) { + for (DictStructIterator> iter = orders_active.Begin(); iter.IsValid(); ++iter) { _order = iter.Value(); if (_order REF_DEREF IsOpen(true)) { _order REF_DEREF Refresh(); @@ -1016,15 +1017,15 @@ HistorySelect(0, TimeCurrent()); // Select history for access. /** * Calculate number of allowed orders to open. */ - unsigned long CalcMaxOrders(float volume_size, float _risk_ratio = 1.0, long prev_max_orders = 0, long hard_limit = 0, - bool smooth = true) { + uint64 CalcMaxOrders(float volume_size, float _risk_ratio = 1.0, int64 prev_max_orders = 0, int64 hard_limit = 0, + bool smooth = true) { float _avail_margin = fmin(account.GetMarginFree(), account.GetBalance() + account.GetCredit()); if (_avail_margin == 0 || volume_size == 0) { return 0; } float _margin_required = GetMarginRequired(); float _avail_orders = _avail_margin / _margin_required / volume_size; - long new_max_orders = (long)(_avail_orders * _risk_ratio); + int64 new_max_orders = (int64)(_avail_orders * _risk_ratio); if (hard_limit > 0) new_max_orders = fmin(hard_limit, new_max_orders); if (smooth && new_max_orders > prev_max_orders) { // Increase the limit smoothly. @@ -1172,10 +1173,10 @@ HistorySelect(0, TimeCurrent()); // Select history for access. * * @see: https://book.mql4.com/appendix/limits */ - static long GetTradeDistanceInPts(string _symbol) { + static int64 GetTradeDistanceInPts(string _symbol) { return fmax(SymbolInfoStatic::GetTradeStopsLevel(_symbol), SymbolInfoStatic::GetFreezeLevel(_symbol)); } - long GetTradeDistanceInPts() { return GetTradeDistanceInPts(GetSource() PTR_DEREF GetSymbol()); } + int64 GetTradeDistanceInPts() { return GetTradeDistanceInPts(GetSource() PTR_DEREF GetSymbol()); } /** * Get a market distance in pips. @@ -1733,7 +1734,7 @@ HistorySelect(0, TimeCurrent()); // Select history for access. */ virtual void OnOrderOpen(const Order &_order) { if (logger.GetLevel() >= V_INFO) { - // logger.Info(_order.ToString(), (string)_order.Get(ORDER_TICKET)); // @fixme + // logger.Info(_order.ToString(), (string)_order.Get(ORDER_TICKET)); // @fixme ResetLastError(); // @fixme: Error 69539 } } diff --git a/Trade.struct.h b/Trade.struct.h index c581db218..c959c1e94 100644 --- a/Trade.struct.h +++ b/Trade.struct.h @@ -132,7 +132,7 @@ struct TradeParams { unsigned short bars_min; // Minimum bars to trade. string order_comment; // Order comment. float lot_size; // Default lot size. - unsigned long magic_no; // Unique magic number used for the trading. + uint64 magic_no; // Unique magic number used for the trading. float risk_margin; // Maximum account margin to risk (in %). unsigned int limits_stats[FINAL_ENUM_TRADE_STAT_TYPE][FINAL_ENUM_TRADE_STAT_PERIOD]; unsigned int slippage; // Value of the maximum price slippage in points. @@ -147,7 +147,7 @@ struct TradeParams { slippage(_slippage) { SetLimits(0); } - TradeParams(unsigned long _magic_no, ENUM_LOG_LEVEL _ll = V_INFO) + TradeParams(uint64 _magic_no, ENUM_LOG_LEVEL _ll = V_INFO) : bars_min(100), order_comment(""), lot_size(0), magic_no(_magic_no), log_level(_ll) {} TradeParams(const TradeParams &_tparams) { THIS_REF = _tparams; } // Deconstructor. @@ -219,7 +219,7 @@ struct TradeParams { lot_size = (float)_value; return; case TRADE_PARAM_MAGIC_NO: - magic_no = (unsigned long)_value; + magic_no = (uint64)_value; return; case TRADE_PARAM_ORDER_COMMENT: order_comment = SerializerConversions::ValueToString(_value); @@ -276,7 +276,7 @@ struct TradeParams { } } void SetLotSize(float _lot_size) { lot_size = _lot_size; } - void SetMagicNo(unsigned long _mn) { magic_no = _mn; } + void SetMagicNo(uint64 _mn) { magic_no = _mn; } void SetRiskMargin(float _value) { risk_margin = _value; } // Serializers. void SerializeStub(int _n1 = 1, int _n2 = 1, int _n3 = 1, int _n4 = 1, int _n5 = 1) {} diff --git a/Trade/TradeSignal.struct.h b/Trade/TradeSignal.struct.h index 92946633f..76d171b89 100644 --- a/Trade/TradeSignal.struct.h +++ b/Trade/TradeSignal.struct.h @@ -58,11 +58,11 @@ // Structure for a trade signal. struct TradeSignalEntry { protected: - long magic_id; // Magic identifier. + int64 magic_id; // Magic identifier. unsigned int signals; // Store signals (@see: ENUM_TRADE_SIGNAL_FLAG). float strength; // Signal strength. ENUM_TIMEFRAMES tf; // Timeframe. - long timestamp; // Creation timestamp + int64 timestamp; // Creation timestamp float weight; // Signal weight. public: @@ -117,8 +117,8 @@ struct TradeSignalEntry { }; /* Constructor */ - TradeSignalEntry(unsigned int _signals = 0, ENUM_TIMEFRAMES _tf = PERIOD_CURRENT, long _magic_id = 0, - float _strength = 0.0f, float _weight = 0.0f, long _time = 0) + TradeSignalEntry(unsigned int _signals = 0, ENUM_TIMEFRAMES _tf = PERIOD_CURRENT, int64 _magic_id = 0, + float _strength = 0.0f, float _weight = 0.0f, int64 _time = 0) : magic_id(_magic_id), signals(_signals), strength(_strength), tf(_tf), timestamp(_time), weight(_weight) {} TradeSignalEntry(const TradeSignalEntry &_entry) { THIS_REF = _entry; } /* Getters */ @@ -147,7 +147,7 @@ struct TradeSignalEntry { void Set(STRUCT_ENUM(TradeSignalEntry, ENUM_TRADE_SIGNAL_PROP) _prop, T _value) { switch (_prop) { case TRADE_SIGNAL_PROP_MAGIC_ID: - magic_id = (long)_value; + magic_id = (int64)_value; return; case TRADE_SIGNAL_PROP_SIGNALS: signals = (unsigned int)_value; @@ -159,7 +159,7 @@ struct TradeSignalEntry { tf = (ENUM_TIMEFRAMES)_value; return; case TRADE_SIGNAL_PROP_TIME: - timestamp = (long)_value; + timestamp = (int64)_value; return; case TRADE_SIGNAL_PROP_WEIGHT: weight = (float)_value; diff --git a/Trade/TradeSignalManager.h b/Trade/TradeSignalManager.h index da966da63..c481bc684 100644 --- a/Trade/TradeSignalManager.h +++ b/Trade/TradeSignalManager.h @@ -140,7 +140,7 @@ class TradeSignalManager : Dynamic { continue; } } - Set(TSM_PROP_LAST_CHECK, ::TimeGMT()); + Set(TSM_PROP_LAST_CHECK, ::TimeGMT()); } /* State methods */ @@ -152,9 +152,9 @@ class TradeSignalManager : Dynamic { * _update Update last check timestamp when true. */ bool IsReady(bool _update = true) { - bool _res = Get(TSM_PROP_LAST_CHECK) + Get(TSM_PROP_FREQ) >= ::TimeGMT(); + bool _res = Get(TSM_PROP_LAST_CHECK) + Get(TSM_PROP_FREQ) >= ::TimeGMT(); if (_res) { - Set(TSM_PROP_LAST_CHECK, ::TimeGMT()); + Set(TSM_PROP_LAST_CHECK, ::TimeGMT()); } return _res; } diff --git a/Trade/TradeSignalManager.struct.h b/Trade/TradeSignalManager.struct.h index bf3e56c08..aebaac524 100644 --- a/Trade/TradeSignalManager.struct.h +++ b/Trade/TradeSignalManager.struct.h @@ -39,8 +39,8 @@ */ struct TradeSignalManagerParams { protected: - short freq; // Signal process refresh frequency (in sec). - long last_check; // Last check. + short freq; // Signal process refresh frequency (in sec). + int64 last_check; // Last check. public: /* Struct's enumerations */ @@ -84,7 +84,7 @@ struct TradeSignalManagerParams { freq = (short)_value; return; case TSM_PARAMS_PROP_LAST_CHECK: - last_check = (long)_value; + last_check = (int64)_value; return; } SetUserError(ERR_INVALID_PARAMETER); diff --git a/tests/StrategyTest-RSI.mq5 b/tests/StrategyTest-RSI.mq5 index 489ababc1..a43da0df7 100644 --- a/tests/StrategyTest-RSI.mq5 +++ b/tests/StrategyTest-RSI.mq5 @@ -28,10 +28,10 @@ //#define __debug_verbose__ // Includes. -#include "../Platform/Chart/ChartMt.h" #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" @@ -95,7 +95,7 @@ int OnInit() { // Initialize strategy instance. stg_rsi = Stg_RSI::Init(_candles = Platform::FetchDefaultCandleIndicator(_Symbol, PERIOD_M5)); stg_rsi REF_DEREF SetName("Stg_RSI"); - stg_rsi REF_DEREF Set(STRAT_PARAM_ID, 1234); + stg_rsi REF_DEREF Set(STRAT_PARAM_ID, 1234); // Initialize trade instance. TradeParams _tparams; @@ -113,7 +113,7 @@ int OnInit() { Print(stg_rsi REF_DEREF ToString()); // Check for errors. - long _last_error = GetLastError(); + int64 _last_error = GetLastError(); if (_last_error > 0) { assertTrueOrFail(_last_error == ERR_NO_ERROR, StringFormat("Error occured! Code: %d", _last_error)); } @@ -129,23 +129,23 @@ void OnTick() { if (Platform::IsNewMinute()) { if (stg_rsi REF_DEREF SignalOpen(ORDER_TYPE_BUY)) { MqlTradeRequest _request = trade REF_DEREF GetTradeOpenRequest( - ORDER_TYPE_BUY, 0, stg_rsi REF_DEREF Get(STRAT_PARAM_ID), stg_rsi REF_DEREF GetName()); + ORDER_TYPE_BUY, 0, stg_rsi REF_DEREF Get(STRAT_PARAM_ID), stg_rsi REF_DEREF GetName()); trade REF_DEREF RequestSend(_request); } else if (stg_rsi REF_DEREF SignalOpen(ORDER_TYPE_SELL)) { MqlTradeRequest _request = trade REF_DEREF GetTradeOpenRequest( - ORDER_TYPE_SELL, 0, stg_rsi REF_DEREF Get(STRAT_PARAM_ID), stg_rsi REF_DEREF GetName()); + ORDER_TYPE_SELL, 0, stg_rsi REF_DEREF Get(STRAT_PARAM_ID), stg_rsi REF_DEREF GetName()); trade REF_DEREF RequestSend(_request); } if (trade REF_DEREF Get(TRADE_STATE_ORDERS_ACTIVE)) { if (stg_rsi REF_DEREF SignalClose(ORDER_TYPE_BUY)) { // Close signal for buy order. - trade REF_DEREF OrdersCloseViaProp2( - ORDER_MAGIC, stg_rsi REF_DEREF Get(STRAT_PARAM_ID), ORDER_TYPE, ORDER_TYPE_BUY, MATH_COND_EQ, + trade REF_DEREF OrdersCloseViaProp2( + ORDER_MAGIC, stg_rsi REF_DEREF Get(STRAT_PARAM_ID), ORDER_TYPE, ORDER_TYPE_BUY, MATH_COND_EQ, ORDER_REASON_CLOSED_BY_SIGNAL, stg_rsi REF_DEREF GetOrderCloseComment()); } if (stg_rsi REF_DEREF SignalClose(ORDER_TYPE_SELL)) { - trade REF_DEREF OrdersCloseViaProp2( - ORDER_MAGIC, stg_rsi REF_DEREF Get(STRAT_PARAM_ID), ORDER_TYPE, ORDER_TYPE_SELL, MATH_COND_EQ, + trade REF_DEREF OrdersCloseViaProp2( + ORDER_MAGIC, stg_rsi REF_DEREF Get(STRAT_PARAM_ID), ORDER_TYPE, ORDER_TYPE_SELL, MATH_COND_EQ, ORDER_REASON_CLOSED_BY_SIGNAL, stg_rsi REF_DEREF GetOrderCloseComment()); } } @@ -155,7 +155,7 @@ void OnTick() { // Print strategy values every hour. Print(stg_rsi REF_DEREF ToString()); } - long _last_error = GetLastError(); + int64 _last_error = GetLastError(); if (_last_error > 0) { assertTrueOrExit(_last_error == ERR_NO_ERROR, StringFormat("Error occured! Code: %d", _last_error)); } diff --git a/tests/TickerTest.mq5 b/tests/TickerTest.mq5 index b1f8870d5..c4b89b56e 100644 --- a/tests/TickerTest.mq5 +++ b/tests/TickerTest.mq5 @@ -31,7 +31,7 @@ // Global variables. Ref indi_tick; -unsigned long total_ticks; +uint64 total_ticks; Ticker *ticker_csv; Ticker *ticker01; Ticker *ticker02; From cf14d7854dc1620f3fc1f2dc4d715ff83973a47a Mon Sep 17 00:00:00 2001 From: Adrian Kierzkowski Date: Thu, 6 Jul 2023 20:00:59 +0200 Subject: [PATCH 22/26] C++ tests now compiles. --- Convert.basic.h | 24 ++++++++++++++++++++++++ EA.mqh | 2 +- EA.struct.h | 18 ++++++++++++------ Indicator/IndicatorData.h | 19 +++++++++++++++++++ Serializer/SerializerNodeParam.h | 6 +++++- Storage/Dict/DictIteratorBase.h | 9 ++++++++- Storage/Dict/DictStruct.h | 2 +- Trade.struct.h | 12 ++++++------ Trade/TradeSignal.struct.h | 2 +- 9 files changed, 77 insertions(+), 17 deletions(-) diff --git a/Convert.basic.h b/Convert.basic.h index b1a7d546d..bd208e044 100644 --- a/Convert.basic.h +++ b/Convert.basic.h @@ -176,4 +176,28 @@ class ConvertBasic { DoubleToType(_value, _out); return _out; } + + template + static T Convert(bool _value, T& _out) { + BoolToType(_value, _out); + return _out; + } + + template + static T Convert(int64 _value, T& _out) { + LongToType(_value, _out); + return _out; + } + + template + static T Convert(double _value, T& _out) { + DoubleToType(_value, _out); + return _out; + } + + template + static T Convert(CONST_REF_TO(string) _value, T& _out) { + StringToType(_value, _out); + return _out; + } }; diff --git a/EA.mqh b/EA.mqh index a3179f174..a307aa7a8 100644 --- a/EA.mqh +++ b/EA.mqh @@ -1136,7 +1136,7 @@ class EA : public Taskable { * Returns serialized representation of the object instance. */ SerializerNodeType Serialize(Serializer &_s) { - _s.Pass(THIS_REF, "account", account, SERIALIZER_FIELD_FLAG_DYNAMIC); + _s.PassObject(THIS_REF, "account", PTR_TO_REF(account), SERIALIZER_FIELD_FLAG_DYNAMIC); for (DictStructIterator> _iter = GetStrategies() PTR_DEREF Begin(); _iter.IsValid(); ++_iter) { Strategy *_strat = _iter.Value().Ptr(); diff --git a/EA.struct.h b/EA.struct.h index 26f4ea3ff..9f72e46f8 100644 --- a/EA.struct.h +++ b/EA.struct.h @@ -111,9 +111,11 @@ struct EAParams { // Getters. template T Get(unsigned int _param) { + T _out; switch (_param) { case EA_PARAM_PROP_AUTHOR: - return (T)author; + ConvertBasic::StringToType(author, _out); + return _out; case EA_PARAM_PROP_CHART_INFO_FREQ: return (T)chart_info_freq; case EA_PARAM_PROP_DATA_EXPORT: @@ -121,19 +123,23 @@ struct EAParams { case EA_PARAM_PROP_DATA_STORE: return (T)data_store; case EA_PARAM_PROP_DESC: - return (T)desc; + ConvertBasic::StringToType(desc, _out); + return _out; case EA_PARAM_PROP_LOG_LEVEL: return (T)log_level; case EA_PARAM_PROP_NAME: - return (T)name; + ConvertBasic::StringToType(name, _out); + return _out; case EA_PARAM_PROP_RISK_MARGIN_MAX: return (T)risk_margin_max; case EA_PARAM_PROP_SIGNAL_FILTER: return (T)signal_filter; case EA_PARAM_PROP_SYMBOL: - return (T)symbol; + ConvertBasic::StringToType(symbol, _out); + return _out; case EA_PARAM_PROP_VER: - return (T)ver; + ConvertBasic::StringToType(ver, _out); + return _out; } SetUserError(ERR_INVALID_PARAMETER); return (T)WRONG_VALUE; @@ -145,7 +151,7 @@ struct EAParams { return (T)task_init; } SetUserError(ERR_INVALID_PARAMETER); - T _empty(); + T _empty; return _empty; } // Setters. diff --git a/Indicator/IndicatorData.h b/Indicator/IndicatorData.h index 5289778ee..4b1f0e083 100644 --- a/Indicator/IndicatorData.h +++ b/Indicator/IndicatorData.h @@ -562,6 +562,25 @@ class IndicatorData : public IndicatorBase { return _is_valid; } +#ifdef __cplusplus + template + bool CopyValues(FIXED_ARRAY_REF(T, _data, size), int _count, int _start_shift = 0, int _mode = 0) { + bool _is_valid = true; + if (size < _count) { + Alert("Error: CopyValues(): Provided _count = ", IntegerToString(_count), " is too much for fixed array of size ", + IntegerToString(size)); + return false; + } + for (int i = 0; i < _count; i++) { + IndicatorDataEntry _entry = GetEntry(_start_shift + i); + _is_valid &= _entry.IsValid(); + _data[i] = (T)_entry[_mode]; + } + return _is_valid; + } + +#endif + /* Getters */ int GetBarsCalculated() { return GetBars(); } diff --git a/Serializer/SerializerNodeParam.h b/Serializer/SerializerNodeParam.h index 14a7268fd..8d6c27616 100644 --- a/Serializer/SerializerNodeParam.h +++ b/Serializer/SerializerNodeParam.h @@ -158,7 +158,11 @@ class SerializerNodeParam { * Returns stringified version of the value. Note "forceQuotesOnString" flag. */ string AsString(bool includeQuotes = false, bool forceQuotesOnString = true, bool escapeString = true, - int _fp_precision = 8) { + int _fp_precision = -1) { + if (_fp_precision == -1) { + _fp_precision = GetFloatingPointPrecision(); + } + switch (_type) { case SerializerNodeParamBool: return SerializerConversions::ValueToString(_integral._bool, includeQuotes, escapeString, _fp_precision); diff --git a/Storage/Dict/DictIteratorBase.h b/Storage/Dict/DictIteratorBase.h index 4714239ab..c9ac08fbf 100644 --- a/Storage/Dict/DictIteratorBase.h +++ b/Storage/Dict/DictIteratorBase.h @@ -93,7 +93,14 @@ class DictIteratorBase { K Key() { CheckValidity(); - return PTR_ATTRIB(_dict, GetMode()) == DictModeList ? (K)_slotIdx : _dict PTR_DEREF GetSlot(_slotIdx) PTR_DEREF key; + + if (PTR_ATTRIB(_dict, GetMode()) == DictModeList) { + K _key; + ConvertBasic::LongToType(_slotIdx, _key); + return _key; + } + + return _dict PTR_DEREF GetSlot(_slotIdx) PTR_DEREF key; } string KeyAsString(bool includeQuotes = false) { diff --git a/Storage/Dict/DictStruct.h b/Storage/Dict/DictStruct.h index 08981389b..6b73ebc55 100644 --- a/Storage/Dict/DictStruct.h +++ b/Storage/Dict/DictStruct.h @@ -444,7 +444,7 @@ class DictStruct : public DictBase { SerializerNodeType Serialize(Serializer& s) { if (s.IsWriting()) { for (DictIteratorBase i(Begin()); i.IsValid(); ++i) - s.PassObject(this, THIS_ATTR GetMode() == DictModeDict ? i.KeyAsString() : "", i.Value()); + s.PassObject(THIS_REF, THIS_ATTR GetMode() == DictModeDict ? i.KeyAsString() : "", i.Value()); return (THIS_ATTR GetMode() == DictModeDict) ? SerializerNodeObject : SerializerNodeArray; } else { diff --git a/Trade.struct.h b/Trade.struct.h index c959c1e94..40d48d3a4 100644 --- a/Trade.struct.h +++ b/Trade.struct.h @@ -213,22 +213,22 @@ struct TradeParams { void Set(ENUM_TRADE_PARAM _param, T _value) { switch (_param) { case TRADE_PARAM_BARS_MIN: - bars_min = (unsigned short)_value; + ConvertBasic::Convert(_value, bars_min); return; case TRADE_PARAM_LOT_SIZE: - lot_size = (float)_value; + ConvertBasic::Convert(_value, lot_size); return; case TRADE_PARAM_MAGIC_NO: - magic_no = (uint64)_value; + ConvertBasic::Convert(_value, magic_no); return; case TRADE_PARAM_ORDER_COMMENT: - order_comment = SerializerConversions::ValueToString(_value); + ConvertBasic::Convert(SerializerConversions::ValueToString(_value), order_comment); return; case TRADE_PARAM_RISK_MARGIN: - risk_margin = (float)_value; + ConvertBasic::Convert(_value, risk_margin); return; case TRADE_PARAM_SLIPPAGE: - slippage = (unsigned int)_value; + ConvertBasic::Convert(_value, slippage); return; default: break; diff --git a/Trade/TradeSignal.struct.h b/Trade/TradeSignal.struct.h index 76d171b89..5ccc55c6b 100644 --- a/Trade/TradeSignal.struct.h +++ b/Trade/TradeSignal.struct.h @@ -156,7 +156,7 @@ struct TradeSignalEntry { strength = (float)_value; return; case TRADE_SIGNAL_PROP_TF: - tf = (ENUM_TIMEFRAMES)_value; + tf = (ENUM_TIMEFRAMES)(int)_value; return; case TRADE_SIGNAL_PROP_TIME: timestamp = (int64)_value; From 4dffc63748bdb4b5692fe9d487de4c44c04ed237 Mon Sep 17 00:00:00 2001 From: Adrian Kierzkowski Date: Fri, 14 Jul 2023 18:55:30 +0200 Subject: [PATCH 23/26] C++ and MQL fixes. Cleaned up Std.h regarding array/reference macros. Added Visual Studio file exclusions into .gitignore. --- .gitignore | 4 + Bar.struct.h | 2 +- Convert.basic.h | 2 +- Pattern.struct.h | 37 ++++++++ Platform/Chart/Chart.struct.static.h | 2 +- Platform/Chart/Chart.symboltf.h | 4 +- Platform/Chart/ChartBase.h | 2 +- Platform/Chart/ChartMt.h | 4 +- Platform/Platform.extern.h | 2 +- Platform/Platform.h | 12 +-- Std.h | 137 ++++++++++++++++++--------- Storage/Objects.h | 4 +- Trade.struct.h | 6 +- 13 files changed, 154 insertions(+), 64 deletions(-) diff --git a/.gitignore b/.gitignore index d21efcaed..d689d2162 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,7 @@ docs/api/build .DS_Store docs/build +.vs +x64 +*.sln +*.vcx* diff --git a/Bar.struct.h b/Bar.struct.h index fe55530d2..e7c649bd9 100644 --- a/Bar.struct.h +++ b/Bar.struct.h @@ -70,7 +70,7 @@ struct BarOHLC low = fmin(low, _prices[i]); } } - BarOHLC(CONST_ARRAY_REF(double, _prices, 4), datetime _time = 0) : time(_time) { + BarOHLC(CONST_FIXED_ARRAY_REF(double, _prices, 4), datetime _time = 0) : time(_time) { _time = _time == (datetime)0 ? TimeCurrent() : _time; int _size = 4; close = _prices[0]; diff --git a/Convert.basic.h b/Convert.basic.h index bd208e044..fcec38b90 100644 --- a/Convert.basic.h +++ b/Convert.basic.h @@ -196,7 +196,7 @@ class ConvertBasic { } template - static T Convert(CONST_REF_TO(string) _value, T& _out) { + static T Convert(CONST_REF_TO_SIMPLE(string) _value, T& _out) { StringToType(_value, _out); return _out; } diff --git a/Pattern.struct.h b/Pattern.struct.h index 97c756d28..8191780e7 100644 --- a/Pattern.struct.h +++ b/Pattern.struct.h @@ -302,12 +302,15 @@ struct PatternCandle2 : PatternCandle { SetPattern(_enum, CheckPattern(_enum, _c)); } } +#ifndef __MQL__ + // In MQL we use non-fixed-array constructor. PatternCandle2(CONST_FIXED_ARRAY_REF(BarOHLC, _c, 8)) : PatternCandle(PATTERN_2CANDLE_NONE) { for (int i = 0; i < sizeof(int) * 8; i++) { ENUM_PATTERN_2CANDLE _enum = (ENUM_PATTERN_2CANDLE)(1 << i); SetPattern(_enum, CheckPattern(_enum, _c)); } } +#endif // Calculation methods. static bool CheckPattern(ENUM_PATTERN_2CANDLE _enum, CONST_ARRAY_REF(BarOHLC, _c)) { switch (_enum) { @@ -417,12 +420,15 @@ struct PatternCandle3 : PatternCandle { SetPattern(_enum, CheckPattern(_enum, _c)); } } +#ifndef __MQL__ + // In MQL we use non-fixed-array constructor. PatternCandle3(CONST_FIXED_ARRAY_REF(BarOHLC, _c, 8)) : PatternCandle(PATTERN_3CANDLE_NONE) { for (int i = 0; i < sizeof(int) * 8; i++) { ENUM_PATTERN_3CANDLE _enum = (ENUM_PATTERN_3CANDLE)(1 << i); SetPattern(_enum, CheckPattern(_enum, _c)); } } +#endif // Calculation methods. static bool CheckPattern(ENUM_PATTERN_3CANDLE _enum, CONST_ARRAY_REF(BarOHLC, _c)) { switch (_enum) { @@ -539,12 +545,15 @@ struct PatternCandle4 : PatternCandle { SetPattern(_enum, CheckPattern(_enum, _c)); } } +#ifndef __MQL__ + // In MQL we use non-fixed-array constructor. PatternCandle4(CONST_FIXED_ARRAY_REF(BarOHLC, _c, 8)) : PatternCandle(PATTERN_4CANDLE_NONE) { for (int i = 0; i < sizeof(int) * 8; i++) { ENUM_PATTERN_4CANDLE _enum = (ENUM_PATTERN_4CANDLE)(1 << i); SetPattern(_enum, CheckPattern(_enum, _c)); } } +#endif // Calculation methods. static bool CheckPattern(ENUM_PATTERN_4CANDLE _enum, CONST_ARRAY_REF(BarOHLC, _c)) { PatternCandle3 _c3(_c); @@ -711,12 +720,16 @@ struct PatternCandle5 : PatternCandle { SetPattern(_enum, CheckPattern(_enum, _c)); } } +#ifndef __MQL__ + // In MQL we use non-fixed-array constructor. PatternCandle5(CONST_FIXED_ARRAY_REF(BarOHLC, _c, 8)) : PatternCandle(PATTERN_5CANDLE_NONE) { for (int i = 0; i < sizeof(int) * 8; i++) { ENUM_PATTERN_5CANDLE _enum = (ENUM_PATTERN_5CANDLE)(1 << i); SetPattern(_enum, CheckPattern(_enum, _c)); } } +#endif + // Calculation methods. static bool CheckPattern(ENUM_PATTERN_5CANDLE _enum, CONST_ARRAY_REF(BarOHLC, _c)) { switch (_enum) { @@ -868,12 +881,16 @@ struct PatternCandle6 : PatternCandle { SetPattern(_enum, CheckPattern(_enum, _c)); } } +#ifndef __MQL__ + // In MQL we use non-fixed-array constructor. PatternCandle6(CONST_FIXED_ARRAY_REF(BarOHLC, _c, 8)) : PatternCandle(PATTERN_6CANDLE_NONE) { for (int i = 0; i < sizeof(int) * 8; i++) { ENUM_PATTERN_6CANDLE _enum = (ENUM_PATTERN_6CANDLE)(1 << i); SetPattern(_enum, CheckPattern(_enum, _c)); } } +#endif + // Calculation methods. static bool CheckPattern(ENUM_PATTERN_6CANDLE _enum, CONST_ARRAY_REF(BarOHLC, _c)) { switch (_enum) { @@ -893,12 +910,16 @@ struct PatternCandle7 : PatternCandle { SetPattern(_enum, CheckPattern(_enum, _c)); } } +#ifndef __MQL__ + // In MQL we use non-fixed-array constructor. PatternCandle7(CONST_FIXED_ARRAY_REF(BarOHLC, _c, 8)) : PatternCandle(PATTERN_7CANDLE_NONE) { for (int i = 0; i < sizeof(int) * 8; i++) { ENUM_PATTERN_7CANDLE _enum = (ENUM_PATTERN_7CANDLE)(1 << i); SetPattern(_enum, CheckPattern(_enum, _c)); } } +#endif + // Calculation methods. static bool CheckPattern(ENUM_PATTERN_7CANDLE _enum, CONST_ARRAY_REF(BarOHLC, _c)) { switch (_enum) { @@ -918,12 +939,16 @@ struct PatternCandle8 : PatternCandle { SetPattern(_enum, CheckPattern(_enum, _c)); } } +#ifndef __MQL__ + // In MQL we use non-fixed-array constructor. PatternCandle8(CONST_FIXED_ARRAY_REF(BarOHLC, _c, 8)) : PatternCandle(PATTERN_8CANDLE_NONE) { for (int i = 0; i < sizeof(int) * 8; i++) { ENUM_PATTERN_8CANDLE _enum = (ENUM_PATTERN_8CANDLE)(1 << i); SetPattern(_enum, CheckPattern(_enum, _c)); } } +#endif + // Calculation methods. static bool CheckPattern(ENUM_PATTERN_8CANDLE _enum, CONST_ARRAY_REF(BarOHLC, _c)) { switch (_enum) { @@ -943,12 +968,16 @@ struct PatternCandle9 : PatternCandle { SetPattern(_enum, CheckPattern(_enum, _c)); } } +#ifndef __MQL__ + // In MQL we use non-fixed-array constructor. PatternCandle9(CONST_FIXED_ARRAY_REF(BarOHLC, _c, 8)) : PatternCandle(PATTERN_9CANDLE_NONE) { for (int i = 0; i < sizeof(int) * 8; i++) { ENUM_PATTERN_9CANDLE _enum = (ENUM_PATTERN_9CANDLE)(1 << i); SetPattern(_enum, CheckPattern(_enum, _c)); } } +#endif + // Calculation methods. static bool CheckPattern(ENUM_PATTERN_9CANDLE _enum, CONST_ARRAY_REF(BarOHLC, _c)) { switch (_enum) { @@ -968,12 +997,16 @@ struct PatternCandle10 : PatternCandle { SetPattern(_enum, CheckPattern(_enum, _c)); } } +#ifndef __MQL__ + // In MQL we use non-fixed-array constructor. PatternCandle10(CONST_FIXED_ARRAY_REF(BarOHLC, _c, 8)) : PatternCandle(PATTERN_10CANDLE_NONE) { for (int i = 0; i < sizeof(int) * 8; i++) { ENUM_PATTERN_10CANDLE _enum = (ENUM_PATTERN_10CANDLE)(1 << i); SetPattern(_enum, CheckPattern(_enum, _c)); } } +#endif + // Calculation methods. static bool CheckPattern(ENUM_PATTERN_10CANDLE _enum, CONST_ARRAY_REF(BarOHLC, _c)) { switch (_enum) { @@ -1019,6 +1052,8 @@ struct PatternEntry { pattern8(_c), pattern9(_c), pattern10(_c) {} +#ifndef __MQL__ + // In MQL we use non-fixed-array constructor. PatternEntry(FIXED_ARRAY_REF(BarOHLC, _c, 8)) : pattern1(_c[0]), pattern2(_c), @@ -1030,6 +1065,8 @@ struct PatternEntry { pattern8(_c), pattern9(_c), pattern10(_c) {} +#endif + // Operator methods. unsigned int operator[](const int _index) const { switch (_index) { diff --git a/Platform/Chart/Chart.struct.static.h b/Platform/Chart/Chart.struct.static.h index fae59fb87..ba9c086fa 100644 --- a/Platform/Chart/Chart.struct.static.h +++ b/Platform/Chart/Chart.struct.static.h @@ -325,7 +325,7 @@ struct ChartStatic { * * If local history is empty (not loaded), function returns 0. */ - static datetime GetBarTime(CONST_REF_TO(string) _symbol, ENUM_TIMEFRAMES _tf, unsigned int _shift = 0) { + static datetime GetBarTime(CONST_REF_TO_SIMPLE(string) _symbol, ENUM_TIMEFRAMES _tf, unsigned int _shift = 0) { #ifdef __MQL4__ datetime _time = ::iTime(_symbol, _tf, _shift); // Same as: Time[_shift] diff --git a/Platform/Chart/Chart.symboltf.h b/Platform/Chart/Chart.symboltf.h index 9fbb59e20..29a82e6bc 100644 --- a/Platform/Chart/Chart.symboltf.h +++ b/Platform/Chart/Chart.symboltf.h @@ -42,8 +42,8 @@ struct SymbolTf { const ENUM_TIMEFRAMES tf; const string symbol_tf_key; - CONST_REF_TO(string) Key() const { return symbol_tf_key; } - CONST_REF_TO(string) Symbol() const { return symbol; } + RETURN_REF_TO_SIMPLE(string) Key() const { return symbol_tf_key; } + RETURN_REF_TO_SIMPLE(string) Symbol() const { return symbol; } ENUM_TIMEFRAMES Tf() const { return tf; } SymbolTf(string _symbol, ENUM_TIMEFRAMES _tf) diff --git a/Platform/Chart/ChartBase.h b/Platform/Chart/ChartBase.h index cf3b939c7..1b4a049c7 100644 --- a/Platform/Chart/ChartBase.h +++ b/Platform/Chart/ChartBase.h @@ -133,7 +133,7 @@ class ChartBase : public Dynamic { /** * Return symbol bound to chart. */ - CONST_REF_TO(string) GetSymbol() { return cparams.Get(CHART_PARAM_SYMBOL); } + CONST_REF_TO_SIMPLE(string) GetSymbol() { return cparams.Get(CHART_PARAM_SYMBOL); } /** * Return time-frame bound to chart. diff --git a/Platform/Chart/ChartMt.h b/Platform/Chart/ChartMt.h index 6dc74488e..d98b4c8e1 100644 --- a/Platform/Chart/ChartMt.h +++ b/Platform/Chart/ChartMt.h @@ -300,6 +300,8 @@ struct ChartBarTime { ChartBarTime() : symbol_tf(Symbol(), PERIOD_CURRENT) {} datetime operator[](const int _shift) const { return Get(symbol_tf, _shift); } static datetime Get(const SymbolTf& _symbol_tf, const int _shift) { - return ChartStatic::GetBarTime(_symbol_tf.Symbol(), _symbol_tf.Tf(), _shift); + string _symbol = _symbol_tf.Symbol(); + ENUM_TIMEFRAMES _tf = _symbol_tf.Tf(); + return ChartStatic::GetBarTime(_symbol, _tf, _shift); } }; diff --git a/Platform/Platform.extern.h b/Platform/Platform.extern.h index 538725218..f5b62bd7f 100644 --- a/Platform/Platform.extern.h +++ b/Platform/Platform.extern.h @@ -59,7 +59,7 @@ extern void Alert(string argument); /** * Returns number of candles for a given symbol and time-frame. */ -extern int Bars(CONST_REF_TO(string) _symbol, ENUM_TIMEFRAMES _tf); +extern int Bars(CONST_REF_TO_SIMPLE(string) _symbol, ENUM_TIMEFRAMES _tf); /** * Returns the number of calculated data for the specified indicator. diff --git a/Platform/Platform.h b/Platform/Platform.h index 9fbbc7ae9..4890e377c 100644 --- a/Platform/Platform.h +++ b/Platform/Platform.h @@ -36,7 +36,7 @@ /** * Returns number of candles for a given symbol and time-frame. */ -extern int Bars(CONST_REF_TO(string) _symbol, ENUM_TIMEFRAMES _tf); +extern int Bars(CONST_REF_TO_SIMPLE(string) _symbol, ENUM_TIMEFRAMES _tf); #endif @@ -197,7 +197,7 @@ class Platform { /** * Adds indicator to be processed by platform and tries to initialize its data source(s). */ - static void AddWithDefaultBindings(IndicatorData *_indi, CONST_REF_TO(string) _symbol, ENUM_TIMEFRAMES _tf) { + static void AddWithDefaultBindings(IndicatorData *_indi, string _symbol, ENUM_TIMEFRAMES _tf) { Add(_indi); BindDefaultDataSource(_indi, _symbol, _tf); } @@ -255,7 +255,7 @@ class Platform { /** * Returns number of candles for a given symbol and time-frame. */ - static int Bars(CONST_REF_TO(string) _symbol, ENUM_TIMEFRAMES _tf) { + static int Bars(CONST_REF_TO_SIMPLE(string) _symbol, ENUM_TIMEFRAMES _tf) { Print("Not yet implemented: ", __FUNCTION__, " returns 0."); return 0; } @@ -282,7 +282,7 @@ class Platform { * Note that some indicators may work on custom set of buffers required from data source and not on Candle or Tick * indicator. */ - static void BindDefaultDataSource(IndicatorData *_indi, CONST_REF_TO(string) _symbol, ENUM_TIMEFRAMES _tf) { + static void BindDefaultDataSource(IndicatorData *_indi, CONST_REF_TO_SIMPLE(string) _symbol, ENUM_TIMEFRAMES _tf) { Flags _suitable_ds_types = _indi PTR_DEREF GetSuitableDataSourceTypes(); IndicatorData *_default_indi_candle = FetchDefaultCandleIndicator(_symbol, _tf); @@ -383,7 +383,7 @@ class Platform { /** * Returns default properties for given symbol for current platform. */ - static SymbolInfoProp FetchDefaultSymbolProps(CONST_REF_TO(string) _symbol) { + static SymbolInfoProp FetchDefaultSymbolProps(CONST_REF_TO_SIMPLE(string) _symbol) { SymbolInfoProp props; #ifdef __MQLBUILD__ props.pip_value = SymbolInfoStatic::GetPipValue(_symbol); @@ -502,7 +502,7 @@ DictStruct> Platform::indis_dflt; /** * Returns number of candles for a given symbol and time-frame. */ -int Bars(CONST_REF_TO(string) _symbol, ENUM_TIMEFRAMES _tf) { return Platform::Bars(_symbol, _tf); } +int Bars(CONST_REF_TO_SIMPLE(string) _symbol, ENUM_TIMEFRAMES _tf) { return Platform::Bars(_symbol, _tf); } /** * Returns the number of calculated data for the specified indicator. diff --git a/Std.h b/Std.h index a27bef3b4..caa222a15 100644 --- a/Std.h +++ b/Std.h @@ -79,84 +79,129 @@ #define VOID_DATA(N) void* N #endif -// References. -#ifdef __cplusplus -#define REF(X) (&X) -#else +// Reference to simple type like bool, int, double, string. +#ifdef __MQL__ #define REF(X) X& +#else +#define REF(X) (&X) #endif // Arrays and references to arrays. #define _COMMA , + +// Reference to object. #ifdef __MQL__ -#define ARRAY_DECLARATION_BRACKETS [] +#define REF_TO(T) T* #else -// C++'s _cpp_array is an object, so no brackets are needed. -#define ARRAY_DECLARATION_BRACKETS +#define REF_TO(T) T& #endif +// Const reference to object. +#define CONST_REF_TO(T) const REF_TO(T) + +// Reference to simple type like bool, int, double, string. +#define REF_TO_SIMPLE(T) T& + +// Const reference to simple type like bool, int, double, string. +#define CONST_REF_TO_SIMPLE(T) const REF_TO_SIMPLE(T) + +// Returning type for methods that returns simple types as int, double, string. #ifdef __MQL__ -/** - * Reference to object. - */ +#define RETURN_REF_TO_SIMPLE(T) T +#else +#define RETURN_REF_TO_SIMPLE(T) T& +#endif -#define REF_TO(T) T* -#define CONST_REF_TO(T) const REF_TO(T) +// Returning type for methods that returns simple contstant types as int, double, string. +#define RETURN_CONST_REF_TO_SIMPLE(T) const RETURN_REF_TO_SIMPLE(T) + +// Casts reference to object to given type. +#ifdef __MQL__ #define REF_CAST(T) (T*) +#else +#define REF_CAST(T) (T&) +#endif /** - * Reference to the array. - * - * @usage - * ARRAY_REF(, ) + * Type of the array. + * T = Type of the array items. + * Example: ARRAY_TYPE(int) items; ArrayPush(items, 1); */ +#ifdef __MQL__ #define ARRAY_TYPE(T) T[] -#define ARRAY_REF(T, N) REF(T) N ARRAY_DECLARATION_BRACKETS -#define FIXED_ARRAY_REF(T, N, S) ARRAY_REF(T, N) - -#define CONST_ARRAY_REF(T, N) const N ARRAY_DECLARATION_BRACKETS +#else +#define ARRAY_TYPE(T) _cpp_array +#endif /** - * Array definition. - * - * @usage - * ARRAY(, ) + * Declaration of the array of given type and name. + * T = Type of the array items. + * N = Name of the array. + * Example: ARRAY(int, items); ArrayPush(items, 1); */ +#ifdef __MQL__ #define ARRAY(T, N) T N[] -#define FIXED_ARRAY(T, N, SIZE) T N[SIZE] - -#define CONST_FIXED_ARRAY_REF(T, N, S) const FIXED_ARRAY_REF(T, N, S) +#else +#define ARRAY(T, N) ::_cpp_array N +#endif +/** + * Reference to the array of given type and name. + * T = Type of the array items. + * N = Name of the array. + * Example: void Append(ARRAY_REF(int, values)); + */ +#ifdef __MQL__ +#define ARRAY_REF(T, N) REF(T) N[] #else +#define ARRAY_REF(T, N) ARRAY_TYPE(T) & N +#endif + /** - * Reference to object. + * Reference to the constant array of given type and name. + * T = Type of the array items. + * N = Name of the array. + * Example: void Append(CONST_ARRAY_REF(int, values)); */ -#define REF_TO(T) T& -#define CONST_REF_TO(T) const REF_TO(T) -#define REF_CAST(T) (T&) +#ifdef __MQL__ +#define CONST_ARRAY_REF(T, N) const T& N[] +#else +#define CONST_ARRAY_REF(T, N) const _cpp_array& N +#endif /** + * Declaration of the array of given type, name and fixed size. + * T = Type of the array items. + * N = Name of the array. + * S = Fixed size of the array. + * Example: FIXED_ARRAY(int, values, 1); values[0] = 1; + */ +#define FIXED_ARRAY(T, N, SIZE) T N[SIZE] - * Reference to the array. - * - * @usage - * ARRAY_REF(, ) +/** + * Reference to the array of given type and name and fixed size. + * T = Type of the array items. + * N = Name of the array. + * S = Fixed size of the array. + * Example: void Append(FIXED_ARRAY_REF(int, values, 5)); */ -#define ARRAY_TYPE(T) _cpp_array -#define ARRAY_REF(T, N) ARRAY_TYPE(T) & N +#ifdef __MQL__ +#define FIXED_ARRAY_REF(T, N, S) ARRAY_REF(T, N) +#else #define FIXED_ARRAY_REF(T, N, S) T(&N)[S] - -#define CONST_ARRAY_REF(T, N) const _cpp_array& N -#define CONST_FIXED_ARRAY_REF(T, N, S) const FIXED_ARRAY_REF(T, N, S) +#endif /** - * Array definition. - * - * @usage - * ARRAY(, ) + * Reference to the constant array of given type and name and fixed size. + * T = Type of the array items. + * N = Name of the array. + * S = Fixed size of the array. + * Example: void Append(FIXED_ARRAY_REF(int, values, 5)); */ -#define ARRAY(T, N) ::_cpp_array N -#define FIXED_ARRAY(T, N, SIZE) T N[SIZE] +#ifdef __MQL__ +#define CONST_FIXED_ARRAY_REF(T, N, S) const FIXED_ARRAY_REF(T, N, S) +#else +#define CONST_FIXED_ARRAY_REF(T, N, S) const FIXED_ARRAY_REF(T, N, S) #endif // typename(T) diff --git a/Storage/Objects.h b/Storage/Objects.h index 329028333..0b584041d 100644 --- a/Storage/Objects.h +++ b/Storage/Objects.h @@ -48,7 +48,7 @@ class Objects { /** * Tries to retrieve pointer to object for a given key. Returns true if object did exist. */ - static bool TryGet(CONST_REF_TO(string) key, C*& out_ptr) { + static bool TryGet(CONST_REF_TO_SIMPLE(string) key, C*& out_ptr) { unsigned int position; if (!GetObjects() PTR_DEREF KeyExists(key, position)) { out_ptr = NULL; @@ -62,7 +62,7 @@ class Objects { /** * Stores object pointer with a given key. */ - static C* Set(CONST_REF_TO(string) key, C* ptr) { + static C* Set(CONST_REF_TO_SIMPLE(string) key, C* ptr) { Ref _ref(ptr); GetObjects() PTR_DEREF Set(key, _ref); return ptr; diff --git a/Trade.struct.h b/Trade.struct.h index 40d48d3a4..a6cc518cc 100644 --- a/Trade.struct.h +++ b/Trade.struct.h @@ -221,9 +221,11 @@ struct TradeParams { case TRADE_PARAM_MAGIC_NO: ConvertBasic::Convert(_value, magic_no); return; - case TRADE_PARAM_ORDER_COMMENT: - ConvertBasic::Convert(SerializerConversions::ValueToString(_value), order_comment); + case TRADE_PARAM_ORDER_COMMENT: { + string _value_string = SerializerConversions::ValueToString(_value); + ConvertBasic::Convert(_value_string, order_comment); return; + } case TRADE_PARAM_RISK_MARGIN: ConvertBasic::Convert(_value, risk_margin); return; From 5395496beaebe7a8e41fc03aa4218778d72ca575 Mon Sep 17 00:00:00 2001 From: Adrian Kierzkowski Date: Sat, 15 Jul 2023 21:55:02 +0200 Subject: [PATCH 24/26] Looks like C++/MT4 errors are fixed. Need some additional fixed for MT5. --- Convert.basic.h | 6 ++++++ Convert.mqh | 2 +- EA.mqh | 4 ++-- Indicators/Bitwise/Indi_Pattern.mqh | 10 +++++----- Indicators/Indi_Drawer.mqh | 2 +- Indicators/tests/Indi_OHLC.test.cpp | 2 +- Indicators/tests/Indi_Pattern.test.cpp | 2 +- Indicators/tests/Indi_Price.test.cpp | 2 +- Platform/Chart/Chart.symboltf.h | 4 ++-- Platform/Web/Web.h | 1 + Serializer/SerializerSqlite.h | 3 ++- Std.h | 2 +- Storage/Array.extern.h | 8 ++------ Storage/Array.h | 14 ++++++++++++++ Storage/Database.h | 2 +- Storage/Dict/DictBase.h | 2 +- Storage/Dict/DictIteratorBase.h | 3 ++- Storage/ValueStorage.h | 2 +- tests/EATest.mq5 | 2 +- 19 files changed, 46 insertions(+), 27 deletions(-) diff --git a/Convert.basic.h b/Convert.basic.h index fcec38b90..42bb39e78 100644 --- a/Convert.basic.h +++ b/Convert.basic.h @@ -183,6 +183,12 @@ class ConvertBasic { return _out; } + template + static T Convert(int _value, T& _out) { + LongToType((long)_value, _out); + return _out; + } + template static T Convert(int64 _value, T& _out) { LongToType(_value, _out); diff --git a/Convert.mqh b/Convert.mqh index 86abc3ed9..73a235be7 100644 --- a/Convert.mqh +++ b/Convert.mqh @@ -223,7 +223,7 @@ class Convert { * Convert points into price value. */ static double PointsToValue(int64 pts, string _symbol = NULL) { - return PointsToValue(pts, SymbolInfoStatic::SymbolInfoInteger(_symbol, SYMBOL_TRADE_CALC_MODE)); + return PointsToValue(pts, (int)SymbolInfoStatic::SymbolInfoInteger(_symbol, SYMBOL_TRADE_CALC_MODE)); } /** diff --git a/EA.mqh b/EA.mqh index a307aa7a8..d5f2c74d9 100644 --- a/EA.mqh +++ b/EA.mqh @@ -67,8 +67,8 @@ class EA : public Taskable { Dict ddata; // Custom user data. Dict idata; // Custom user data. DictObject trade; - DictObject> data_indi; - DictObject> data_stg; + DictObject> data_indi; + DictObject> data_stg; EAParams eparams; EAProcessResult eresults; EAState estate; diff --git a/Indicators/Bitwise/Indi_Pattern.mqh b/Indicators/Bitwise/Indi_Pattern.mqh index 58b40c201..d00d30f13 100644 --- a/Indicators/Bitwise/Indi_Pattern.mqh +++ b/Indicators/Bitwise/Indi_Pattern.mqh @@ -93,7 +93,7 @@ class Indi_Pattern : public Indicator { int i; int _max_modes = Get(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_MAX_MODES)); - INDI_REQUIRE_SHIFT_OR_RETURN(GetCandle(), ToRelShift(_abs_shift) + _max_modes, WRONG_VALUE); + INDI_REQUIRE_SHIFT_OR_RETURN(GetCandle(), ToRelShift(_abs_shift) + _max_modes, (double)WRONG_VALUE); FIXED_ARRAY(BarOHLC, _ohlcs, 8); @@ -104,7 +104,7 @@ class Indi_Pattern : public Indicator { _ohlcs[i] = GetCandle() PTR_DEREF GetOHLC(ToRelShift(_abs_shift) + i); if (!_ohlcs[i].IsValid()) { // Return empty entry on invalid candles. - return WRONG_VALUE; + return (double)WRONG_VALUE; } } break; @@ -122,7 +122,7 @@ class Indi_Pattern : public Indicator { "SetIndicatorData() " "method, which is a part of PatternParams structure."); SetUserError(ERR_INVALID_PARAMETER); - return WRONG_VALUE; + return (double)WRONG_VALUE; } for (i = 0; i < _max_modes; ++i) { @@ -132,13 +132,13 @@ class Indi_Pattern : public Indicator { _ohlcs[i].close = GetDataSource() PTR_DEREF GetValue(PRICE_CLOSE, ToRelShift(_abs_shift) + i); if (!_ohlcs[i].IsValid()) { // Return empty entry on invalid candles. - return WRONG_VALUE; + return (double)WRONG_VALUE; } } break; default: SetUserError(ERR_INVALID_PARAMETER); - return WRONG_VALUE; + return (double)WRONG_VALUE; } PatternEntry pattern(_ohlcs); return pattern[_mode + 1]; diff --git a/Indicators/Indi_Drawer.mqh b/Indicators/Indi_Drawer.mqh index 75cd23825..61f9890a6 100644 --- a/Indicators/Indi_Drawer.mqh +++ b/Indicators/Indi_Drawer.mqh @@ -166,7 +166,7 @@ class Indi_Drawer : public Indicator { */ } - Redis *Redis() { return &redis; } + Redis *GetRedis() { return &redis; } /** * Returns the indicator value. diff --git a/Indicators/tests/Indi_OHLC.test.cpp b/Indicators/tests/Indi_OHLC.test.cpp index ba42aef26..4ea8c86c3 100644 --- a/Indicators/tests/Indi_OHLC.test.cpp +++ b/Indicators/tests/Indi_OHLC.test.cpp @@ -25,7 +25,7 @@ */ // Includes. -#include "../Indi_OHLC.mqh" +#include "../../Indicators/OHLC/Indi_OHLC.mqh" #include "../../Platform/Platform.h" diff --git a/Indicators/tests/Indi_Pattern.test.cpp b/Indicators/tests/Indi_Pattern.test.cpp index 1828b7ae0..888cbd60c 100644 --- a/Indicators/tests/Indi_Pattern.test.cpp +++ b/Indicators/tests/Indi_Pattern.test.cpp @@ -25,7 +25,7 @@ */ // Includes. -#include "../Indi_Pattern.mqh" +#include "../../Indicators/Bitwise/Indi_Pattern.mqh" #include "../../Platform/Platform.h" diff --git a/Indicators/tests/Indi_Price.test.cpp b/Indicators/tests/Indi_Price.test.cpp index c0cd11094..203d9c372 100644 --- a/Indicators/tests/Indi_Price.test.cpp +++ b/Indicators/tests/Indi_Price.test.cpp @@ -25,7 +25,7 @@ */ // Includes. -#include "../Indi_Price.mqh" +#include "../../Indicators/Price/Indi_Price.h" #include "../../Platform/Platform.h" diff --git a/Platform/Chart/Chart.symboltf.h b/Platform/Chart/Chart.symboltf.h index 29a82e6bc..e3b9c2f9f 100644 --- a/Platform/Chart/Chart.symboltf.h +++ b/Platform/Chart/Chart.symboltf.h @@ -42,8 +42,8 @@ struct SymbolTf { const ENUM_TIMEFRAMES tf; const string symbol_tf_key; - RETURN_REF_TO_SIMPLE(string) Key() const { return symbol_tf_key; } - RETURN_REF_TO_SIMPLE(string) Symbol() const { return symbol; } + RETURN_CONST_REF_TO_SIMPLE(string) Key() const { return symbol_tf_key; } + RETURN_CONST_REF_TO_SIMPLE(string) Symbol() const { return symbol; } ENUM_TIMEFRAMES Tf() const { return tf; } SymbolTf(string _symbol, ENUM_TIMEFRAMES _tf) diff --git a/Platform/Web/Web.h b/Platform/Web/Web.h index fb1e27097..14d8af2aa 100644 --- a/Platform/Web/Web.h +++ b/Platform/Web/Web.h @@ -23,6 +23,7 @@ // Properties. #ifdef __MQL__ #property strict +#else // Allows the preprocessor to include a header file when it is needed. #pragma once #endif diff --git a/Serializer/SerializerSqlite.h b/Serializer/SerializerSqlite.h index 291c468cb..a26500dc1 100644 --- a/Serializer/SerializerSqlite.h +++ b/Serializer/SerializerSqlite.h @@ -80,7 +80,8 @@ class SerializerSqlite { } if (!_db.TableExists(_table)) { - if (!_db.CreateTable(_table, _db.GetTableSchema(_table))) { + DatabaseTableSchema _schema = _db.GetTableSchema(_table); + if (!_db.CreateTable(_table, _schema)) { return false; } } diff --git a/Std.h b/Std.h index caa222a15..60338aae6 100644 --- a/Std.h +++ b/Std.h @@ -99,7 +99,7 @@ // Const reference to object. #define CONST_REF_TO(T) const REF_TO(T) -// Reference to simple type like bool, int, double, string. +// Reference to simple type like bool, int, double, string or structure that is not treated as object by MT. #define REF_TO_SIMPLE(T) T& // Const reference to simple type like bool, int, double, string. diff --git a/Storage/Array.extern.h b/Storage/Array.extern.h index 20cf8635e..963f414e5 100644 --- a/Storage/Array.extern.h +++ b/Storage/Array.extern.h @@ -99,13 +99,9 @@ int ArraySort(ARRAY_REF(T, array)) { } template -void ArrayFill(ARRAY_REF(X, array), int start, int count, X value) { - Array::ArrayFill(array, start, count, value); -} +void ArrayFill(ARRAY_REF(X, array), int start, int count, X value); template -void ArrayFill(FIXED_ARRAY_REF(X, array, size), int start, int count, X value) { - Array::ArrayFill(array, start, count, value); -} +void ArrayFill(FIXED_ARRAY_REF(X, array, size), int start, int count, X value); #endif diff --git a/Storage/Array.h b/Storage/Array.h index 44fa76f47..84aa976a0 100644 --- a/Storage/Array.h +++ b/Storage/Array.h @@ -802,3 +802,17 @@ void ArrayPushObject(ARRAY_REF(X, array), X& value) { ::ArrayResize(array, Array::ArraySize(array) + 1); array[Array::ArraySize(array) - 1] = value; } + +#ifndef __MQL__ + +template +void ArrayFill(ARRAY_REF(X, array), int start, int count, X value) { + Array::ArrayFill(array, start, count, value); +} + +template +void ArrayFill(FIXED_ARRAY_REF(X, array, size), int start, int count, X value) { + Array::ArrayFill(array, start, count, value); +} + +#endif \ No newline at end of file diff --git a/Storage/Database.h b/Storage/Database.h index 4e200832f..3b0d878f4 100644 --- a/Storage/Database.h +++ b/Storage/Database.h @@ -99,7 +99,7 @@ class Database { /** * Creates table. */ - bool CreateTable(string _name, DatabaseTableSchema &_schema) { + bool CreateTable(string _name, REF_TO_SIMPLE(DatabaseTableSchema) _schema) { bool _result = false; #ifndef __MQL4__ if (DatabaseTableExists(handle, _name)) { diff --git a/Storage/Dict/DictBase.h b/Storage/Dict/DictBase.h index 082fbe377..6f0e05659 100644 --- a/Storage/Dict/DictBase.h +++ b/Storage/Dict/DictBase.h @@ -274,7 +274,7 @@ class DictBase { /** * Returns number of used DictSlots. */ - const unsigned int Size() { return _DictSlots_ref._num_used; } + const unsigned int Size() const { return _DictSlots_ref._num_used; } /** * Returns number of all (reserved) DictSlots. diff --git a/Storage/Dict/DictIteratorBase.h b/Storage/Dict/DictIteratorBase.h index c9ac08fbf..a1cee24d3 100644 --- a/Storage/Dict/DictIteratorBase.h +++ b/Storage/Dict/DictIteratorBase.h @@ -29,6 +29,7 @@ template class DictBase; +#include "../../Convert.basic.h" #include "../../Serializer/SerializerConversions.h" #include "DictBase.h" #include "DictSlotsRef.h" @@ -96,7 +97,7 @@ class DictIteratorBase { if (PTR_ATTRIB(_dict, GetMode()) == DictModeList) { K _key; - ConvertBasic::LongToType(_slotIdx, _key); + ConvertBasic::Convert(_slotIdx, _key); return _key; } diff --git a/Storage/ValueStorage.h b/Storage/ValueStorage.h index 7c7707741..36149f164 100644 --- a/Storage/ValueStorage.h +++ b/Storage/ValueStorage.h @@ -83,7 +83,7 @@ enum ENUM_IPEAK { IPEAK_LOWEST, IPEAK_HIGHEST }; * (the one that doesn't exist in the hierarchy). */ #define INDICATOR_CALCULATE_POPULATE_PARAMS_AND_CACHE_SHORT(INDI, APPLIED_PRICE, KEY) \ - ValueStorage *_price_ptr; \ + ValueStorage *_price_ptr = nullptr; \ if (INDI PTR_DEREF GetSuitableDataSource() PTR_DEREF HasSpecificAppliedPriceValueStorage(APPLIED_PRICE, INDI)) { \ _price_ptr = \ INDI PTR_DEREF GetSuitableDataSource() PTR_DEREF GetSpecificAppliedPriceValueStorage(APPLIED_PRICE, INDI); \ diff --git a/tests/EATest.mq5 b/tests/EATest.mq5 index 777b518c4..b8d14d5c2 100644 --- a/tests/EATest.mq5 +++ b/tests/EATest.mq5 @@ -28,8 +28,8 @@ struct DataParamEntry; // Includes. -#include "../Exchange/Account/Account.struct.h" #include "../EA.mqh" +#include "../Exchange/Account/Account.struct.h" #include "../Test.mqh" // Defines EA classes. From bc351cc4caab34e4dd8de46dd2eaaff42052cfae Mon Sep 17 00:00:00 2001 From: Adrian Kierzkowski Date: Sun, 16 Jul 2023 14:12:25 +0200 Subject: [PATCH 25/26] Looks like C++/MT4/MT5 errors are fixed. --- Exchange/SymbolInfo/SymbolInfo.h | 3 +++ Math/Math.h | 16 +++++++++++++++- Serializer/SerializerSqlite.h | 2 +- Stats.mqh | 2 +- Storage/Database.h | 20 ++++++++++---------- Storage/Database.struct.h | 2 +- Storage/Dict/Buffer/BufferStruct.h | 3 +++ Strategy.mqh | 1 + 8 files changed, 35 insertions(+), 14 deletions(-) diff --git a/Exchange/SymbolInfo/SymbolInfo.h b/Exchange/SymbolInfo/SymbolInfo.h index 2b3d5bc36..f4887aa93 100644 --- a/Exchange/SymbolInfo/SymbolInfo.h +++ b/Exchange/SymbolInfo/SymbolInfo.h @@ -25,6 +25,9 @@ #pragma once #endif +// Flag for Database.struct.h so SymbolInfo structure will be supported by it. +#define DATABASE_INCLUDE_SYMBOLINFO_STRUCT + // Includes symbol defines, enums and structs. #include "SymbolInfo.define.h" #include "SymbolInfo.enum.h" diff --git a/Math/Math.h b/Math/Math.h index 5df7476b2..4dc2735f5 100644 --- a/Math/Math.h +++ b/Math/Math.h @@ -26,8 +26,8 @@ #endif // Includes. -#include "../Storage/Data.struct.h" #include "../Indicator/Indicator.struct.h" +#include "../Storage/Data.struct.h" #include "Math.define.h" #include "Math.enum.h" #include "Math.extern.h" @@ -265,3 +265,17 @@ class Math { } } }; + +#ifdef __MQL__ + +/** + * Specialization of MQL's Round() to support int64 input. + */ +int64 MathRound(int64 _value) { return _value; } + +/** + * Specialization of MQL's round() to support int64 input. + */ +int64 round(int64 _value) { return MathRound(_value); } + +#endif \ No newline at end of file diff --git a/Serializer/SerializerSqlite.h b/Serializer/SerializerSqlite.h index a26500dc1..c087c93a8 100644 --- a/Serializer/SerializerSqlite.h +++ b/Serializer/SerializerSqlite.h @@ -86,7 +86,7 @@ class SerializerSqlite { } } - if (!_db.ImportData(_table, _matrix_out)) { + if (!_db.Import(_table, _matrix_out)) { return false; } diff --git a/Stats.mqh b/Stats.mqh index 14c455844..7b95ff564 100644 --- a/Stats.mqh +++ b/Stats.mqh @@ -98,7 +98,7 @@ class Stats { /** * Get number of ticks per second. */ - double GetTicksPerSec() { return round(total_bars > 0 ? (total_ticks / total_bars / curr_period) / 60 : 0); } + uint64 GetTicksPerSec() { return round(total_bars > 0 ? (total_ticks / total_bars / curr_period) / 60 : 0); } /** * Get number of ticks per given time period. diff --git a/Storage/Database.h b/Storage/Database.h index 3b0d878f4..5a59b3426 100644 --- a/Storage/Database.h +++ b/Storage/Database.h @@ -49,13 +49,13 @@ class Database { /** * Class constructor. */ -#ifndef __MQL4__ +#ifdef __MQL5__ Database(string _filename, unsigned int _flags = DATABASE_OPEN_CREATE) #else Database(string _filename, unsigned int _flags = 0) #endif { -#ifndef __MQL4__ +#ifdef __MQL5__ handle = DatabaseOpen(_filename, _flags); #else handle = -1; @@ -67,7 +67,7 @@ class Database { * Class deconstructor. */ ~Database() { -#ifndef __MQL4__ +#ifdef __MQL5__ DatabaseClose(handle); #endif } @@ -78,7 +78,7 @@ class Database { * Checks if table exists. */ bool TableExists(string _name) { -#ifndef __MQL4__ +#ifdef __MQL5__ return DatabaseTableExists(handle, _name); #else SetUserError(ERR_USER_NOT_SUPPORTED); @@ -101,7 +101,7 @@ class Database { */ bool CreateTable(string _name, REF_TO_SIMPLE(DatabaseTableSchema) _schema) { bool _result = false; -#ifndef __MQL4__ +#ifdef __MQL5__ if (DatabaseTableExists(handle, _name)) { // Generic error (ERR_DATABASE_ERROR). SetUserError(5601); @@ -145,7 +145,7 @@ class Database { */ bool DropTable(string _name) { tables.Unset(_name); -#ifndef __MQL4__ +#ifdef __MQL5__ return DatabaseExecute(handle, "DROP TABLE IF EXISTS `" + _name + "`"); #else return false; @@ -157,7 +157,7 @@ class Database { /** * Imports data into table. First row must contain column names. Strings must be enclosed with double quotes. */ - bool ImportData(const string _name, MatrixMini2d &data) { + bool Import(const string _name, MatrixMini2d &data) { if (data.SizeY() < 2 || data.SizeX() == 0) { // No data to import or there are no columns in input data (Serialize() serialized no fields). return true; @@ -171,7 +171,7 @@ class Database { _cols += "`" + StringSubstr(key, 1, StringLen(key) - 2) + "`,"; } _cols = StringSubstr(_cols, 0, StringLen(_cols) - 1); // Removes extra comma. -#ifndef __MQL4__ +#ifdef __MQL5__ if (DatabaseTransactionBegin(handle)) { _query = StringFormat("INSERT INTO `%s`(%s) VALUES\n", _name, _cols); for (int y = 1; y < data.SizeY(); ++y) { @@ -201,7 +201,7 @@ class Database { return _result; } -#ifdef BUFFER_STRUCT_H +#ifdef DATABASE_INCLUDE_BUFFER_STRUCT /** * Imports BufferStruct records into a table. */ @@ -214,7 +214,7 @@ class Database { _cols += iter.Value().name + ","; } _cols = StringSubstr(_cols, 0, StringLen(_cols) - 1); // Removes extra comma. -#ifndef __MQL4__ +#ifdef __MQL5__ if (DatabaseTransactionBegin(handle)) { for (DictStructIterator iter = _bstruct.Begin(); iter.IsValid(); ++iter) { _query = StringFormat("INSERT INTO %s(%s) VALUES (%s)", _name, _cols, iter.Value().ToCSV()); diff --git a/Storage/Database.struct.h b/Storage/Database.struct.h index e3c216401..9e380446c 100644 --- a/Storage/Database.struct.h +++ b/Storage/Database.struct.h @@ -93,7 +93,7 @@ struct DatabaseTableSchema { }; // Struct table entry for SymbolInfo. -#ifdef SYMBOLINFO_H +#ifdef DATABASE_INCLUDE_SYMBOLINFO_STRUCT struct DbSymbolInfoEntry : public SymbolInfoEntry { DatabaseTableSchema schema; // Constructors. diff --git a/Storage/Dict/Buffer/BufferStruct.h b/Storage/Dict/Buffer/BufferStruct.h index e38de8b08..0e8d3645b 100644 --- a/Storage/Dict/Buffer/BufferStruct.h +++ b/Storage/Dict/Buffer/BufferStruct.h @@ -25,6 +25,9 @@ #pragma once #endif +// Flag for Database.struct.h so BufferStruct structure will be supported by it. +#define DATABASE_INCLUDE_BUFFER_STRUCT + // Includes. #include "../../../Serializer/Serializer.h" #include "../DictBase.h" diff --git a/Strategy.mqh b/Strategy.mqh index b322ff805..446edb004 100644 --- a/Strategy.mqh +++ b/Strategy.mqh @@ -30,6 +30,7 @@ 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" From 5ccbf9631d82a13bfc9851fe8525d9cf742f9ab7 Mon Sep 17 00:00:00 2001 From: Adrian Kierzkowski Date: Mon, 17 Jul 2023 16:12:25 +0200 Subject: [PATCH 26/26] More of C++/MT4/MT5 error fixes. --- Indicators/Indi_Drawer.mqh | 4 +- Log.mqh | 3 +- Math/Math.define.h | 7 + Math/Math.extern.h | 28 ++- Math/Math.h | 287 ++++++++++++++++++++++++++++- Math/Math.normal.h | 92 +++++++++ Math/Matrix.h | 17 +- Platform/Chart/Chart.struct.h | 3 +- Platform/Platform.enum.h | 2 +- Serializer/SerializerConversions.h | 1 - Storage/Array.h | 2 +- 11 files changed, 423 insertions(+), 23 deletions(-) create mode 100644 Math/Math.normal.h diff --git a/Indicators/Indi_Drawer.mqh b/Indicators/Indi_Drawer.mqh index 61f9890a6..bd8ce5789 100644 --- a/Indicators/Indi_Drawer.mqh +++ b/Indicators/Indi_Drawer.mqh @@ -98,8 +98,8 @@ class Indi_Drawer : public Indicator { Set(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_MAX_MODES), num_args - 1); if (num_args - 1 > _max_modes) { - GetLogger() PTR_DEREF Error( - StringFormat("Too many data for buffers for action %s!", EnumToString(_action), __FUNCTION_LINE__)); + GetLogger() PTR_DEREF Error(StringFormat("Too many data for buffers for action %s at %s!", + C_STR(EnumToString(_action)), __FUNCTION_LINE__)); return false; } diff --git a/Log.mqh b/Log.mqh index 32679ae95..ef9e21fcb 100644 --- a/Log.mqh +++ b/Log.mqh @@ -31,6 +31,7 @@ class DictStruct; // Includes. #include "File.mqh" +#include "Std.h" #include "Storage/Array.h" #include "Storage/Collection.h" #include "Storage/DateTime.h" @@ -39,7 +40,7 @@ class DictStruct; // Define assert macros. // Alias for function and line macros combined together. -#define __FUNCTION_LINE__ string(__FUNCTION__) + ":" + IntegerToString(__LINE__) +#define __FUNCTION_LINE__ C_STR(string(__FUNCTION__) + ":" + IntegerToString(__LINE__)) // Log verbosity level. enum ENUM_LOG_LEVEL { diff --git a/Math/Math.define.h b/Math/Math.define.h index 439becf80..f3cf78ff4 100644 --- a/Math/Math.define.h +++ b/Math/Math.define.h @@ -37,6 +37,13 @@ #define fmin5(_v1, _v2, _v3, _v4, _v5) fmin(fmin(fmin(fmin(_v1, _v2), _v3), _v4), _v5) #define fmin6(_v1, _v2, _v3, _v4, _v5, _v6) fmin(fmin(fmin(fmin(fmin(_v1, _v2), _v3), _v4), _v5), _v6) +// Math errors. +#define MATH_ERR_OK 0 +#define MATH_ERR_ARGUMENTS_NAN 1 +#define MATH_ERR_ARGUMENTS_INVALID 2 +#define MATH_ERR_RESULT_INFINITE 3 +#define MATH_ERR_NON_CONVERGENCE 4 + #ifdef __cplusplus #include diff --git a/Math/Math.extern.h b/Math/Math.extern.h index 9248b9253..64dfd0258 100644 --- a/Math/Math.extern.h +++ b/Math/Math.extern.h @@ -20,11 +20,34 @@ * */ -// Define external global functions. #ifndef __MQL__ // Allows the preprocessor to include a header file when it is needed. #pragma once +#include +#include +#endif + +#ifdef __MQL__ +const double NaN = (double)"nan"; +#else +const double NaN = std::nan(""); +#endif + +#ifdef __MQL__ +const double POSINF = (double)"inf"; +#else +const double POSINF = std::numeric_limits::infinity(); +#endif + +#ifdef __MQL__ +const double NEGINF = (double)"-inf"; +#else +const double NEGINF = std::numeric_limits::infinity() * -1; +#endif + +// Define external global functions. +#ifndef __MQL__ #include #include @@ -90,4 +113,7 @@ T log10(T value) { } int MathRand() { return std::rand() % 32768; } // int rand() { return std::rand() % 32768; } + +bool MathIsValidNumber(double _number) { return (_number != NaN && _number != NEGINF && _number != POSINF); } + #endif diff --git a/Math/Math.h b/Math/Math.h index 4dc2735f5..04d27f20b 100644 --- a/Math/Math.h +++ b/Math/Math.h @@ -31,6 +31,7 @@ #include "Math.define.h" #include "Math.enum.h" #include "Math.extern.h" +#include "Math.normal.h" #include "Math.struct.h" /** @@ -127,6 +128,290 @@ class Math { */ static double NonZero(double _v) { return _v == 0 ? DBL_MIN : _v; } + static double RandomNonZero(void) { + double rnd = 0; + + while (rnd == 0.0 || rnd == 1.0) { + rnd = MathRand() / 32767.0; + } + + return rnd; + } + + static double TailLogProbability(const double probability, const bool tail, const bool log_mode) { + if (tail == true) { + if (log_mode) + return MathExp(probability); + else + return (probability); + } else { + if (log_mode) + return (1.0 - MathExp(probability)); + else + return (1.0 - probability); + } + } + + static double QuantileNormal(const double probability, const double mu, const double sigma, const bool tail, + const bool log_mode, int &error_code) { + // Check NaN. + if (!MathIsValidNumber(probability) || !MathIsValidNumber(mu) || !MathIsValidNumber(sigma)) { + error_code = MATH_ERR_ARGUMENTS_NAN; + return NaN; + } + //--- check sigma + if (sigma <= 0) { + error_code = MATH_ERR_ARGUMENTS_INVALID; + return NaN; + } + + // Calculate real probability. + double prob = TailLogProbability(probability, tail, log_mode); + + // Check probability range. + if (prob < 0.0 || prob > 1.0) { + error_code = MATH_ERR_ARGUMENTS_INVALID; + return NaN; + } + + // f(0)=-infinity + if (prob == 0.0) { + error_code = MATH_ERR_RESULT_INFINITE; + return NEGINF; + } + // f(1)=+infinity + if (prob == 1.0) { + error_code = MATH_ERR_RESULT_INFINITE; + return POSINF; + } + + error_code = MATH_ERR_OK; + + double q = prob - 0.5; + double r = 0; + double ppnd16 = 0.0; + + if (MathAbs(q) <= 0.425) { + r = 0.180625 - q * q; + ppnd16 = q * + (((((((normal_q_a7 * r + normal_q_a6) * r + normal_q_a5) * r + normal_q_a4) * r + normal_q_a3) * r + + normal_q_a2) * + r + + normal_q_a1) * + r + + normal_q_a0) / + (((((((normal_q_b7 * r + normal_q_b6) * r + normal_q_b5) * r + normal_q_b4) * r + normal_q_b3) * r + + normal_q_b2) * + r + + normal_q_b1) * + r + + 1.0); + + error_code = MATH_ERR_OK; + + return mu + sigma * ppnd16; + } else { + if (q < 0.0) + r = prob; + else + r = 1.0 - prob; + + r = MathSqrt(-MathLog(r)); + + if (r <= 5.0) { + r = r - 1.6; + ppnd16 = (((((((normal_q_c7 * r + normal_q_c6) * r + normal_q_c5) * r + normal_q_c4) * r + normal_q_c3) * r + + normal_q_c2) * + r + + normal_q_c1) * + r + + normal_q_c0) / + (((((((normal_q_d7 * r + normal_q_d6) * r + normal_q_d5) * r + normal_q_d4) * r + normal_q_d3) * r + + normal_q_d2) * + r + + normal_q_d1) * + r + + 1.0); + } else { + r = r - 5.0; + ppnd16 = (((((((normal_q_e7 * r + normal_q_e6) * r + normal_q_e5) * r + normal_q_e4) * r + normal_q_e3) * r + + normal_q_e2) * + r + + normal_q_e1) * + r + + normal_q_e0) / + (((((((normal_q_f7 * r + normal_q_f6) * r + normal_q_f5) * r + normal_q_f4) * r + normal_q_f3) * r + + normal_q_f2) * + r + + normal_q_f1) * + r + + 1.0); + } + + if (q < 0.0) ppnd16 = -ppnd16; + } + // Return rescaled/shifted value. + return mu + sigma * ppnd16; + } + + static bool QuantileNormal(CONST_ARRAY_REF(double, probability), const double mu, const double sigma, const bool tail, + const bool log_mode, ARRAY_REF(double, result)) { + //--- check NaN + if (!MathIsValidNumber(mu) || !MathIsValidNumber(sigma)) return false; + //--- check sigma + if (sigma < 0) return false; + + int data_count = ArraySize(probability); + if (data_count == 0) return false; + + int error_code = 0, i; + ArrayResize(result, data_count); + + //--- case sigma==0 + if (sigma == 0.0) { + for (i = 0; i < data_count; i++) result[i] = mu; + return true; + } + + for (i = 0; i < data_count; i++) { + //--- calculate real probability + double prob = TailLogProbability(probability[i], tail, log_mode); + //--- check probability range + if (prob < 0.0 || prob > 1.0) return false; + + //--- f(0)=-infinity, f(1)=+infinity + if (prob == 0.0 || prob == 1.0) { + if (prob == 0.0) + result[i] = NEGINF; + else + result[i] = POSINF; + } else { + double q = prob - 0.5; + double r = 0; + double ppnd16 = 0.0; + //--- + if (MathAbs(q) <= 0.425) { + r = 0.180625 - q * q; + ppnd16 = q * + (((((((normal_q_a7 * r + normal_q_a6) * r + normal_q_a5) * r + normal_q_a4) * r + normal_q_a3) * r + + normal_q_a2) * + r + + normal_q_a1) * + r + + normal_q_a0) / + (((((((normal_q_b7 * r + normal_q_b6) * r + normal_q_b5) * r + normal_q_b4) * r + normal_q_b3) * r + + normal_q_b2) * + r + + normal_q_b1) * + r + + 1.0); + //--- set rescaled/shifted value + result[i] = mu + sigma * ppnd16; + } else { + if (q < 0.0) + r = prob; + else + r = 1.0 - prob; + //--- + r = MathSqrt(-MathLog(r)); + //--- + if (r <= 5.0) { + r = r - 1.6; + ppnd16 = + (((((((normal_q_c7 * r + normal_q_c6) * r + normal_q_c5) * r + normal_q_c4) * r + normal_q_c3) * r + + normal_q_c2) * + r + + normal_q_c1) * + r + + normal_q_c0) / + (((((((normal_q_d7 * r + normal_q_d6) * r + normal_q_d5) * r + normal_q_d4) * r + normal_q_d3) * r + + normal_q_d2) * + r + + normal_q_d1) * + r + + 1.0); + } else { + r = r - 5.0; + ppnd16 = + (((((((normal_q_e7 * r + normal_q_e6) * r + normal_q_e5) * r + normal_q_e4) * r + normal_q_e3) * r + + normal_q_e2) * + r + + normal_q_e1) * + r + + normal_q_e0) / + (((((((normal_q_f7 * r + normal_q_f6) * r + normal_q_f5) * r + normal_q_f4) * r + normal_q_f3) * r + + normal_q_f2) * + r + + normal_q_f1) * + r + + 1.0); + } + //--- + if (q < 0.0) ppnd16 = -ppnd16; + } + //--- set rescaled/shifted value + result[i] = mu + sigma * ppnd16; + } + } + return true; + } + + static bool QuantileNormal(CONST_ARRAY_REF(double, probability), const double mu, const double sigma, + ARRAY_REF(double, result)) { + return QuantileNormal(probability, mu, sigma, true, false, result); + } + + static double RandomNormal(const double mu, const double sigma, int &error_code) { + if (!MathIsValidNumber(mu) || !MathIsValidNumber(sigma)) { + error_code = MATH_ERR_ARGUMENTS_NAN; + return NaN; + } + + if (sigma < 0) { + error_code = MATH_ERR_ARGUMENTS_INVALID; + return NaN; + } + + error_code = MATH_ERR_OK; + + if (sigma == 0.0) return mu; + + double rnd = RandomNonZero(); + + return QuantileNormal(rnd, mu, sigma, true, false, error_code); + } + + static bool RandomNormal(const double mu, const double sigma, const int data_count, ARRAY_REF(double, result)) { + int i; + + // Check NaN. + if (!MathIsValidNumber(mu) || !MathIsValidNumber(sigma)) { + return false; + } + + // Check sigma. + if (sigma < 0) { + return false; + } + + // Prepare output array and calculate random values. + ArrayResize(result, data_count); + + if (sigma == 0.0) { + for (i = 0; i < data_count; i++) result[i] = mu; + return true; + } + + int err_code = 0; + + for (i = 0; i < data_count; i++) { + result[i] = RandomNonZero(); + } + + // Return normal random array using quantile. + return QuantileNormal(result, mu, sigma, result); + } + /* Conditions */ /** @@ -278,4 +563,4 @@ int64 MathRound(int64 _value) { return _value; } */ int64 round(int64 _value) { return MathRound(_value); } -#endif \ No newline at end of file +#endif diff --git a/Math/Math.normal.h b/Math/Math.normal.h new file mode 100644 index 000000000..6ceabd2c8 --- /dev/null +++ b/Math/Math.normal.h @@ -0,0 +1,92 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2023, 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 . + * + */ + +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + +const static double normal_cdf_a[5] = {2.2352520354606839287E00, 1.6102823106855587881E02, 1.0676894854603709582E03, + 1.8154981253343561249E04, 6.5682337918207449113E-2}; +const static double normal_cdf_b[4] = {4.7202581904688241870E01, 9.7609855173777669322E02, 1.0260932208618978205E04, + 4.5507789335026729956E04}; +//--- coefficients for approximation in second interval +const static double normal_cdf_c[9] = {3.9894151208813466764E-1, 8.8831497943883759412E00, 9.3506656132177855979E01, + 5.9727027639480026226E02, 2.4945375852903726711E03, 6.8481904505362823326E03, + 1.1602651437647350124E04, 9.8427148383839780218E03, 1.0765576773720192317E-8}; +const static double normal_cdf_d[8] = {2.2266688044328115691E01, 2.3538790178262499861E02, 1.5193775994075548050E03, + 6.4855582982667607550E03, 1.8615571640885098091E04, 3.4900952721145977266E04, + 3.8912003286093271411E04, 1.9685429676859990727E04}; +//--- coefficients for approximation in third interval +const static double normal_cdf_p[6] = {2.1589853405795699E-1, 1.274011611602473639E-1, 2.2235277870649807E-2, + 1.421619193227893466E-3, 2.9112874951168792E-5, 2.307344176494017303E-2}; +const static double normal_cdf_q[5] = {1.28426009614491121E00, 4.68238212480865118E-1, 6.59881378689285515E-2, + 3.78239633202758244E-3, 7.29751555083966205E-5}; + +//--- coefficients for p close to 0.5 +const double normal_q_a0 = 3.3871328727963666080; +const double normal_q_a1 = 1.3314166789178437745E+2; +const double normal_q_a2 = 1.9715909503065514427E+3; +const double normal_q_a3 = 1.3731693765509461125E+4; +const double normal_q_a4 = 4.5921953931549871457E+4; +const double normal_q_a5 = 6.7265770927008700853E+4; +const double normal_q_a6 = 3.3430575583588128105E+4; +const double normal_q_a7 = 2.5090809287301226727E+3; +const double normal_q_b1 = 4.2313330701600911252E+1; +const double normal_q_b2 = 6.8718700749205790830E+2; +const double normal_q_b3 = 5.3941960214247511077E+3; +const double normal_q_b4 = 2.1213794301586595867E+4; +const double normal_q_b5 = 3.9307895800092710610E+4; +const double normal_q_b6 = 2.8729085735721942674E+4; +const double normal_q_b7 = 5.2264952788528545610E+3; +//--- coefficients for p not close to 0, 0.5 or 1 +const double normal_q_c0 = 1.42343711074968357734; +const double normal_q_c1 = 4.63033784615654529590; +const double normal_q_c2 = 5.76949722146069140550; +const double normal_q_c3 = 3.64784832476320460504; +const double normal_q_c4 = 1.27045825245236838258; +const double normal_q_c5 = 2.41780725177450611770E-1; +const double normal_q_c6 = 2.27238449892691845833E-2; +const double normal_q_c7 = 7.74545014278341407640E-4; +const double normal_q_d1 = 2.05319162663775882187; +const double normal_q_d2 = 1.67638483018380384940; +const double normal_q_d3 = 6.89767334985100004550E-1; +const double normal_q_d4 = 1.48103976427480074590E-1; +const double normal_q_d5 = 1.51986665636164571966E-2; +const double normal_q_d6 = 5.47593808499534494600E-4; +const double normal_q_d7 = 1.05075007164441684324E-9; +//--- coefficients for p near 0 or 1. +const double normal_q_e0 = 6.65790464350110377720E0; +const double normal_q_e1 = 5.46378491116411436990E0; +const double normal_q_e2 = 1.78482653991729133580E0; +const double normal_q_e3 = 2.96560571828504891230E-1; +const double normal_q_e4 = 2.65321895265761230930E-2; +const double normal_q_e5 = 1.24266094738807843860E-3; +const double normal_q_e6 = 2.71155556874348757815E-5; +const double normal_q_e7 = 2.01033439929228813265E-7; +const double normal_q_f1 = 5.99832206555887937690E-1; +const double normal_q_f2 = 1.36929880922735805310E-1; +const double normal_q_f3 = 1.48753612908506148525E-2; +const double normal_q_f4 = 7.86869131145613259100E-4; +const double normal_q_f5 = 1.84631831751005468180E-5; +const double normal_q_f6 = 1.42151175831644588870E-7; +const double normal_q_f7 = 2.04426310338993978564E-15; diff --git a/Math/Matrix.h b/Math/Matrix.h index 57fa065d5..840eaee82 100644 --- a/Math/Matrix.h +++ b/Math/Matrix.h @@ -25,12 +25,6 @@ #pragma once #endif -#ifdef USE_MQL_MATH_STAT -#ifdef __MQL5__ -#include -#endif -#endif - // Includes. #include "Math.h" @@ -1414,24 +1408,19 @@ class Matrix { */ void FillRandomUniform(X _min, X _max, int _seed = -1) { FillRandom(_min, _max, _seed); } -#ifdef USE_MQL_MATH_STAT /** * Initializer that generates tensors with a normal distribution. */ void FillRandomNormal(X _mean, X _stddev, int _seed = -1) { -#ifdef __MQL5__ if (_seed != -1) { Print("Matrix::FillRandomNormal(): _seed parameter is not yet implemented! Please use -1 as _seed."); } - double _values[]; - MathRandomNormal(_mean, _stddev, GetSize(), _values); + ARRAY(double, _values); + int _size = GetSize(); + Math::RandomNormal(_mean, _stddev, _size, _values); FillFromArray(_values); -#else - Print("Matrix::FillRandomNormal() is implemented only in MQL5!"); -#endif } -#endif void FillFromArray(ARRAY_REF(X, _array)) { if (ArraySize(_array) != GetSize()) { diff --git a/Platform/Chart/Chart.struct.h b/Platform/Chart/Chart.struct.h index 6bd9477ce..c3edc96a7 100644 --- a/Platform/Chart/Chart.struct.h +++ b/Platform/Chart/Chart.struct.h @@ -38,6 +38,7 @@ struct ChartTf; #include "../../Bar.struct.h" #include "../../Serializer/Serializer.h" #include "../../Serializer/SerializerNode.enum.h" +#include "../../Std.h" #include "../../Storage/Array.h" #include "../Terminal.define.h" #include "Chart.define.h" @@ -54,7 +55,7 @@ struct ChartEntry { ChartEntry(const ChartEntry& _r) { SetBar(_r.bar); } // Getters. BarEntry GetBar() { return bar; } - string ToCSV() { return StringFormat("%s", bar.ToCSV()); } + string ToCSV() { return StringFormat("%s", C_STR(bar.ToCSV())); } // Setters. void SetBar(const BarEntry& _bar) { bar = _bar; } // Serializers. diff --git a/Platform/Platform.enum.h b/Platform/Platform.enum.h index edd657855..8c8b75309 100644 --- a/Platform/Platform.enum.h +++ b/Platform/Platform.enum.h @@ -41,4 +41,4 @@ enum ENUM_COPY_TICKS { COPY_TICKS_VOLUME = 1048576, COPY_TICKS_FLAGS = 2097152 }; -#endif \ No newline at end of file +#endif diff --git a/Serializer/SerializerConversions.h b/Serializer/SerializerConversions.h index 61f65548c..dabdb89c4 100644 --- a/Serializer/SerializerConversions.h +++ b/Serializer/SerializerConversions.h @@ -31,7 +31,6 @@ #endif #include "../Convert.extern.h" -#include "../Refs.struct.h" #include "../Storage/DateTime.extern.h" #include "../Storage/Object.h" diff --git a/Storage/Array.h b/Storage/Array.h index 84aa976a0..f155ecd31 100644 --- a/Storage/Array.h +++ b/Storage/Array.h @@ -815,4 +815,4 @@ void ArrayFill(FIXED_ARRAY_REF(X, array, size), int start, int count, X value) { Array::ArrayFill(array, start, count, value); } -#endif \ No newline at end of file +#endif