From fe37c37385e8b1cc7ddf3095cdea88a616ecb327 Mon Sep 17 00:00:00 2001 From: kenorb Date: Sun, 3 Sep 2023 14:27:26 +0100 Subject: [PATCH 1/5] Renames MA_Cross_Shift to MA_Cross_Pivot --- .github/workflows/backtest.yml | 6 +++--- .github/workflows/compile.yml | 4 ++-- Stg_MA_Cross_Shift.mq4 => Stg_MA_Cross_Pivot.mq4 | 4 ++-- Stg_MA_Cross_Shift.mq5 => Stg_MA_Cross_Pivot.mq5 | 2 +- Stg_MA_Cross_Shift.mqh => Stg_MA_Cross_Pivot.mqh | 0 Stg_MA_Cross_Shift.mqproj => Stg_MA_Cross_Pivot.mqproj | 0 6 files changed, 8 insertions(+), 8 deletions(-) rename Stg_MA_Cross_Shift.mq4 => Stg_MA_Cross_Pivot.mq4 (84%) rename Stg_MA_Cross_Shift.mq5 => Stg_MA_Cross_Pivot.mq5 (98%) rename Stg_MA_Cross_Shift.mqh => Stg_MA_Cross_Pivot.mqh (100%) rename Stg_MA_Cross_Shift.mqproj => Stg_MA_Cross_Pivot.mqproj (100%) diff --git a/.github/workflows/backtest.yml b/.github/workflows/backtest.yml index 6362a22..2622cae 100644 --- a/.github/workflows/backtest.yml +++ b/.github/workflows/backtest.yml @@ -35,14 +35,14 @@ jobs: include: . init-platform: true mt-version: 5.0.0.2361 - path: Stg_MA_Cross_Shift.mq4 + path: Stg_MA_Cross_Pivot.mq4 verbose: true - name: Compile for MQL5 uses: fx31337/mql-compile-action@master with: include: . mt-version: 5.0.0.2515 - path: Stg_MA_Cross_Shift.mq5 + path: Stg_MA_Cross_Pivot.mq5 verbose: true - name: List compiled files run: '(Get-ChildItem -Recurse -Path . -Include *.ex[45]).fullname' @@ -73,7 +73,7 @@ jobs: OptFormatBrief: true OptFormatJson: true OptVerbose: true - TestExpert: "Stg_MA_Cross_Shift" + TestExpert: "Stg_MA_Cross_Pivot" TestPeriod: M1 TestReportName: Report-${{ matrix.year }}-${{ matrix.month }} - name: Upload results diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml index c4420fd..61de585 100644 --- a/.github/workflows/compile.yml +++ b/.github/workflows/compile.yml @@ -37,14 +37,14 @@ jobs: include: . init-platform: true mt-version: 5.0.0.2361 - path: Stg_MA_Cross_Shift.mq4 + path: Stg_MA_Cross_Pivot.mq4 verbose: true - name: Compile for MQL5 uses: fx31337/mql-compile-action@master with: include: . mt-version: 5.0.0.2515 - path: Stg_MA_Cross_Shift.mq5 + path: Stg_MA_Cross_Pivot.mq5 verbose: true - name: List compiled files run: '(Get-ChildItem -Recurse -Path . -Include *.ex[45]).fullname' diff --git a/Stg_MA_Cross_Shift.mq4 b/Stg_MA_Cross_Pivot.mq4 similarity index 84% rename from Stg_MA_Cross_Shift.mq4 rename to Stg_MA_Cross_Pivot.mq4 index fe37c53..b8a8228 100644 --- a/Stg_MA_Cross_Shift.mq4 +++ b/Stg_MA_Cross_Pivot.mq4 @@ -6,8 +6,8 @@ /** * @file - * Implements MA Cross Shift strategy. + * Implements MA Cross Pivot strategy. */ // Includes the main code. -#include "Stg_MA_Cross_Shift.mq5" +#include "Stg_MA_Cross_Pivot.mq5" diff --git a/Stg_MA_Cross_Shift.mq5 b/Stg_MA_Cross_Pivot.mq5 similarity index 98% rename from Stg_MA_Cross_Shift.mq5 rename to Stg_MA_Cross_Pivot.mq5 index e4b2fd6..d0defd3 100644 --- a/Stg_MA_Cross_Shift.mq5 +++ b/Stg_MA_Cross_Pivot.mq5 @@ -27,7 +27,7 @@ input ENUM_LOG_LEVEL Log_Level = V_INFO; // Log level. input bool Info_On_Chart = true; // Display info on chart. // Includes strategy. -#include "Stg_MA_Cross_Shift.mqh" +#include "Stg_MA_Cross_Pivot.mqh" // Defines. #define ea_name "Strategy MA Cross Shift" diff --git a/Stg_MA_Cross_Shift.mqh b/Stg_MA_Cross_Pivot.mqh similarity index 100% rename from Stg_MA_Cross_Shift.mqh rename to Stg_MA_Cross_Pivot.mqh diff --git a/Stg_MA_Cross_Shift.mqproj b/Stg_MA_Cross_Pivot.mqproj similarity index 100% rename from Stg_MA_Cross_Shift.mqproj rename to Stg_MA_Cross_Pivot.mqproj From 80e3c5c0dd040c6b264c68d1cb1357334a726227 Mon Sep 17 00:00:00 2001 From: kenorb Date: Sun, 3 Sep 2023 14:31:16 +0100 Subject: [PATCH 2/5] Replaces MA_Cross_Shift with MA_Cross_Pivot --- README.md | 14 +- Stg_MA_Cross_Pivot.mq5 | 10 +- Stg_MA_Cross_Pivot.mqh | 402 +++++++++++++++++++------------------- Stg_MA_Cross_Pivot.mqproj | 6 +- 4 files changed, 216 insertions(+), 216 deletions(-) diff --git a/README.md b/README.md index f0c7144..2d7b2e8 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Strategy MA Cross Shift +# Strategy MA Cross Pivot [![Status][gha-image-check-master]][gha-link-check-master] [![Status][gha-image-compile-master]][gha-link-compile-master] @@ -8,7 +8,7 @@ [![Edit][gh-edit-badge]][gh-edit-link] Strategy based on the moving average price indicators -implementing shifted cross signal. +implementing daily pivot cross signal. ## Dependencies @@ -22,12 +22,12 @@ implementing shifted cross signal. [gh-discuss-link]: https://github.com/EA31337/EA31337-Strategies/discussions [gh-edit-badge]: https://img.shields.io/badge/GitHub-edit-purple.svg?logo=github -[gh-edit-link]: https://github.dev/EA31337/Strategy-MA_Cross_Shift +[gh-edit-link]: https://github.dev/EA31337/Strategy-MA_Cross_Pivot -[gha-link-check-master]: https://github.com/EA31337/Strategy-MA_Cross_Shift/actions?query=workflow:Check+branch%3Amaster -[gha-image-check-master]: https://github.com/EA31337/Strategy-MA_Cross_Shift/workflows/Check/badge.svg?branch=master -[gha-link-compile-master]: https://github.com/EA31337/Strategy-MA_Cross_Shift/actions?query=workflow:Compile+branch%3Amaster -[gha-image-compile-master]: https://github.com/EA31337/Strategy-MA_Cross_Shift/workflows/Compile/badge.svg?branch=master +[gha-link-check-master]: https://github.com/EA31337/Strategy-MA_Cross_Pivot/actions?query=workflow:Check+branch%3Amaster +[gha-image-check-master]: https://github.com/EA31337/Strategy-MA_Cross_Pivot/workflows/Check/badge.svg?branch=master +[gha-link-compile-master]: https://github.com/EA31337/Strategy-MA_Cross_Pivot/actions?query=workflow:Compile+branch%3Amaster +[gha-image-compile-master]: https://github.com/EA31337/Strategy-MA_Cross_Pivot/workflows/Compile/badge.svg?branch=master [tg-channel-image]: https://img.shields.io/badge/Telegram-join-0088CC.svg?logo=telegram [tg-channel-link]: https://t.me/EA31337 diff --git a/Stg_MA_Cross_Pivot.mq5 b/Stg_MA_Cross_Pivot.mq5 index d0defd3..6ddb1b3 100644 --- a/Stg_MA_Cross_Pivot.mq5 +++ b/Stg_MA_Cross_Pivot.mq5 @@ -1,6 +1,6 @@ /** * @file - * Implements MA strategy. + * Implements MA Cross Pivot strategy. */ // Includes conditional compilation directives. @@ -20,7 +20,7 @@ #include // Inputs. -INPUT_GROUP("MA Cross Shift strategy: main"); +INPUT_GROUP("MA Cross Pivot strategy: main"); input int Active_Tfs = M15B + M30B + H1B + H2B + H3B + H4B + H6B + H8B; // Timeframes (M1=1,M2=2,M5=16,M15=256,M30=1024,H1=2048,H2=4096,H3,H4,H6,H8) input ENUM_LOG_LEVEL Log_Level = V_INFO; // Log level. @@ -30,9 +30,9 @@ input bool Info_On_Chart = true; // Display info on chart. #include "Stg_MA_Cross_Pivot.mqh" // Defines. -#define ea_name "Strategy MA Cross Shift" +#define ea_name "Strategy MA Cross Pivot" #define ea_version "2.000" -#define ea_desc "Strategy based on the moving average price indicators implementing shifted cross signal." +#define ea_desc "Strategy based on the moving average price indicators implementing daily pivot cross signal." #define ea_link "https://github.com/EA31337/Strategy-MA" #define ea_author "EA31337 Ltd" @@ -59,7 +59,7 @@ int OnInit() { bool _result = true; EAParams ea_params(__FILE__, Log_Level); ea = new EA(ea_params); - _result &= ea.StrategyAdd(Active_Tfs); + _result &= ea.StrategyAdd(Active_Tfs); return (_result ? INIT_SUCCEEDED : INIT_FAILED); } diff --git a/Stg_MA_Cross_Pivot.mqh b/Stg_MA_Cross_Pivot.mqh index 6c304dc..de4c2ee 100644 --- a/Stg_MA_Cross_Pivot.mqh +++ b/Stg_MA_Cross_Pivot.mqh @@ -3,121 +3,121 @@ * Strategy based on the moving average price indicators implementing shifted cross signal. */ -enum ENUM_STG_MA_CROSS_SHIFT_TYPE { - STG_MA_CROSS_SHIFT_TYPE_0_NONE = 0, // (None) - STG_MA_CROSS_SHIFT_TYPE_AMA, // AMA: Adaptive Moving Average - STG_MA_CROSS_SHIFT_TYPE_DEMA, // DEMA: Double Exponential Moving Average - STG_MA_CROSS_SHIFT_TYPE_FRAMA, // FrAMA: Fractal Adaptive Moving Average - STG_MA_CROSS_SHIFT_TYPE_ICHIMOKU, // Ichimoku - STG_MA_CROSS_SHIFT_TYPE_MA, // MA: Moving Average - STG_MA_CROSS_SHIFT_TYPE_PRICE_CHANNEL, // Price Channel - STG_MA_CROSS_SHIFT_TYPE_SAR, // SAR: Parabolic Stop and Reverse - STG_MA_CROSS_SHIFT_TYPE_TEMA, // TEMA: Triple Exponential Moving Average - STG_MA_CROSS_SHIFT_TYPE_VIDYA, // VIDYA: Variable Index Dynamic Average +enum ENUM_STG_MA_CROSS_PIVOT_TYPE { + STG_MA_CROSS_PIVOT_TYPE_0_NONE = 0, // (None) + STG_MA_CROSS_PIVOT_TYPE_AMA, // AMA: Adaptive Moving Average + STG_MA_CROSS_PIVOT_TYPE_DEMA, // DEMA: Double Exponential Moving Average + STG_MA_CROSS_PIVOT_TYPE_FRAMA, // FrAMA: Fractal Adaptive Moving Average + STG_MA_CROSS_PIVOT_TYPE_ICHIMOKU, // Ichimoku + STG_MA_CROSS_PIVOT_TYPE_MA, // MA: Moving Average + STG_MA_CROSS_PIVOT_TYPE_PRICE_CHANNEL, // Price Channel + STG_MA_CROSS_PIVOT_TYPE_SAR, // SAR: Parabolic Stop and Reverse + STG_MA_CROSS_PIVOT_TYPE_TEMA, // TEMA: Triple Exponential Moving Average + STG_MA_CROSS_PIVOT_TYPE_VIDYA, // VIDYA: Variable Index Dynamic Average }; // User params. -INPUT_GROUP("MA Cross Shift strategy: main strategy params"); -INPUT ENUM_STG_MA_CROSS_SHIFT_TYPE MA_Cross_Shift_Type = STG_MA_CROSS_SHIFT_TYPE_MA; // Indicator MA type -INPUT_GROUP("MA Cross Shift strategy: strategy params"); -INPUT float MA_Cross_Shift_LotSize = 0; // Lot size -INPUT int MA_Cross_Shift_SignalOpenMethod = 0; // Signal open method (-127-127) -INPUT float MA_Cross_Shift_SignalOpenLevel = 0.0f; // Signal open level -INPUT int MA_Cross_Shift_SignalOpenFilterMethod = 32; // Signal open filter method -INPUT int MA_Cross_Shift_SignalOpenFilterTime = 3; // Signal open filter time -INPUT int MA_Cross_Shift_SignalOpenBoostMethod = 0; // Signal open boost method -INPUT int MA_Cross_Shift_SignalCloseMethod = 0; // Signal close method (-127-127) -INPUT int MA_Cross_Shift_SignalCloseFilter = 0; // Signal close filter (-127-127) -INPUT float MA_Cross_Shift_SignalCloseLevel = 0.0f; // Signal close level -INPUT int MA_Cross_Shift_PriceStopMethod = 1; // Price stop method (0-127) -INPUT float MA_Cross_Shift_PriceStopLevel = 2; // Price stop level -INPUT int MA_Cross_Shift_TickFilterMethod = 32; // Tick filter method -INPUT float MA_Cross_Shift_MaxSpread = 4.0; // Max spread to trade (pips) -INPUT short MA_Cross_Shift_Shift = 0; // Shift -INPUT float MA_Cross_Shift_OrderCloseLoss = 80; // Order close loss -INPUT float MA_Cross_Shift_OrderCloseProfit = 80; // Order close profit -INPUT int MA_Cross_Shift_OrderCloseTime = -30; // Order close time in mins (>0) or bars (<0) -INPUT_GROUP("MA Cross Shift strategy: AMA indicator params"); -INPUT int MA_Cross_Shift_Indi_AMA_InpPeriodAMA = 20; // AMA period -INPUT int MA_Cross_Shift_Indi_AMA_InpFastPeriodEMA = 4; // Fast EMA period -INPUT int MA_Cross_Shift_Indi_AMA_InpSlowPeriodEMA = 30; // Slow EMA period -INPUT int MA_Cross_Shift_Indi_AMA_InpShiftAMA = 4; // AMA shift -INPUT int MA_Cross_Shift_Indi_AMA_Shift = 0; // Shift -INPUT int MA_Cross_Shift_Indi_AMA_Shift2 = 10; // Shift 2 -INPUT ENUM_IDATA_SOURCE_TYPE MA_Cross_Shift_Indi_AMA_SourceType = IDATA_BUILTIN; // Source type -INPUT_GROUP("MA Cross Shift strategy: DEMA indicator params"); -INPUT int MA_Cross_Shift_Indi_DEMA_Period = 25; // Period -INPUT int MA_Cross_Shift_Indi_DEMA_MA_Shift = 6; // MA Shift -INPUT ENUM_APPLIED_PRICE MA_Cross_Shift_Indi_DEMA_Applied_Price = PRICE_TYPICAL; // Applied Price -INPUT int MA_Cross_Shift_Indi_DEMA_Shift = 0; // Shift -INPUT int MA_Cross_Shift_Indi_DEMA_Shift2 = 10; // Shift 2 -INPUT ENUM_IDATA_SOURCE_TYPE MA_Cross_Shift_Indi_DEMA_SourceType = IDATA_BUILTIN; // Source type -INPUT_GROUP("MA Cross Shift strategy: FrAMA indicator params"); -INPUT int MA_Cross_Shift_Indi_FrAMA_Period = 10; // Period -INPUT ENUM_APPLIED_PRICE MA_Cross_Shift_Indi_FrAMA_Applied_Price = PRICE_MEDIAN; // Applied Price -INPUT int MA_Cross_Shift_Indi_FrAMA_MA_Shift = 0; // MA Shift -INPUT int MA_Cross_Shift_Indi_FrAMA_Shift = 0; // Shift -INPUT int MA_Cross_Shift_Indi_FrAMA_Shift2 = 10; // Shift 2 -INPUT ENUM_IDATA_SOURCE_TYPE MA_Cross_Shift_Indi_FrAMA_SourceType = IDATA_BUILTIN; // Source type -INPUT_GROUP("MA Cross Shift strategy: Ichimoku indicator params"); -// INPUT ENUM_ICHIMOKU_LINE MA_Cross_Shift_Indi_Ichimoku_MA_Line = LINE_TENKANSEN; // Ichimoku line for MA -INPUT int MA_Cross_Shift_Indi_Ichimoku_Period_Tenkan_Sen = 30; // Period Tenkan Sen -INPUT int MA_Cross_Shift_Indi_Ichimoku_Period_Kijun_Sen = 10; // Period Kijun Sen -INPUT int MA_Cross_Shift_Indi_Ichimoku_Period_Senkou_Span_B = 30; // Period Senkou Span B -INPUT int MA_Cross_Shift_Indi_Ichimoku_Shift = 1; // Shift -INPUT int MA_Cross_Shift_Indi_Ichimoku_Shift2 = 1; // Shift 2 -INPUT ENUM_IDATA_SOURCE_TYPE MA_Cross_Shift_Indi_Ichimoku_SourceType = IDATA_BUILTIN; // Source type -INPUT_GROUP("MA Cross Shift strategy: MA indicator params"); -INPUT int MA_Cross_Shift_Indi_MA_Period = 26; // Period -INPUT int MA_Cross_Shift_Indi_MA_MA_Shift = 0; // MA Shift -INPUT ENUM_MA_METHOD MA_Cross_Shift_Indi_MA_Method = MODE_LWMA; // MA Method -INPUT ENUM_APPLIED_PRICE MA_Cross_Shift_Indi_MA_Applied_Price = PRICE_WEIGHTED; // Applied Price -INPUT int MA_Cross_Shift_Indi_MA_Shift = 0; // Shift -INPUT int MA_Cross_Shift_Indi_MA_Shift2 = 10; // Shift 2 -INPUT ENUM_IDATA_SOURCE_TYPE MA_Cross_Shift_Indi_MA_SourceType = IDATA_BUILTIN; // Source type -INPUT_GROUP("MA Cross Shift strategy: Price Channel indicator params"); -INPUT int MA_Cross_Shift_Indi_PriceChannel_Period = 26; // Period -INPUT int MA_Cross_Shift_Indi_PriceChannel_Shift = 0; // Shift -INPUT int MA_Cross_Shift_Indi_PriceChannel_Shift2 = 10; // Shift 2 -INPUT ENUM_IDATA_SOURCE_TYPE MA_Cross_Shift_Indi_PriceChannel_SourceType = IDATA_ICUSTOM; // Source type -INPUT_GROUP("MA Cross Shift strategy: SAR indicator params"); -INPUT float MA_Cross_Shift_Indi_SAR_Step = 0.04f; // Step -INPUT float MA_Cross_Shift_Indi_SAR_Maximum_Stop = 0.4f; // Maximum stop -INPUT int MA_Cross_Shift_Indi_SAR_Shift = 0; // Shift -INPUT int MA_Cross_Shift_Indi_SAR_Shift2 = 10; // Shift 2 -INPUT ENUM_IDATA_SOURCE_TYPE MA_Cross_Shift_Indi_SAR_SourceType = IDATA_ICUSTOM; // Source type -INPUT_GROUP("MA Cross Shift strategy: TEMA indicator params"); -INPUT int MA_Cross_Shift_Indi_TEMA_Period = 10; // Period -INPUT int MA_Cross_Shift_Indi_TEMA_MA_Shift = 0; // MA Shift -INPUT ENUM_APPLIED_PRICE MA_Cross_Shift_Indi_TEMA_Applied_Price = PRICE_WEIGHTED; // Applied Price -INPUT int MA_Cross_Shift_Indi_TEMA_Shift = 0; // Shift -INPUT int MA_Cross_Shift_Indi_TEMA_Shift2 = 10; // Shift 2 -INPUT ENUM_IDATA_SOURCE_TYPE MA_Cross_Shift_Indi_TEMA_SourceType = IDATA_BUILTIN; // Source type -INPUT_GROUP("MA Cross Shift strategy: VIDYA indicator params"); -INPUT int MA_Cross_Shift_Indi_VIDYA_Period = 30; // Period -INPUT int MA_Cross_Shift_Indi_VIDYA_MA_Period = 20; // MA Period -INPUT int MA_Cross_Shift_Indi_VIDYA_MA_Shift = 1; // MA Shift -INPUT ENUM_APPLIED_PRICE MA_Cross_Shift_Indi_VIDYA_Applied_Price = PRICE_WEIGHTED; // Applied Price -INPUT int MA_Cross_Shift_Indi_VIDYA_Shift = 0; // Shift -INPUT int MA_Cross_Shift_Indi_VIDYA_Shift2 = 10; // Shift 2 -INPUT ENUM_IDATA_SOURCE_TYPE MA_Cross_Shift_Indi_VIDYA_SourceType = IDATA_BUILTIN; // Source type +INPUT_GROUP("MA Cross Pivot strategy: main strategy params"); +INPUT ENUM_STG_MA_CROSS_PIVOT_TYPE MA_Cross_Pivot_Type = STG_MA_CROSS_PIVOT_TYPE_MA; // Indicator MA type +INPUT_GROUP("MA Cross Pivot strategy: strategy params"); +INPUT float MA_Cross_Pivot_LotSize = 0; // Lot size +INPUT int MA_Cross_Pivot_SignalOpenMethod = 0; // Signal open method (-127-127) +INPUT float MA_Cross_Pivot_SignalOpenLevel = 0.0f; // Signal open level +INPUT int MA_Cross_Pivot_SignalOpenFilterMethod = 32; // Signal open filter method +INPUT int MA_Cross_Pivot_SignalOpenFilterTime = 3; // Signal open filter time +INPUT int MA_Cross_Pivot_SignalOpenBoostMethod = 0; // Signal open boost method +INPUT int MA_Cross_Pivot_SignalCloseMethod = 0; // Signal close method (-127-127) +INPUT int MA_Cross_Pivot_SignalCloseFilter = 0; // Signal close filter (-127-127) +INPUT float MA_Cross_Pivot_SignalCloseLevel = 0.0f; // Signal close level +INPUT int MA_Cross_Pivot_PriceStopMethod = 1; // Price stop method (0-127) +INPUT float MA_Cross_Pivot_PriceStopLevel = 2; // Price stop level +INPUT int MA_Cross_Pivot_TickFilterMethod = 32; // Tick filter method +INPUT float MA_Cross_Pivot_MaxSpread = 4.0; // Max spread to trade (pips) +INPUT short MA_Cross_Pivot_Shift = 0; // Shift +INPUT float MA_Cross_Pivot_OrderCloseLoss = 80; // Order close loss +INPUT float MA_Cross_Pivot_OrderCloseProfit = 80; // Order close profit +INPUT int MA_Cross_Pivot_OrderCloseTime = -30; // Order close time in mins (>0) or bars (<0) +INPUT_GROUP("MA Cross Pivot strategy: AMA indicator params"); +INPUT int MA_Cross_Pivot_Indi_AMA_InpPeriodAMA = 20; // AMA period +INPUT int MA_Cross_Pivot_Indi_AMA_InpFastPeriodEMA = 4; // Fast EMA period +INPUT int MA_Cross_Pivot_Indi_AMA_InpSlowPeriodEMA = 30; // Slow EMA period +INPUT int MA_Cross_Pivot_Indi_AMA_InpShiftAMA = 4; // AMA shift +INPUT int MA_Cross_Pivot_Indi_AMA_Shift = 0; // Shift +INPUT int MA_Cross_Pivot_Indi_AMA_Shift2 = 10; // Shift 2 +INPUT ENUM_IDATA_SOURCE_TYPE MA_Cross_Pivot_Indi_AMA_SourceType = IDATA_BUILTIN; // Source type +INPUT_GROUP("MA Cross Pivot strategy: DEMA indicator params"); +INPUT int MA_Cross_Pivot_Indi_DEMA_Period = 25; // Period +INPUT int MA_Cross_Pivot_Indi_DEMA_MA_Shift = 6; // MA Shift +INPUT ENUM_APPLIED_PRICE MA_Cross_Pivot_Indi_DEMA_Applied_Price = PRICE_TYPICAL; // Applied Price +INPUT int MA_Cross_Pivot_Indi_DEMA_Shift = 0; // Shift +INPUT int MA_Cross_Pivot_Indi_DEMA_Shift2 = 10; // Shift 2 +INPUT ENUM_IDATA_SOURCE_TYPE MA_Cross_Pivot_Indi_DEMA_SourceType = IDATA_BUILTIN; // Source type +INPUT_GROUP("MA Cross Pivot strategy: FrAMA indicator params"); +INPUT int MA_Cross_Pivot_Indi_FrAMA_Period = 10; // Period +INPUT ENUM_APPLIED_PRICE MA_Cross_Pivot_Indi_FrAMA_Applied_Price = PRICE_MEDIAN; // Applied Price +INPUT int MA_Cross_Pivot_Indi_FrAMA_MA_Shift = 0; // MA Shift +INPUT int MA_Cross_Pivot_Indi_FrAMA_Shift = 0; // Shift +INPUT int MA_Cross_Pivot_Indi_FrAMA_Shift2 = 10; // Shift 2 +INPUT ENUM_IDATA_SOURCE_TYPE MA_Cross_Pivot_Indi_FrAMA_SourceType = IDATA_BUILTIN; // Source type +INPUT_GROUP("MA Cross Pivot strategy: Ichimoku indicator params"); +// INPUT ENUM_ICHIMOKU_LINE MA_Cross_Pivot_Indi_Ichimoku_MA_Line = LINE_TENKANSEN; // Ichimoku line for MA +INPUT int MA_Cross_Pivot_Indi_Ichimoku_Period_Tenkan_Sen = 30; // Period Tenkan Sen +INPUT int MA_Cross_Pivot_Indi_Ichimoku_Period_Kijun_Sen = 10; // Period Kijun Sen +INPUT int MA_Cross_Pivot_Indi_Ichimoku_Period_Senkou_Span_B = 30; // Period Senkou Span B +INPUT int MA_Cross_Pivot_Indi_Ichimoku_Shift = 1; // Shift +INPUT int MA_Cross_Pivot_Indi_Ichimoku_Shift2 = 1; // Shift 2 +INPUT ENUM_IDATA_SOURCE_TYPE MA_Cross_Pivot_Indi_Ichimoku_SourceType = IDATA_BUILTIN; // Source type +INPUT_GROUP("MA Cross Pivot strategy: MA indicator params"); +INPUT int MA_Cross_Pivot_Indi_MA_Period = 26; // Period +INPUT int MA_Cross_Pivot_Indi_MA_MA_Shift = 0; // MA Shift +INPUT ENUM_MA_METHOD MA_Cross_Pivot_Indi_MA_Method = MODE_LWMA; // MA Method +INPUT ENUM_APPLIED_PRICE MA_Cross_Pivot_Indi_MA_Applied_Price = PRICE_WEIGHTED; // Applied Price +INPUT int MA_Cross_Pivot_Indi_MA_Shift = 0; // Shift +INPUT int MA_Cross_Pivot_Indi_MA_Shift2 = 10; // Shift 2 +INPUT ENUM_IDATA_SOURCE_TYPE MA_Cross_Pivot_Indi_MA_SourceType = IDATA_BUILTIN; // Source type +INPUT_GROUP("MA Cross Pivot strategy: Price Channel indicator params"); +INPUT int MA_Cross_Pivot_Indi_PriceChannel_Period = 26; // Period +INPUT int MA_Cross_Pivot_Indi_PriceChannel_Shift = 0; // Shift +INPUT int MA_Cross_Pivot_Indi_PriceChannel_Shift2 = 10; // Shift 2 +INPUT ENUM_IDATA_SOURCE_TYPE MA_Cross_Pivot_Indi_PriceChannel_SourceType = IDATA_ICUSTOM; // Source type +INPUT_GROUP("MA Cross Pivot strategy: SAR indicator params"); +INPUT float MA_Cross_Pivot_Indi_SAR_Step = 0.04f; // Step +INPUT float MA_Cross_Pivot_Indi_SAR_Maximum_Stop = 0.4f; // Maximum stop +INPUT int MA_Cross_Pivot_Indi_SAR_Shift = 0; // Shift +INPUT int MA_Cross_Pivot_Indi_SAR_Shift2 = 10; // Shift 2 +INPUT ENUM_IDATA_SOURCE_TYPE MA_Cross_Pivot_Indi_SAR_SourceType = IDATA_ICUSTOM; // Source type +INPUT_GROUP("MA Cross Pivot strategy: TEMA indicator params"); +INPUT int MA_Cross_Pivot_Indi_TEMA_Period = 10; // Period +INPUT int MA_Cross_Pivot_Indi_TEMA_MA_Shift = 0; // MA Shift +INPUT ENUM_APPLIED_PRICE MA_Cross_Pivot_Indi_TEMA_Applied_Price = PRICE_WEIGHTED; // Applied Price +INPUT int MA_Cross_Pivot_Indi_TEMA_Shift = 0; // Shift +INPUT int MA_Cross_Pivot_Indi_TEMA_Shift2 = 10; // Shift 2 +INPUT ENUM_IDATA_SOURCE_TYPE MA_Cross_Pivot_Indi_TEMA_SourceType = IDATA_BUILTIN; // Source type +INPUT_GROUP("MA Cross Pivot strategy: VIDYA indicator params"); +INPUT int MA_Cross_Pivot_Indi_VIDYA_Period = 30; // Period +INPUT int MA_Cross_Pivot_Indi_VIDYA_MA_Period = 20; // MA Period +INPUT int MA_Cross_Pivot_Indi_VIDYA_MA_Shift = 1; // MA Shift +INPUT ENUM_APPLIED_PRICE MA_Cross_Pivot_Indi_VIDYA_Applied_Price = PRICE_WEIGHTED; // Applied Price +INPUT int MA_Cross_Pivot_Indi_VIDYA_Shift = 0; // Shift +INPUT int MA_Cross_Pivot_Indi_VIDYA_Shift2 = 10; // Shift 2 +INPUT ENUM_IDATA_SOURCE_TYPE MA_Cross_Pivot_Indi_VIDYA_SourceType = IDATA_BUILTIN; // Source type // Structs. // Defines struct with default user strategy values. -struct Stg_MA_Cross_Shift_Params_Defaults : StgParams { +struct Stg_MA_Cross_Pivot_Params_Defaults : StgParams { uint shift1, shift2; - Stg_MA_Cross_Shift_Params_Defaults() - : StgParams(::MA_Cross_Shift_SignalOpenMethod, ::MA_Cross_Shift_SignalOpenFilterMethod, - ::MA_Cross_Shift_SignalOpenLevel, ::MA_Cross_Shift_SignalOpenBoostMethod, - ::MA_Cross_Shift_SignalCloseMethod, ::MA_Cross_Shift_SignalCloseFilter, - ::MA_Cross_Shift_SignalCloseLevel, ::MA_Cross_Shift_PriceStopMethod, ::MA_Cross_Shift_PriceStopLevel, - ::MA_Cross_Shift_TickFilterMethod, ::MA_Cross_Shift_MaxSpread, ::MA_Cross_Shift_Shift) { - Set(STRAT_PARAM_LS, MA_Cross_Shift_LotSize); - Set(STRAT_PARAM_OCL, MA_Cross_Shift_OrderCloseLoss); - Set(STRAT_PARAM_OCP, MA_Cross_Shift_OrderCloseProfit); - Set(STRAT_PARAM_OCT, MA_Cross_Shift_OrderCloseTime); - Set(STRAT_PARAM_SOFT, MA_Cross_Shift_SignalOpenFilterTime); + Stg_MA_Cross_Pivot_Params_Defaults() + : StgParams(::MA_Cross_Pivot_SignalOpenMethod, ::MA_Cross_Pivot_SignalOpenFilterMethod, + ::MA_Cross_Pivot_SignalOpenLevel, ::MA_Cross_Pivot_SignalOpenBoostMethod, + ::MA_Cross_Pivot_SignalCloseMethod, ::MA_Cross_Pivot_SignalCloseFilter, + ::MA_Cross_Pivot_SignalCloseLevel, ::MA_Cross_Pivot_PriceStopMethod, ::MA_Cross_Pivot_PriceStopLevel, + ::MA_Cross_Pivot_TickFilterMethod, ::MA_Cross_Pivot_MaxSpread, ::MA_Cross_Pivot_Shift) { + Set(STRAT_PARAM_LS, MA_Cross_Pivot_LotSize); + Set(STRAT_PARAM_OCL, MA_Cross_Pivot_OrderCloseLoss); + Set(STRAT_PARAM_OCP, MA_Cross_Pivot_OrderCloseProfit); + Set(STRAT_PARAM_OCT, MA_Cross_Pivot_OrderCloseTime); + Set(STRAT_PARAM_SOFT, MA_Cross_Pivot_SignalOpenFilterTime); } // Getters. uint GetShift1() { return shift1; } @@ -127,22 +127,22 @@ struct Stg_MA_Cross_Shift_Params_Defaults : StgParams { void SetShift2(uint _value) { shift2 = _value; } }; -class Stg_MA_Cross_Shift : public Strategy { +class Stg_MA_Cross_Pivot : public Strategy { protected: - Stg_MA_Cross_Shift_Params_Defaults ssparams; + Stg_MA_Cross_Pivot_Params_Defaults ssparams; public: - Stg_MA_Cross_Shift(StgParams &_sparams, TradeParams &_tparams, ChartParams &_cparams, string _name = "") + Stg_MA_Cross_Pivot(StgParams &_sparams, TradeParams &_tparams, ChartParams &_cparams, string _name = "") : Strategy(_sparams, _tparams, _cparams, _name) {} - static Stg_MA_Cross_Shift *Init(ENUM_TIMEFRAMES _tf = NULL, EA *_ea = NULL) { + static Stg_MA_Cross_Pivot *Init(ENUM_TIMEFRAMES _tf = NULL, EA *_ea = NULL) { // Initialize strategy initial values. - Stg_MA_Cross_Shift_Params_Defaults stg_ma_defaults; + Stg_MA_Cross_Pivot_Params_Defaults stg_ma_defaults; StgParams _stg_params(stg_ma_defaults); // Initialize Strategy instance. ChartParams _cparams(_tf, _Symbol); TradeParams _tparams; - Strategy *_strat = new Stg_MA_Cross_Shift(_stg_params, _tparams, _cparams, "MA"); + Strategy *_strat = new Stg_MA_Cross_Pivot(_stg_params, _tparams, _cparams, "MA"); return _strat; } @@ -151,129 +151,129 @@ class Stg_MA_Cross_Shift : public Strategy { */ void OnInit() { // Initialize indicators. - switch (MA_Cross_Shift_Type) { - case STG_MA_CROSS_SHIFT_TYPE_AMA: // AMA + switch (MA_Cross_Pivot_Type) { + case STG_MA_CROSS_PIVOT_TYPE_AMA: // AMA { - IndiAMAParams _indi_params(::MA_Cross_Shift_Indi_AMA_InpPeriodAMA, ::MA_Cross_Shift_Indi_AMA_InpFastPeriodEMA, - ::MA_Cross_Shift_Indi_AMA_InpSlowPeriodEMA, ::MA_Cross_Shift_Indi_AMA_InpShiftAMA, - PRICE_TYPICAL, ::MA_Cross_Shift_Indi_AMA_Shift); - _indi_params.SetDataSourceType(::MA_Cross_Shift_Indi_AMA_SourceType); + IndiAMAParams _indi_params(::MA_Cross_Pivot_Indi_AMA_InpPeriodAMA, ::MA_Cross_Pivot_Indi_AMA_InpFastPeriodEMA, + ::MA_Cross_Pivot_Indi_AMA_InpSlowPeriodEMA, ::MA_Cross_Pivot_Indi_AMA_InpShiftAMA, + PRICE_TYPICAL, ::MA_Cross_Pivot_Indi_AMA_Shift); + _indi_params.SetDataSourceType(::MA_Cross_Pivot_Indi_AMA_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_AMA(_indi_params), ::MA_Cross_Shift_Type); - _indi_params.SetShift(::MA_Cross_Shift_Indi_AMA_Shift2); - SetIndicator(new Indi_AMA(_indi_params), ::MA_Cross_Shift_Type + 1); - ssparams.SetShift1(MA_Cross_Shift_Indi_AMA_Shift); - ssparams.SetShift2(MA_Cross_Shift_Indi_AMA_Shift2); + SetIndicator(new Indi_AMA(_indi_params), ::MA_Cross_Pivot_Type); + _indi_params.SetShift(::MA_Cross_Pivot_Indi_AMA_Shift2); + SetIndicator(new Indi_AMA(_indi_params), ::MA_Cross_Pivot_Type + 1); + ssparams.SetShift1(MA_Cross_Pivot_Indi_AMA_Shift); + ssparams.SetShift2(MA_Cross_Pivot_Indi_AMA_Shift2); break; } - case STG_MA_CROSS_SHIFT_TYPE_DEMA: // DEMA + case STG_MA_CROSS_PIVOT_TYPE_DEMA: // DEMA { - IndiDEIndiMAParams _indi_params(::MA_Cross_Shift_Indi_DEMA_Period, ::MA_Cross_Shift_Indi_DEMA_MA_Shift, - ::MA_Cross_Shift_Indi_DEMA_Applied_Price, ::MA_Cross_Shift_Indi_DEMA_Shift); - _indi_params.SetDataSourceType(::MA_Cross_Shift_Indi_DEMA_SourceType); + IndiDEIndiMAParams _indi_params(::MA_Cross_Pivot_Indi_DEMA_Period, ::MA_Cross_Pivot_Indi_DEMA_MA_Shift, + ::MA_Cross_Pivot_Indi_DEMA_Applied_Price, ::MA_Cross_Pivot_Indi_DEMA_Shift); + _indi_params.SetDataSourceType(::MA_Cross_Pivot_Indi_DEMA_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_DEMA(_indi_params), ::MA_Cross_Shift_Type); - _indi_params.SetShift(::MA_Cross_Shift_Indi_DEMA_Shift2); - SetIndicator(new Indi_DEMA(_indi_params), ::MA_Cross_Shift_Type + 1); - ssparams.SetShift1(MA_Cross_Shift_Indi_DEMA_Shift); - ssparams.SetShift2(MA_Cross_Shift_Indi_DEMA_Shift2); + SetIndicator(new Indi_DEMA(_indi_params), ::MA_Cross_Pivot_Type); + _indi_params.SetShift(::MA_Cross_Pivot_Indi_DEMA_Shift2); + SetIndicator(new Indi_DEMA(_indi_params), ::MA_Cross_Pivot_Type + 1); + ssparams.SetShift1(MA_Cross_Pivot_Indi_DEMA_Shift); + ssparams.SetShift2(MA_Cross_Pivot_Indi_DEMA_Shift2); break; } - case STG_MA_CROSS_SHIFT_TYPE_FRAMA: // FrAMA + case STG_MA_CROSS_PIVOT_TYPE_FRAMA: // FrAMA { - IndiFrAIndiMAParams _indi_params(::MA_Cross_Shift_Indi_FrAMA_Period, ::MA_Cross_Shift_Indi_FrAMA_MA_Shift, - ::MA_Cross_Shift_Indi_FrAMA_Applied_Price, ::MA_Cross_Shift_Indi_FrAMA_Shift); - _indi_params.SetDataSourceType(::MA_Cross_Shift_Indi_FrAMA_SourceType); + IndiFrAIndiMAParams _indi_params(::MA_Cross_Pivot_Indi_FrAMA_Period, ::MA_Cross_Pivot_Indi_FrAMA_MA_Shift, + ::MA_Cross_Pivot_Indi_FrAMA_Applied_Price, ::MA_Cross_Pivot_Indi_FrAMA_Shift); + _indi_params.SetDataSourceType(::MA_Cross_Pivot_Indi_FrAMA_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_FrAMA(_indi_params), ::MA_Cross_Shift_Type); - _indi_params.SetShift(::MA_Cross_Shift_Indi_FrAMA_Shift2); - SetIndicator(new Indi_FrAMA(_indi_params), ::MA_Cross_Shift_Type + 1); - ssparams.SetShift1(MA_Cross_Shift_Indi_FrAMA_Shift); - ssparams.SetShift2(MA_Cross_Shift_Indi_FrAMA_Shift2); + SetIndicator(new Indi_FrAMA(_indi_params), ::MA_Cross_Pivot_Type); + _indi_params.SetShift(::MA_Cross_Pivot_Indi_FrAMA_Shift2); + SetIndicator(new Indi_FrAMA(_indi_params), ::MA_Cross_Pivot_Type + 1); + ssparams.SetShift1(MA_Cross_Pivot_Indi_FrAMA_Shift); + ssparams.SetShift2(MA_Cross_Pivot_Indi_FrAMA_Shift2); break; } - case STG_MA_CROSS_SHIFT_TYPE_ICHIMOKU: // Ichimoku + case STG_MA_CROSS_PIVOT_TYPE_ICHIMOKU: // Ichimoku { IndiIchimokuParams _indi_params( - ::MA_Cross_Shift_Indi_Ichimoku_Period_Tenkan_Sen, ::MA_Cross_Shift_Indi_Ichimoku_Period_Kijun_Sen, - ::MA_Cross_Shift_Indi_Ichimoku_Period_Senkou_Span_B, ::MA_Cross_Shift_Indi_Ichimoku_Shift); - _indi_params.SetDataSourceType(::MA_Cross_Shift_Indi_Ichimoku_SourceType); + ::MA_Cross_Pivot_Indi_Ichimoku_Period_Tenkan_Sen, ::MA_Cross_Pivot_Indi_Ichimoku_Period_Kijun_Sen, + ::MA_Cross_Pivot_Indi_Ichimoku_Period_Senkou_Span_B, ::MA_Cross_Pivot_Indi_Ichimoku_Shift); + _indi_params.SetDataSourceType(::MA_Cross_Pivot_Indi_Ichimoku_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_Ichimoku(_indi_params), ::MA_Cross_Shift_Type); - _indi_params.SetShift(::MA_Cross_Shift_Indi_Ichimoku_Shift2); - SetIndicator(new Indi_Ichimoku(_indi_params), ::MA_Cross_Shift_Type + 1); - ssparams.SetShift1(MA_Cross_Shift_Indi_Ichimoku_Shift); - ssparams.SetShift2(MA_Cross_Shift_Indi_Ichimoku_Shift2); + SetIndicator(new Indi_Ichimoku(_indi_params), ::MA_Cross_Pivot_Type); + _indi_params.SetShift(::MA_Cross_Pivot_Indi_Ichimoku_Shift2); + SetIndicator(new Indi_Ichimoku(_indi_params), ::MA_Cross_Pivot_Type + 1); + ssparams.SetShift1(MA_Cross_Pivot_Indi_Ichimoku_Shift); + ssparams.SetShift2(MA_Cross_Pivot_Indi_Ichimoku_Shift2); break; } - case STG_MA_CROSS_SHIFT_TYPE_MA: // MA + case STG_MA_CROSS_PIVOT_TYPE_MA: // MA { - IndiMAParams _indi_params(::MA_Cross_Shift_Indi_MA_Period, ::MA_Cross_Shift_Indi_MA_MA_Shift, - ::MA_Cross_Shift_Indi_MA_Method, ::MA_Cross_Shift_Indi_MA_Applied_Price, - ::MA_Cross_Shift_Indi_MA_Shift); - _indi_params.SetDataSourceType(::MA_Cross_Shift_Indi_MA_SourceType); + IndiMAParams _indi_params(::MA_Cross_Pivot_Indi_MA_Period, ::MA_Cross_Pivot_Indi_MA_MA_Shift, + ::MA_Cross_Pivot_Indi_MA_Method, ::MA_Cross_Pivot_Indi_MA_Applied_Price, + ::MA_Cross_Pivot_Indi_MA_Shift); + _indi_params.SetDataSourceType(::MA_Cross_Pivot_Indi_MA_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_MA(_indi_params), ::MA_Cross_Shift_Type); - _indi_params.SetShift(::MA_Cross_Shift_Indi_MA_Shift2); - SetIndicator(new Indi_MA(_indi_params), ::MA_Cross_Shift_Type + 1); - ssparams.SetShift1(MA_Cross_Shift_Indi_MA_Shift); - ssparams.SetShift2(MA_Cross_Shift_Indi_MA_Shift2); + SetIndicator(new Indi_MA(_indi_params), ::MA_Cross_Pivot_Type); + _indi_params.SetShift(::MA_Cross_Pivot_Indi_MA_Shift2); + SetIndicator(new Indi_MA(_indi_params), ::MA_Cross_Pivot_Type + 1); + ssparams.SetShift1(MA_Cross_Pivot_Indi_MA_Shift); + ssparams.SetShift2(MA_Cross_Pivot_Indi_MA_Shift2); break; } - case STG_MA_CROSS_SHIFT_TYPE_PRICE_CHANNEL: // Price Channel + case STG_MA_CROSS_PIVOT_TYPE_PRICE_CHANNEL: // Price Channel { - IndiPriceChannelParams _indi_params(::MA_Cross_Shift_Indi_PriceChannel_Period, - ::MA_Cross_Shift_Indi_PriceChannel_Shift); - _indi_params.SetDataSourceType(::MA_Cross_Shift_Indi_PriceChannel_SourceType); + IndiPriceChannelParams _indi_params(::MA_Cross_Pivot_Indi_PriceChannel_Period, + ::MA_Cross_Pivot_Indi_PriceChannel_Shift); + _indi_params.SetDataSourceType(::MA_Cross_Pivot_Indi_PriceChannel_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_PriceChannel(_indi_params), ::MA_Cross_Shift_Type); - _indi_params.SetShift(::MA_Cross_Shift_Indi_PriceChannel_Shift2); - SetIndicator(new Indi_PriceChannel(_indi_params), ::MA_Cross_Shift_Type + 1); - ssparams.SetShift1(MA_Cross_Shift_Indi_PriceChannel_Shift); - ssparams.SetShift2(MA_Cross_Shift_Indi_PriceChannel_Shift2); + SetIndicator(new Indi_PriceChannel(_indi_params), ::MA_Cross_Pivot_Type); + _indi_params.SetShift(::MA_Cross_Pivot_Indi_PriceChannel_Shift2); + SetIndicator(new Indi_PriceChannel(_indi_params), ::MA_Cross_Pivot_Type + 1); + ssparams.SetShift1(MA_Cross_Pivot_Indi_PriceChannel_Shift); + ssparams.SetShift2(MA_Cross_Pivot_Indi_PriceChannel_Shift2); break; } - case STG_MA_CROSS_SHIFT_TYPE_SAR: // SAR + case STG_MA_CROSS_PIVOT_TYPE_SAR: // SAR { - IndiSARParams _indi_params(::MA_Cross_Shift_Indi_SAR_Step, ::MA_Cross_Shift_Indi_SAR_Maximum_Stop, - ::MA_Cross_Shift_Indi_SAR_Shift); - _indi_params.SetDataSourceType(::MA_Cross_Shift_Indi_SAR_SourceType); + IndiSARParams _indi_params(::MA_Cross_Pivot_Indi_SAR_Step, ::MA_Cross_Pivot_Indi_SAR_Maximum_Stop, + ::MA_Cross_Pivot_Indi_SAR_Shift); + _indi_params.SetDataSourceType(::MA_Cross_Pivot_Indi_SAR_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_SAR(_indi_params), ::MA_Cross_Shift_Type); - _indi_params.SetShift(::MA_Cross_Shift_Indi_SAR_Shift2); - SetIndicator(new Indi_SAR(_indi_params), ::MA_Cross_Shift_Type + 1); - ssparams.SetShift1(MA_Cross_Shift_Indi_SAR_Shift); - ssparams.SetShift2(MA_Cross_Shift_Indi_SAR_Shift2); + SetIndicator(new Indi_SAR(_indi_params), ::MA_Cross_Pivot_Type); + _indi_params.SetShift(::MA_Cross_Pivot_Indi_SAR_Shift2); + SetIndicator(new Indi_SAR(_indi_params), ::MA_Cross_Pivot_Type + 1); + ssparams.SetShift1(MA_Cross_Pivot_Indi_SAR_Shift); + ssparams.SetShift2(MA_Cross_Pivot_Indi_SAR_Shift2); break; } - case STG_MA_CROSS_SHIFT_TYPE_TEMA: // TEMA + case STG_MA_CROSS_PIVOT_TYPE_TEMA: // TEMA { - IndiTEMAParams _indi_params(::MA_Cross_Shift_Indi_TEMA_Period, ::MA_Cross_Shift_Indi_TEMA_MA_Shift, - ::MA_Cross_Shift_Indi_TEMA_Applied_Price, ::MA_Cross_Shift_Indi_TEMA_Shift); - _indi_params.SetDataSourceType(::MA_Cross_Shift_Indi_TEMA_SourceType); + IndiTEMAParams _indi_params(::MA_Cross_Pivot_Indi_TEMA_Period, ::MA_Cross_Pivot_Indi_TEMA_MA_Shift, + ::MA_Cross_Pivot_Indi_TEMA_Applied_Price, ::MA_Cross_Pivot_Indi_TEMA_Shift); + _indi_params.SetDataSourceType(::MA_Cross_Pivot_Indi_TEMA_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_TEMA(_indi_params), ::MA_Cross_Shift_Type); - _indi_params.SetShift(::MA_Cross_Shift_Indi_TEMA_Shift2); - SetIndicator(new Indi_TEMA(_indi_params), ::MA_Cross_Shift_Type + 1); - ssparams.SetShift1(MA_Cross_Shift_Indi_TEMA_Shift); - ssparams.SetShift2(MA_Cross_Shift_Indi_TEMA_Shift2); + SetIndicator(new Indi_TEMA(_indi_params), ::MA_Cross_Pivot_Type); + _indi_params.SetShift(::MA_Cross_Pivot_Indi_TEMA_Shift2); + SetIndicator(new Indi_TEMA(_indi_params), ::MA_Cross_Pivot_Type + 1); + ssparams.SetShift1(MA_Cross_Pivot_Indi_TEMA_Shift); + ssparams.SetShift2(MA_Cross_Pivot_Indi_TEMA_Shift2); break; } - case STG_MA_CROSS_SHIFT_TYPE_VIDYA: // VIDYA + case STG_MA_CROSS_PIVOT_TYPE_VIDYA: // VIDYA { - IndiVIDYAParams _indi_params(::MA_Cross_Shift_Indi_VIDYA_Period, ::MA_Cross_Shift_Indi_VIDYA_MA_Period, - ::MA_Cross_Shift_Indi_VIDYA_MA_Shift, ::MA_Cross_Shift_Indi_VIDYA_Applied_Price, - ::MA_Cross_Shift_Indi_VIDYA_Shift); - _indi_params.SetDataSourceType(::MA_Cross_Shift_Indi_VIDYA_SourceType); + IndiVIDYAParams _indi_params(::MA_Cross_Pivot_Indi_VIDYA_Period, ::MA_Cross_Pivot_Indi_VIDYA_MA_Period, + ::MA_Cross_Pivot_Indi_VIDYA_MA_Shift, ::MA_Cross_Pivot_Indi_VIDYA_Applied_Price, + ::MA_Cross_Pivot_Indi_VIDYA_Shift); + _indi_params.SetDataSourceType(::MA_Cross_Pivot_Indi_VIDYA_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_VIDYA(_indi_params), ::MA_Cross_Shift_Type); - _indi_params.SetShift(::MA_Cross_Shift_Indi_VIDYA_Shift2); - SetIndicator(new Indi_VIDYA(_indi_params), ::MA_Cross_Shift_Type + 1); - ssparams.SetShift1(MA_Cross_Shift_Indi_VIDYA_Shift); - ssparams.SetShift2(MA_Cross_Shift_Indi_VIDYA_Shift2); + SetIndicator(new Indi_VIDYA(_indi_params), ::MA_Cross_Pivot_Type); + _indi_params.SetShift(::MA_Cross_Pivot_Indi_VIDYA_Shift2); + SetIndicator(new Indi_VIDYA(_indi_params), ::MA_Cross_Pivot_Type + 1); + ssparams.SetShift1(MA_Cross_Pivot_Indi_VIDYA_Shift); + ssparams.SetShift2(MA_Cross_Pivot_Indi_VIDYA_Shift2); break; } - case STG_MA_CROSS_SHIFT_TYPE_0_NONE: // (None) + case STG_MA_CROSS_PIVOT_TYPE_0_NONE: // (None) default: break; } @@ -283,8 +283,8 @@ class Stg_MA_Cross_Shift : public Strategy { * Check strategy's opening signal. */ bool SignalOpen(ENUM_ORDER_TYPE _cmd, int _method = 0, float _level = 0.0f, int _shift = 0) { - IndicatorBase *_indi1 = GetIndicator(::MA_Cross_Shift_Type); - IndicatorBase *_indi2 = GetIndicator(::MA_Cross_Shift_Type + 1); + IndicatorBase *_indi1 = GetIndicator(::MA_Cross_Pivot_Type); + IndicatorBase *_indi2 = GetIndicator(::MA_Cross_Pivot_Type + 1); // uint _ishift1 = _indi1.GetParams().GetShift(); // @todo: Convert into Get(). // uint _ishift2 = _indi2.GetParams().GetShift(); // @todo: Convert into Get(). uint _ishift1 = ssparams.GetShift1(); diff --git a/Stg_MA_Cross_Pivot.mqproj b/Stg_MA_Cross_Pivot.mqproj index 4527d51..9bb99c6 100644 --- a/Stg_MA_Cross_Pivot.mqproj +++ b/Stg_MA_Cross_Pivot.mqproj @@ -15,7 +15,7 @@ "files": [ { - "path":"Stg_MA_Cross_Shift.mq5", + "path":"Stg_MA_Cross_Pivot.mq5", "compile":true, "relative_to_project":true }, @@ -215,7 +215,7 @@ "relative_to_project":false }, { - "path":"Stg_MA_Cross_Shift.mqh", + "path":"Stg_MA_Cross_Pivot.mqh", "compile":false, "relative_to_project":true }, @@ -795,4 +795,4 @@ "relative_to_project":false } ] -} \ No newline at end of file +} From 30049edb21ad3b21500f951e3637485a923e20a7 Mon Sep 17 00:00:00 2001 From: kenorb Date: Sun, 3 Sep 2023 14:57:46 +0100 Subject: [PATCH 3/5] Adds initial strategy signal logic --- Stg_MA_Cross_Pivot.mqh | 113 ++++++++++------------------------------- 1 file changed, 26 insertions(+), 87 deletions(-) diff --git a/Stg_MA_Cross_Pivot.mqh b/Stg_MA_Cross_Pivot.mqh index de4c2ee..5d4fbb8 100644 --- a/Stg_MA_Cross_Pivot.mqh +++ b/Stg_MA_Cross_Pivot.mqh @@ -18,15 +18,15 @@ enum ENUM_STG_MA_CROSS_PIVOT_TYPE { // User params. INPUT_GROUP("MA Cross Pivot strategy: main strategy params"); -INPUT ENUM_STG_MA_CROSS_PIVOT_TYPE MA_Cross_Pivot_Type = STG_MA_CROSS_PIVOT_TYPE_MA; // Indicator MA type +INPUT ENUM_STG_MA_CROSS_PIVOT_TYPE MA_Cross_Pivot_Type = STG_MA_CROSS_PIVOT_TYPE_FRAMA; // Indicator MA type INPUT_GROUP("MA Cross Pivot strategy: strategy params"); INPUT float MA_Cross_Pivot_LotSize = 0; // Lot size -INPUT int MA_Cross_Pivot_SignalOpenMethod = 0; // Signal open method (-127-127) +INPUT int MA_Cross_Pivot_SignalOpenMethod = 1; // Signal open method (-3-3) INPUT float MA_Cross_Pivot_SignalOpenLevel = 0.0f; // Signal open level INPUT int MA_Cross_Pivot_SignalOpenFilterMethod = 32; // Signal open filter method INPUT int MA_Cross_Pivot_SignalOpenFilterTime = 3; // Signal open filter time INPUT int MA_Cross_Pivot_SignalOpenBoostMethod = 0; // Signal open boost method -INPUT int MA_Cross_Pivot_SignalCloseMethod = 0; // Signal close method (-127-127) +INPUT int MA_Cross_Pivot_SignalCloseMethod = 1; // Signal close method (-3-3) INPUT int MA_Cross_Pivot_SignalCloseFilter = 0; // Signal close filter (-127-127) INPUT float MA_Cross_Pivot_SignalCloseLevel = 0.0f; // Signal close level INPUT int MA_Cross_Pivot_PriceStopMethod = 1; // Price stop method (0-127) @@ -43,21 +43,18 @@ INPUT int MA_Cross_Pivot_Indi_AMA_InpFastPeriodEMA = 4; INPUT int MA_Cross_Pivot_Indi_AMA_InpSlowPeriodEMA = 30; // Slow EMA period INPUT int MA_Cross_Pivot_Indi_AMA_InpShiftAMA = 4; // AMA shift INPUT int MA_Cross_Pivot_Indi_AMA_Shift = 0; // Shift -INPUT int MA_Cross_Pivot_Indi_AMA_Shift2 = 10; // Shift 2 INPUT ENUM_IDATA_SOURCE_TYPE MA_Cross_Pivot_Indi_AMA_SourceType = IDATA_BUILTIN; // Source type INPUT_GROUP("MA Cross Pivot strategy: DEMA indicator params"); INPUT int MA_Cross_Pivot_Indi_DEMA_Period = 25; // Period INPUT int MA_Cross_Pivot_Indi_DEMA_MA_Shift = 6; // MA Shift INPUT ENUM_APPLIED_PRICE MA_Cross_Pivot_Indi_DEMA_Applied_Price = PRICE_TYPICAL; // Applied Price INPUT int MA_Cross_Pivot_Indi_DEMA_Shift = 0; // Shift -INPUT int MA_Cross_Pivot_Indi_DEMA_Shift2 = 10; // Shift 2 INPUT ENUM_IDATA_SOURCE_TYPE MA_Cross_Pivot_Indi_DEMA_SourceType = IDATA_BUILTIN; // Source type INPUT_GROUP("MA Cross Pivot strategy: FrAMA indicator params"); INPUT int MA_Cross_Pivot_Indi_FrAMA_Period = 10; // Period INPUT ENUM_APPLIED_PRICE MA_Cross_Pivot_Indi_FrAMA_Applied_Price = PRICE_MEDIAN; // Applied Price INPUT int MA_Cross_Pivot_Indi_FrAMA_MA_Shift = 0; // MA Shift INPUT int MA_Cross_Pivot_Indi_FrAMA_Shift = 0; // Shift -INPUT int MA_Cross_Pivot_Indi_FrAMA_Shift2 = 10; // Shift 2 INPUT ENUM_IDATA_SOURCE_TYPE MA_Cross_Pivot_Indi_FrAMA_SourceType = IDATA_BUILTIN; // Source type INPUT_GROUP("MA Cross Pivot strategy: Ichimoku indicator params"); // INPUT ENUM_ICHIMOKU_LINE MA_Cross_Pivot_Indi_Ichimoku_MA_Line = LINE_TENKANSEN; // Ichimoku line for MA @@ -65,7 +62,6 @@ INPUT int MA_Cross_Pivot_Indi_Ichimoku_Period_Tenkan_Sen = 30; INPUT int MA_Cross_Pivot_Indi_Ichimoku_Period_Kijun_Sen = 10; // Period Kijun Sen INPUT int MA_Cross_Pivot_Indi_Ichimoku_Period_Senkou_Span_B = 30; // Period Senkou Span B INPUT int MA_Cross_Pivot_Indi_Ichimoku_Shift = 1; // Shift -INPUT int MA_Cross_Pivot_Indi_Ichimoku_Shift2 = 1; // Shift 2 INPUT ENUM_IDATA_SOURCE_TYPE MA_Cross_Pivot_Indi_Ichimoku_SourceType = IDATA_BUILTIN; // Source type INPUT_GROUP("MA Cross Pivot strategy: MA indicator params"); INPUT int MA_Cross_Pivot_Indi_MA_Period = 26; // Period @@ -73,25 +69,21 @@ INPUT int MA_Cross_Pivot_Indi_MA_MA_Shift = 0; INPUT ENUM_MA_METHOD MA_Cross_Pivot_Indi_MA_Method = MODE_LWMA; // MA Method INPUT ENUM_APPLIED_PRICE MA_Cross_Pivot_Indi_MA_Applied_Price = PRICE_WEIGHTED; // Applied Price INPUT int MA_Cross_Pivot_Indi_MA_Shift = 0; // Shift -INPUT int MA_Cross_Pivot_Indi_MA_Shift2 = 10; // Shift 2 INPUT ENUM_IDATA_SOURCE_TYPE MA_Cross_Pivot_Indi_MA_SourceType = IDATA_BUILTIN; // Source type INPUT_GROUP("MA Cross Pivot strategy: Price Channel indicator params"); INPUT int MA_Cross_Pivot_Indi_PriceChannel_Period = 26; // Period INPUT int MA_Cross_Pivot_Indi_PriceChannel_Shift = 0; // Shift -INPUT int MA_Cross_Pivot_Indi_PriceChannel_Shift2 = 10; // Shift 2 INPUT ENUM_IDATA_SOURCE_TYPE MA_Cross_Pivot_Indi_PriceChannel_SourceType = IDATA_ICUSTOM; // Source type INPUT_GROUP("MA Cross Pivot strategy: SAR indicator params"); INPUT float MA_Cross_Pivot_Indi_SAR_Step = 0.04f; // Step INPUT float MA_Cross_Pivot_Indi_SAR_Maximum_Stop = 0.4f; // Maximum stop INPUT int MA_Cross_Pivot_Indi_SAR_Shift = 0; // Shift -INPUT int MA_Cross_Pivot_Indi_SAR_Shift2 = 10; // Shift 2 INPUT ENUM_IDATA_SOURCE_TYPE MA_Cross_Pivot_Indi_SAR_SourceType = IDATA_ICUSTOM; // Source type INPUT_GROUP("MA Cross Pivot strategy: TEMA indicator params"); INPUT int MA_Cross_Pivot_Indi_TEMA_Period = 10; // Period INPUT int MA_Cross_Pivot_Indi_TEMA_MA_Shift = 0; // MA Shift INPUT ENUM_APPLIED_PRICE MA_Cross_Pivot_Indi_TEMA_Applied_Price = PRICE_WEIGHTED; // Applied Price INPUT int MA_Cross_Pivot_Indi_TEMA_Shift = 0; // Shift -INPUT int MA_Cross_Pivot_Indi_TEMA_Shift2 = 10; // Shift 2 INPUT ENUM_IDATA_SOURCE_TYPE MA_Cross_Pivot_Indi_TEMA_SourceType = IDATA_BUILTIN; // Source type INPUT_GROUP("MA Cross Pivot strategy: VIDYA indicator params"); INPUT int MA_Cross_Pivot_Indi_VIDYA_Period = 30; // Period @@ -99,14 +91,12 @@ INPUT int MA_Cross_Pivot_Indi_VIDYA_MA_Period = 20; INPUT int MA_Cross_Pivot_Indi_VIDYA_MA_Shift = 1; // MA Shift INPUT ENUM_APPLIED_PRICE MA_Cross_Pivot_Indi_VIDYA_Applied_Price = PRICE_WEIGHTED; // Applied Price INPUT int MA_Cross_Pivot_Indi_VIDYA_Shift = 0; // Shift -INPUT int MA_Cross_Pivot_Indi_VIDYA_Shift2 = 10; // Shift 2 INPUT ENUM_IDATA_SOURCE_TYPE MA_Cross_Pivot_Indi_VIDYA_SourceType = IDATA_BUILTIN; // Source type // Structs. // Defines struct with default user strategy values. struct Stg_MA_Cross_Pivot_Params_Defaults : StgParams { - uint shift1, shift2; Stg_MA_Cross_Pivot_Params_Defaults() : StgParams(::MA_Cross_Pivot_SignalOpenMethod, ::MA_Cross_Pivot_SignalOpenFilterMethod, ::MA_Cross_Pivot_SignalOpenLevel, ::MA_Cross_Pivot_SignalOpenBoostMethod, @@ -119,12 +109,6 @@ struct Stg_MA_Cross_Pivot_Params_Defaults : StgParams { Set(STRAT_PARAM_OCT, MA_Cross_Pivot_OrderCloseTime); Set(STRAT_PARAM_SOFT, MA_Cross_Pivot_SignalOpenFilterTime); } - // Getters. - uint GetShift1() { return shift1; } - uint GetShift2() { return shift2; } - // Setters. - void SetShift1(uint _value) { shift1 = _value; } - void SetShift2(uint _value) { shift2 = _value; } }; class Stg_MA_Cross_Pivot : public Strategy { @@ -160,10 +144,6 @@ class Stg_MA_Cross_Pivot : public Strategy { _indi_params.SetDataSourceType(::MA_Cross_Pivot_Indi_AMA_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); SetIndicator(new Indi_AMA(_indi_params), ::MA_Cross_Pivot_Type); - _indi_params.SetShift(::MA_Cross_Pivot_Indi_AMA_Shift2); - SetIndicator(new Indi_AMA(_indi_params), ::MA_Cross_Pivot_Type + 1); - ssparams.SetShift1(MA_Cross_Pivot_Indi_AMA_Shift); - ssparams.SetShift2(MA_Cross_Pivot_Indi_AMA_Shift2); break; } case STG_MA_CROSS_PIVOT_TYPE_DEMA: // DEMA @@ -173,10 +153,6 @@ class Stg_MA_Cross_Pivot : public Strategy { _indi_params.SetDataSourceType(::MA_Cross_Pivot_Indi_DEMA_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); SetIndicator(new Indi_DEMA(_indi_params), ::MA_Cross_Pivot_Type); - _indi_params.SetShift(::MA_Cross_Pivot_Indi_DEMA_Shift2); - SetIndicator(new Indi_DEMA(_indi_params), ::MA_Cross_Pivot_Type + 1); - ssparams.SetShift1(MA_Cross_Pivot_Indi_DEMA_Shift); - ssparams.SetShift2(MA_Cross_Pivot_Indi_DEMA_Shift2); break; } case STG_MA_CROSS_PIVOT_TYPE_FRAMA: // FrAMA @@ -186,10 +162,6 @@ class Stg_MA_Cross_Pivot : public Strategy { _indi_params.SetDataSourceType(::MA_Cross_Pivot_Indi_FrAMA_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); SetIndicator(new Indi_FrAMA(_indi_params), ::MA_Cross_Pivot_Type); - _indi_params.SetShift(::MA_Cross_Pivot_Indi_FrAMA_Shift2); - SetIndicator(new Indi_FrAMA(_indi_params), ::MA_Cross_Pivot_Type + 1); - ssparams.SetShift1(MA_Cross_Pivot_Indi_FrAMA_Shift); - ssparams.SetShift2(MA_Cross_Pivot_Indi_FrAMA_Shift2); break; } case STG_MA_CROSS_PIVOT_TYPE_ICHIMOKU: // Ichimoku @@ -200,10 +172,6 @@ class Stg_MA_Cross_Pivot : public Strategy { _indi_params.SetDataSourceType(::MA_Cross_Pivot_Indi_Ichimoku_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); SetIndicator(new Indi_Ichimoku(_indi_params), ::MA_Cross_Pivot_Type); - _indi_params.SetShift(::MA_Cross_Pivot_Indi_Ichimoku_Shift2); - SetIndicator(new Indi_Ichimoku(_indi_params), ::MA_Cross_Pivot_Type + 1); - ssparams.SetShift1(MA_Cross_Pivot_Indi_Ichimoku_Shift); - ssparams.SetShift2(MA_Cross_Pivot_Indi_Ichimoku_Shift2); break; } case STG_MA_CROSS_PIVOT_TYPE_MA: // MA @@ -214,10 +182,6 @@ class Stg_MA_Cross_Pivot : public Strategy { _indi_params.SetDataSourceType(::MA_Cross_Pivot_Indi_MA_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); SetIndicator(new Indi_MA(_indi_params), ::MA_Cross_Pivot_Type); - _indi_params.SetShift(::MA_Cross_Pivot_Indi_MA_Shift2); - SetIndicator(new Indi_MA(_indi_params), ::MA_Cross_Pivot_Type + 1); - ssparams.SetShift1(MA_Cross_Pivot_Indi_MA_Shift); - ssparams.SetShift2(MA_Cross_Pivot_Indi_MA_Shift2); break; } case STG_MA_CROSS_PIVOT_TYPE_PRICE_CHANNEL: // Price Channel @@ -227,10 +191,6 @@ class Stg_MA_Cross_Pivot : public Strategy { _indi_params.SetDataSourceType(::MA_Cross_Pivot_Indi_PriceChannel_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); SetIndicator(new Indi_PriceChannel(_indi_params), ::MA_Cross_Pivot_Type); - _indi_params.SetShift(::MA_Cross_Pivot_Indi_PriceChannel_Shift2); - SetIndicator(new Indi_PriceChannel(_indi_params), ::MA_Cross_Pivot_Type + 1); - ssparams.SetShift1(MA_Cross_Pivot_Indi_PriceChannel_Shift); - ssparams.SetShift2(MA_Cross_Pivot_Indi_PriceChannel_Shift2); break; } case STG_MA_CROSS_PIVOT_TYPE_SAR: // SAR @@ -240,10 +200,6 @@ class Stg_MA_Cross_Pivot : public Strategy { _indi_params.SetDataSourceType(::MA_Cross_Pivot_Indi_SAR_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); SetIndicator(new Indi_SAR(_indi_params), ::MA_Cross_Pivot_Type); - _indi_params.SetShift(::MA_Cross_Pivot_Indi_SAR_Shift2); - SetIndicator(new Indi_SAR(_indi_params), ::MA_Cross_Pivot_Type + 1); - ssparams.SetShift1(MA_Cross_Pivot_Indi_SAR_Shift); - ssparams.SetShift2(MA_Cross_Pivot_Indi_SAR_Shift2); break; } case STG_MA_CROSS_PIVOT_TYPE_TEMA: // TEMA @@ -253,10 +209,6 @@ class Stg_MA_Cross_Pivot : public Strategy { _indi_params.SetDataSourceType(::MA_Cross_Pivot_Indi_TEMA_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); SetIndicator(new Indi_TEMA(_indi_params), ::MA_Cross_Pivot_Type); - _indi_params.SetShift(::MA_Cross_Pivot_Indi_TEMA_Shift2); - SetIndicator(new Indi_TEMA(_indi_params), ::MA_Cross_Pivot_Type + 1); - ssparams.SetShift1(MA_Cross_Pivot_Indi_TEMA_Shift); - ssparams.SetShift2(MA_Cross_Pivot_Indi_TEMA_Shift2); break; } case STG_MA_CROSS_PIVOT_TYPE_VIDYA: // VIDYA @@ -267,10 +219,6 @@ class Stg_MA_Cross_Pivot : public Strategy { _indi_params.SetDataSourceType(::MA_Cross_Pivot_Indi_VIDYA_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); SetIndicator(new Indi_VIDYA(_indi_params), ::MA_Cross_Pivot_Type); - _indi_params.SetShift(::MA_Cross_Pivot_Indi_VIDYA_Shift2); - SetIndicator(new Indi_VIDYA(_indi_params), ::MA_Cross_Pivot_Type + 1); - ssparams.SetShift1(MA_Cross_Pivot_Indi_VIDYA_Shift); - ssparams.SetShift2(MA_Cross_Pivot_Indi_VIDYA_Shift2); break; } case STG_MA_CROSS_PIVOT_TYPE_0_NONE: // (None) @@ -283,54 +231,45 @@ class Stg_MA_Cross_Pivot : public Strategy { * Check strategy's opening signal. */ bool SignalOpen(ENUM_ORDER_TYPE _cmd, int _method = 0, float _level = 0.0f, int _shift = 0) { - IndicatorBase *_indi1 = GetIndicator(::MA_Cross_Pivot_Type); - IndicatorBase *_indi2 = GetIndicator(::MA_Cross_Pivot_Type + 1); - // uint _ishift1 = _indi1.GetParams().GetShift(); // @todo: Convert into Get(). - // uint _ishift2 = _indi2.GetParams().GetShift(); // @todo: Convert into Get(). - uint _ishift1 = ssparams.GetShift1(); - uint _ishift2 = ssparams.GetShift2(); + Chart *_chart = trade.GetChart(); + IndicatorBase *_indi = GetIndicator(::MA_Cross_Pivot_Type); + // uint _ishift = _indi.GetParams().GetShift(); // @todo: Convert into Get(). // bool _result = _indi.GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift); // @fixme + uint _ishift = _shift; bool _result = true; if (!_result) { // Returns false when indicator data is not valid. return false; } // float _level_pips = (float)(_level * _chart.GetPipSize()); - double _value1 = _indi1[_ishift1][0]; - double _value2 = _indi2[_ishift2][0]; + double _value1 = _indi[_ishift][0]; + ChartEntry _ohlc_d1 = _chart.GetEntry(PERIOD_D1, _shift, _chart.GetSymbol()); + double _d1_pivot = _ohlc_d1.bar.ohlc.GetPivot(); switch (_cmd) { case ORDER_TYPE_BUY: // Buy signal. - _result &= _indi1.IsIncreasing(1, 0, _ishift1); - _result &= _indi1[_ishift1][0] > _indi2[_ishift2][0]; - _result &= _indi1[_ishift1 + 1][0] < _indi2[_ishift2 + 1][0]; - //_result &= Math::ChangeInPct(_indi1[_ishift1 + 1][0], _indi1[_ishift1][0], true) > _level; + _result &= _indi.IsIncreasing(1, 0, _ishift); + _result &= _indi[_shift][0] > _d1_pivot; + _result &= _indi[_shift + 1][0] < _d1_pivot; + //_result &= Math::ChangeInPct(_indi[_ishift + 1][0], _indi[_ishift][0], true) > _level; if (_result && _method != 0) { - if (METHOD(_method, 0)) _result &= _indi1[_ishift1][0] < _indi1[_ishift1 + 3][0]; - if (METHOD(_method, 1)) _result &= _indi2[_ishift2][0] < _indi2[_ishift2 + 3][0]; - if (METHOD(_method, 2)) - _result &= fmax4(_indi1[_ishift1][0], _indi1[_ishift1 + 1][0], _indi1[_ishift1 + 2][0], - _indi1[_ishift1 + 3][0]) == _indi1[_ishift1][0]; - if (METHOD(_method, 3)) - _result &= fmax4(_indi2[_ishift2][0], _indi2[_ishift2 + 1][0], _indi2[_ishift2 + 2][0], - _indi2[_ishift2 + 3][0]) == _indi2[_ishift2][0]; + if (METHOD(_method, 0)) _result &= _indi[_ishift + 3][0] < _d1_pivot; + if (METHOD(_method, 1)) + _result &= fmax4(_indi[_ishift][0], _indi[_ishift + 1][0], _indi[_ishift + 2][0], _indi[_ishift + 3][0]) == + _indi[_ishift][0]; } break; case ORDER_TYPE_SELL: // Sell signal. - _result &= _indi1.IsDecreasing(1, 0, _ishift1); - _result &= _indi1[_ishift1][0] < _indi2[_ishift2][0]; - _result &= _indi1[_ishift1 + 1][0] > _indi2[_ishift2 + 1][0]; - //_result &= Math::ChangeInPct(_indi1[_ishift1 + 1][0], _indi1[_ishift1][0], true) < _level; + _result &= _indi.IsDecreasing(1, 0, _ishift); + _result &= _indi[_shift][0] < _d1_pivot; + _result &= _indi[_shift + 1][0] > _d1_pivot; + //_result &= Math::ChangeInPct(_indi[_ishift + 1][0], _indi[_ishift][0], true) < _level; if (_result && _method != 0) { - if (METHOD(_method, 0)) _result &= _indi1[_ishift1][0] > _indi1[_ishift1 + 3][0]; - if (METHOD(_method, 1)) _result &= _indi2[_ishift2][0] > _indi2[_ishift2 + 3][0]; - if (METHOD(_method, 2)) - _result &= fmin4(_indi1[_ishift1][0], _indi1[_ishift1 + 1][0], _indi1[_ishift1 + 2][0], - _indi1[_ishift1 + 3][0]) == _indi1[_ishift1][0]; - if (METHOD(_method, 3)) - _result &= fmin4(_indi2[_ishift2][0], _indi2[_ishift2 + 1][0], _indi2[_ishift2 + 2][0], - _indi2[_ishift2 + 3][0]) == _indi2[_ishift2][0]; + if (METHOD(_method, 0)) _result &= _indi[_ishift + 3][0] > _d1_pivot; + if (METHOD(_method, 1)) + _result &= fmin4(_indi[_ishift][0], _indi[_ishift + 1][0], _indi[_ishift + 2][0], _indi[_ishift + 3][0]) == + _indi[_ishift][0]; } break; } From 953d904cdd0ddbd18db74deb196757b8cc443ad0 Mon Sep 17 00:00:00 2001 From: kenorb Date: Wed, 6 Sep 2023 00:01:20 +0100 Subject: [PATCH 4/5] Sets DEMA as default indicator --- Stg_MA_Cross_Pivot.mqh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Stg_MA_Cross_Pivot.mqh b/Stg_MA_Cross_Pivot.mqh index 5d4fbb8..678f5dc 100644 --- a/Stg_MA_Cross_Pivot.mqh +++ b/Stg_MA_Cross_Pivot.mqh @@ -18,7 +18,7 @@ enum ENUM_STG_MA_CROSS_PIVOT_TYPE { // User params. INPUT_GROUP("MA Cross Pivot strategy: main strategy params"); -INPUT ENUM_STG_MA_CROSS_PIVOT_TYPE MA_Cross_Pivot_Type = STG_MA_CROSS_PIVOT_TYPE_FRAMA; // Indicator MA type +INPUT ENUM_STG_MA_CROSS_PIVOT_TYPE MA_Cross_Pivot_Type = STG_MA_CROSS_PIVOT_TYPE_DEMA; // Indicator MA type INPUT_GROUP("MA Cross Pivot strategy: strategy params"); INPUT float MA_Cross_Pivot_LotSize = 0; // Lot size INPUT int MA_Cross_Pivot_SignalOpenMethod = 1; // Signal open method (-3-3) From 733bd2627ea7bf5b70d8738eb16e79b2d4d16d4c Mon Sep 17 00:00:00 2001 From: kenorb Date: Wed, 6 Sep 2023 00:19:05 +0100 Subject: [PATCH 5/5] Check pivot for the day before --- Stg_MA_Cross_Pivot.mqh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Stg_MA_Cross_Pivot.mqh b/Stg_MA_Cross_Pivot.mqh index 678f5dc..87dcf17 100644 --- a/Stg_MA_Cross_Pivot.mqh +++ b/Stg_MA_Cross_Pivot.mqh @@ -243,7 +243,7 @@ class Stg_MA_Cross_Pivot : public Strategy { } // float _level_pips = (float)(_level * _chart.GetPipSize()); double _value1 = _indi[_ishift][0]; - ChartEntry _ohlc_d1 = _chart.GetEntry(PERIOD_D1, _shift, _chart.GetSymbol()); + ChartEntry _ohlc_d1 = _chart.GetEntry(PERIOD_D1, _shift + 1, _chart.GetSymbol()); double _d1_pivot = _ohlc_d1.bar.ohlc.GetPivot(); switch (_cmd) { case ORDER_TYPE_BUY: