From 065ced2fb69e169da35704176245b555995253e7 Mon Sep 17 00:00:00 2001 From: kenorb Date: Sun, 10 Sep 2023 15:30:05 +0100 Subject: [PATCH 1/6] Renames strategy to Retracement --- .github/workflows/backtest.yml | 6 +++--- .github/workflows/compile.yml | 4 ++-- README.md | 5 ++--- Stg_MA_Cross_Sup_Res.mq4 => Stg_Retracement.mq4 | 4 ++-- Stg_MA_Cross_Sup_Res.mq5 => Stg_Retracement.mq5 | 2 +- Stg_MA_Cross_Sup_Res.mqh => Stg_Retracement.mqh | 0 Stg_MA_Cross_Sup_Res.mqproj => Stg_Retracement.mqproj | 0 7 files changed, 10 insertions(+), 11 deletions(-) rename Stg_MA_Cross_Sup_Res.mq4 => Stg_Retracement.mq4 (83%) rename Stg_MA_Cross_Sup_Res.mq5 => Stg_Retracement.mq5 (98%) rename Stg_MA_Cross_Sup_Res.mqh => Stg_Retracement.mqh (100%) rename Stg_MA_Cross_Sup_Res.mqproj => Stg_Retracement.mqproj (100%) diff --git a/.github/workflows/backtest.yml b/.github/workflows/backtest.yml index e4c907a..259c2c2 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_Sup_Res.mq4 + path: Stg_Retracement.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_Sup_Res.mq5 + path: Stg_Retracement.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_Sup_Res" + TestExpert: "Stg_Retracement" TestPeriod: M1 TestReportName: Report-${{ matrix.year }}-${{ matrix.month }} - name: Upload results diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml index 9b9cc35..81f817b 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_Sup_Res.mq4 + path: Stg_Retracement.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_Sup_Res.mq5 + path: Stg_Retracement.mq5 verbose: true - name: List compiled files run: '(Get-ChildItem -Recurse -Path . -Include *.ex[45]).fullname' diff --git a/README.md b/README.md index f47b3d0..bffebfc 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Strategy MA Cross Sup/Res +# Strategy Retracement [![Status][gha-image-check-master]][gha-link-check-master] [![Status][gha-image-compile-master]][gha-link-compile-master] @@ -7,8 +7,7 @@ [![License][license-image]][license-link] [![Edit][gh-edit-badge]][gh-edit-link] -Strategy based on the moving average price indicators -implementing support/resistance cross signal. +Strategy based on the Fibonacci retracement levels. ## Dependencies diff --git a/Stg_MA_Cross_Sup_Res.mq4 b/Stg_Retracement.mq4 similarity index 83% rename from Stg_MA_Cross_Sup_Res.mq4 rename to Stg_Retracement.mq4 index 04b02cb..30457d0 100644 --- a/Stg_MA_Cross_Sup_Res.mq4 +++ b/Stg_Retracement.mq4 @@ -6,8 +6,8 @@ /** * @file - * Implements MA Cross Sup/Res strategy. + * Implements Retracement strategy. */ // Includes the main code. -#include "Stg_MA_Cross_Sup_Res.mq5" +#include "Stg_Retracement.mq5" diff --git a/Stg_MA_Cross_Sup_Res.mq5 b/Stg_Retracement.mq5 similarity index 98% rename from Stg_MA_Cross_Sup_Res.mq5 rename to Stg_Retracement.mq5 index 35bdbd9..0f959b0 100644 --- a/Stg_MA_Cross_Sup_Res.mq5 +++ b/Stg_Retracement.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_Sup_Res.mqh" +#include "Stg_Retracement.mqh" // Defines. #define ea_name "Strategy MA Cross Sup/Res" diff --git a/Stg_MA_Cross_Sup_Res.mqh b/Stg_Retracement.mqh similarity index 100% rename from Stg_MA_Cross_Sup_Res.mqh rename to Stg_Retracement.mqh diff --git a/Stg_MA_Cross_Sup_Res.mqproj b/Stg_Retracement.mqproj similarity index 100% rename from Stg_MA_Cross_Sup_Res.mqproj rename to Stg_Retracement.mqproj From 5930252ba68862ae7ce0a1ed72dc87a6afb3c4e0 Mon Sep 17 00:00:00 2001 From: kenorb Date: Sun, 10 Sep 2023 15:44:35 +0100 Subject: [PATCH 2/6] Replaces MA_Cross_Sup_Res with Retracement --- README.md | 10 +- Stg_Retracement.mq5 | 12 +- Stg_Retracement.mqh | 319 ++++++++++++++++++++--------------------- Stg_Retracement.mqproj | 8 +- 4 files changed, 172 insertions(+), 177 deletions(-) diff --git a/README.md b/README.md index bffebfc..de91b32 100644 --- a/README.md +++ b/README.md @@ -21,12 +21,12 @@ Strategy based on the Fibonacci retracement levels. [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_Sup_Res +[gh-edit-link]: https://github.dev/EA31337/Strategy-Retracement -[gha-link-check-master]: https://github.com/EA31337/Strategy-MA_Cross_Sup_Res/actions?query=workflow:Check+branch%3Amaster -[gha-image-check-master]: https://github.com/EA31337/Strategy-MA_Cross_Sup_Res/workflows/Check/badge.svg?branch=master -[gha-link-compile-master]: https://github.com/EA31337/Strategy-MA_Cross_Sup_Res/actions?query=workflow:Compile+branch%3Amaster -[gha-image-compile-master]: https://github.com/EA31337/Strategy-MA_Cross_Sup_Res/workflows/Compile/badge.svg?branch=master +[gha-link-check-master]: https://github.com/EA31337/Strategy-Retracement/actions?query=workflow:Check+branch%3Amaster +[gha-image-check-master]: https://github.com/EA31337/Strategy-Retracement/workflows/Check/badge.svg?branch=master +[gha-link-compile-master]: https://github.com/EA31337/Strategy-Retracement/actions?query=workflow:Compile+branch%3Amaster +[gha-image-compile-master]: https://github.com/EA31337/Strategy-Retracement/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_Retracement.mq5 b/Stg_Retracement.mq5 index 0f959b0..8bd7133 100644 --- a/Stg_Retracement.mq5 +++ b/Stg_Retracement.mq5 @@ -1,6 +1,6 @@ /** * @file - * Implements MA Cross Sup/Res strategy. + * Implements Retracement strategy. */ // Includes conditional compilation directives. @@ -20,7 +20,7 @@ #include // Inputs. -INPUT_GROUP("MA Cross Sup/Res strategy: main"); +INPUT_GROUP("Retracement 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,10 +30,10 @@ input bool Info_On_Chart = true; // Display info on chart. #include "Stg_Retracement.mqh" // Defines. -#define ea_name "Strategy MA Cross Sup/Res" +#define ea_name "Strategy Retracement" #define ea_version "2.000" -#define ea_desc "Strategy based on the moving average price indicators implementing support/resistance cross signal." -#define ea_link "https://github.com/EA31337/Strategy-MA_Cross_Sup_Res" +#define ea_desc "Strategy based on the Fibonacci retracement levels." +#define ea_link "https://github.com/EA31337/Strategy-Retracement" #define ea_author "EA31337 Ltd" // Properties. @@ -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_Retracement.mqh b/Stg_Retracement.mqh index 68110bb..8d2b4e5 100644 --- a/Stg_Retracement.mqh +++ b/Stg_Retracement.mqh @@ -1,135 +1,132 @@ /** * @file - * Strategy based on the moving average price indicators implementing support/resistance cross signal. + * Strategy based on the Fibonacci retracement levels. */ -enum ENUM_STG_MA_CROSS_SUP_RES_TYPE { - STG_MA_CROSS_SUP_RES_TYPE_0_NONE = 0, // (None) - STG_MA_CROSS_SUP_RES_TYPE_AMA, // AMA: Adaptive Moving Average - STG_MA_CROSS_SUP_RES_TYPE_DEMA, // DEMA: Double Exponential Moving Average - STG_MA_CROSS_SUP_RES_TYPE_FRAMA, // FrAMA: Fractal Adaptive Moving Average - STG_MA_CROSS_SUP_RES_TYPE_ICHIMOKU, // Ichimoku - STG_MA_CROSS_SUP_RES_TYPE_MA, // MA: Moving Average - STG_MA_CROSS_SUP_RES_TYPE_PRICE_CHANNEL, // Price Channel - STG_MA_CROSS_SUP_RES_TYPE_SAR, // SAR: Parabolic Stop and Reverse - STG_MA_CROSS_SUP_RES_TYPE_TEMA, // TEMA: Triple Exponential Moving Average - STG_MA_CROSS_SUP_RES_TYPE_VIDYA, // VIDYA: Variable Index Dynamic Average +enum ENUM_STG_RETRACEMENT_TYPE { + STG_RETRACEMENT_TYPE_0_NONE = 0, // (None) + STG_RETRACEMENT_TYPE_AMA, // AMA: Adaptive Moving Average + STG_RETRACEMENT_TYPE_DEMA, // DEMA: Double Exponential Moving Average + STG_RETRACEMENT_TYPE_FRAMA, // FrAMA: Fractal Adaptive Moving Average + STG_RETRACEMENT_TYPE_ICHIMOKU, // Ichimoku + STG_RETRACEMENT_TYPE_MA, // MA: Moving Average + STG_RETRACEMENT_TYPE_PRICE_CHANNEL, // Price Channel + STG_RETRACEMENT_TYPE_SAR, // SAR: Parabolic Stop and Reverse + STG_RETRACEMENT_TYPE_TEMA, // TEMA: Triple Exponential Moving Average + STG_RETRACEMENT_TYPE_VIDYA, // VIDYA: Variable Index Dynamic Average }; // User params. -INPUT_GROUP("MA Cross Sup/Res strategy: main strategy params"); -INPUT ENUM_STG_MA_CROSS_SUP_RES_TYPE MA_Cross_Sup_Res_Type = - STG_MA_CROSS_SUP_RES_TYPE_TEMA; // MA Cross Sup/Res: Indicator MA type -INPUT ENUM_PP_TYPE MA_Cross_Sup_Res_Calc_Mode = PP_FLOOR; // Support/Resistance calculation mode -INPUT_GROUP("MA Cross Sup/Res strategy: strategy params"); -INPUT float MA_Cross_Sup_Res_LotSize = 0; // Lot size -INPUT int MA_Cross_Sup_Res_SignalOpenMethod = 1; // Signal open method (-3-3) -INPUT float MA_Cross_Sup_Res_SignalOpenLevel = 0.5f; // Signal open level -INPUT int MA_Cross_Sup_Res_SignalOpenFilterMethod = 32; // Signal open filter method -INPUT int MA_Cross_Sup_Res_SignalOpenFilterTime = 3; // Signal open filter time -INPUT int MA_Cross_Sup_Res_SignalOpenBoostMethod = 0; // Signal open boost method -INPUT int MA_Cross_Sup_Res_SignalCloseMethod = 1; // Signal close method (-3-3) -INPUT int MA_Cross_Sup_Res_SignalCloseFilter = 0; // Signal close filter (-127-127) -INPUT float MA_Cross_Sup_Res_SignalCloseLevel = 0.5f; // Signal close level -INPUT int MA_Cross_Sup_Res_PriceStopMethod = 1; // Price stop method (0-127) -INPUT float MA_Cross_Sup_Res_PriceStopLevel = 2; // Price stop level -INPUT int MA_Cross_Sup_Res_TickFilterMethod = 32; // Tick filter method -INPUT float MA_Cross_Sup_Res_MaxSpread = 4.0; // Max spread to trade (pips) -INPUT short MA_Cross_Sup_Res_Shift = 0; // Shift -INPUT float MA_Cross_Sup_Res_OrderCloseLoss = 80; // Order close loss -INPUT float MA_Cross_Sup_Res_OrderCloseProfit = 80; // Order close profit -INPUT int MA_Cross_Sup_Res_OrderCloseTime = -30; // Order close time in mins (>0) or bars (<0) -INPUT_GROUP("MA Cross Sup/Res strategy: AMA indicator params"); -INPUT int MA_Cross_Sup_Res_Indi_AMA_InpPeriodAMA = 20; // AMA period -INPUT int MA_Cross_Sup_Res_Indi_AMA_InpFastPeriodEMA = 4; // Fast EMA period -INPUT int MA_Cross_Sup_Res_Indi_AMA_InpSlowPeriodEMA = 30; // Slow EMA period -INPUT int MA_Cross_Sup_Res_Indi_AMA_InpShiftAMA = 4; // AMA shift -INPUT int MA_Cross_Sup_Res_Indi_AMA_Shift = 0; // Shift -INPUT ENUM_IDATA_SOURCE_TYPE MA_Cross_Sup_Res_Indi_AMA_SourceType = IDATA_BUILTIN; // Source type -INPUT_GROUP("MA Cross Sup/Res strategy: DEMA indicator params"); -INPUT int MA_Cross_Sup_Res_Indi_DEMA_Period = 25; // Period -INPUT int MA_Cross_Sup_Res_Indi_DEMA_MA_Shift = 6; // MA Shift -INPUT ENUM_APPLIED_PRICE MA_Cross_Sup_Res_Indi_DEMA_Applied_Price = PRICE_TYPICAL; // Applied Price -INPUT int MA_Cross_Sup_Res_Indi_DEMA_Shift = 0; // Shift -INPUT ENUM_IDATA_SOURCE_TYPE MA_Cross_Sup_Res_Indi_DEMA_SourceType = IDATA_BUILTIN; // Source type -INPUT_GROUP("MA Cross Sup/Res strategy: FrAMA indicator params"); -INPUT int MA_Cross_Sup_Res_Indi_FrAMA_Period = 10; // Period -INPUT ENUM_APPLIED_PRICE MA_Cross_Sup_Res_Indi_FrAMA_Applied_Price = PRICE_MEDIAN; // Applied Price -INPUT int MA_Cross_Sup_Res_Indi_FrAMA_MA_Shift = 0; // MA Shift -INPUT int MA_Cross_Sup_Res_Indi_FrAMA_Shift = 0; // Shift -INPUT ENUM_IDATA_SOURCE_TYPE MA_Cross_Sup_Res_Indi_FrAMA_SourceType = IDATA_BUILTIN; // Source type -INPUT_GROUP("MA Cross Sup/Res strategy: Ichimoku indicator params"); -// INPUT ENUM_ICHIMOKU_LINE MA_Cross_Sup_Res_Indi_Ichimoku_MA_Line = LINE_TENKANSEN; // Ichimoku line for MA -INPUT int MA_Cross_Sup_Res_Indi_Ichimoku_Period_Tenkan_Sen = 30; // Period Tenkan Sen -INPUT int MA_Cross_Sup_Res_Indi_Ichimoku_Period_Kijun_Sen = 10; // Period Kijun Sen -INPUT int MA_Cross_Sup_Res_Indi_Ichimoku_Period_Senkou_Span_B = 30; // Period Senkou Span B -INPUT int MA_Cross_Sup_Res_Indi_Ichimoku_Shift = 1; // Shift -INPUT ENUM_IDATA_SOURCE_TYPE MA_Cross_Sup_Res_Indi_Ichimoku_SourceType = IDATA_BUILTIN; // Source type -INPUT_GROUP("MA Cross Sup/Res strategy: MA indicator params"); -INPUT int MA_Cross_Sup_Res_Indi_MA_Period = 26; // Period -INPUT int MA_Cross_Sup_Res_Indi_MA_MA_Shift = 0; // MA Shift -INPUT ENUM_MA_METHOD MA_Cross_Sup_Res_Indi_MA_Method = MODE_LWMA; // MA Method -INPUT ENUM_APPLIED_PRICE MA_Cross_Sup_Res_Indi_MA_Applied_Price = PRICE_WEIGHTED; // Applied Price -INPUT int MA_Cross_Sup_Res_Indi_MA_Shift = 0; // Shift -INPUT ENUM_IDATA_SOURCE_TYPE MA_Cross_Sup_Res_Indi_MA_SourceType = IDATA_BUILTIN; // Source type -INPUT_GROUP("MA Cross Sup/Res strategy: Price Channel indicator params"); -INPUT int MA_Cross_Sup_Res_Indi_PriceChannel_Period = 26; // Period -INPUT int MA_Cross_Sup_Res_Indi_PriceChannel_Shift = 0; // Shift -INPUT ENUM_IDATA_SOURCE_TYPE MA_Cross_Sup_Res_Indi_PriceChannel_SourceType = IDATA_ICUSTOM; // Source type -INPUT_GROUP("MA Cross Sup/Res strategy: SAR indicator params"); -INPUT float MA_Cross_Sup_Res_Indi_SAR_Step = 0.04f; // Step -INPUT float MA_Cross_Sup_Res_Indi_SAR_Maximum_Stop = 0.4f; // Maximum stop -INPUT int MA_Cross_Sup_Res_Indi_SAR_Shift = 0; // Shift -INPUT ENUM_IDATA_SOURCE_TYPE MA_Cross_Sup_Res_Indi_SAR_SourceType = IDATA_ICUSTOM; // Source type -INPUT_GROUP("MA Cross Sup/Res strategy: TEMA indicator params"); -INPUT int MA_Cross_Sup_Res_Indi_TEMA_Period = 10; // Period -INPUT int MA_Cross_Sup_Res_Indi_TEMA_MA_Shift = 0; // MA Shift -INPUT ENUM_APPLIED_PRICE MA_Cross_Sup_Res_Indi_TEMA_Applied_Price = PRICE_WEIGHTED; // Applied Price -INPUT int MA_Cross_Sup_Res_Indi_TEMA_Shift = 0; // Shift -INPUT ENUM_IDATA_SOURCE_TYPE MA_Cross_Sup_Res_Indi_TEMA_SourceType = IDATA_BUILTIN; // Source type -INPUT_GROUP("MA Cross Sup/Res strategy: VIDYA indicator params"); -INPUT int MA_Cross_Sup_Res_Indi_VIDYA_Period = 30; // Period -INPUT int MA_Cross_Sup_Res_Indi_VIDYA_MA_Period = 20; // MA Period -INPUT int MA_Cross_Sup_Res_Indi_VIDYA_MA_Shift = 1; // MA Shift -INPUT ENUM_APPLIED_PRICE MA_Cross_Sup_Res_Indi_VIDYA_Applied_Price = PRICE_WEIGHTED; // Applied Price -INPUT int MA_Cross_Sup_Res_Indi_VIDYA_Shift = 0; // Shift -INPUT ENUM_IDATA_SOURCE_TYPE MA_Cross_Sup_Res_Indi_VIDYA_SourceType = IDATA_BUILTIN; // Source type +INPUT_GROUP("Retracement strategy: main strategy params"); +INPUT ENUM_STG_RETRACEMENT_TYPE Retracement_Type = STG_RETRACEMENT_TYPE_TEMA; // Retracement: Indicator MA type +INPUT ENUM_PP_TYPE Retracement_Calc_Mode = PP_FLOOR; // Calculation mode +INPUT_GROUP("Retracement strategy: strategy params"); +INPUT float Retracement_LotSize = 0; // Lot size +INPUT int Retracement_SignalOpenMethod = 1; // Signal open method (-3-3) +INPUT float Retracement_SignalOpenLevel = 0.5f; // Signal open level +INPUT int Retracement_SignalOpenFilterMethod = 32; // Signal open filter method +INPUT int Retracement_SignalOpenFilterTime = 3; // Signal open filter time +INPUT int Retracement_SignalOpenBoostMethod = 0; // Signal open boost method +INPUT int Retracement_SignalCloseMethod = 1; // Signal close method (-3-3) +INPUT int Retracement_SignalCloseFilter = 0; // Signal close filter (-127-127) +INPUT float Retracement_SignalCloseLevel = 0.5f; // Signal close level +INPUT int Retracement_PriceStopMethod = 1; // Price stop method (0-127) +INPUT float Retracement_PriceStopLevel = 2; // Price stop level +INPUT int Retracement_TickFilterMethod = 32; // Tick filter method +INPUT float Retracement_MaxSpread = 4.0; // Max spread to trade (pips) +INPUT short Retracement_Shift = 0; // Shift +INPUT float Retracement_OrderCloseLoss = 80; // Order close loss +INPUT float Retracement_OrderCloseProfit = 80; // Order close profit +INPUT int Retracement_OrderCloseTime = -30; // Order close time in mins (>0) or bars (<0) +INPUT_GROUP("Retracement strategy: AMA indicator params"); +INPUT int Retracement_Indi_AMA_InpPeriodAMA = 20; // AMA period +INPUT int Retracement_Indi_AMA_InpFastPeriodEMA = 4; // Fast EMA period +INPUT int Retracement_Indi_AMA_InpSlowPeriodEMA = 30; // Slow EMA period +INPUT int Retracement_Indi_AMA_InpShiftAMA = 4; // AMA shift +INPUT int Retracement_Indi_AMA_Shift = 0; // Shift +INPUT ENUM_IDATA_SOURCE_TYPE Retracement_Indi_AMA_SourceType = IDATA_BUILTIN; // Source type +INPUT_GROUP("Retracement strategy: DEMA indicator params"); +INPUT int Retracement_Indi_DEMA_Period = 25; // Period +INPUT int Retracement_Indi_DEMA_MA_Shift = 6; // MA Shift +INPUT ENUM_APPLIED_PRICE Retracement_Indi_DEMA_Applied_Price = PRICE_TYPICAL; // Applied Price +INPUT int Retracement_Indi_DEMA_Shift = 0; // Shift +INPUT ENUM_IDATA_SOURCE_TYPE Retracement_Indi_DEMA_SourceType = IDATA_BUILTIN; // Source type +INPUT_GROUP("Retracement strategy: FrAMA indicator params"); +INPUT int Retracement_Indi_FrAMA_Period = 10; // Period +INPUT ENUM_APPLIED_PRICE Retracement_Indi_FrAMA_Applied_Price = PRICE_MEDIAN; // Applied Price +INPUT int Retracement_Indi_FrAMA_MA_Shift = 0; // MA Shift +INPUT int Retracement_Indi_FrAMA_Shift = 0; // Shift +INPUT ENUM_IDATA_SOURCE_TYPE Retracement_Indi_FrAMA_SourceType = IDATA_BUILTIN; // Source type +INPUT_GROUP("Retracement strategy: Ichimoku indicator params"); +// INPUT ENUM_ICHIMOKU_LINE Retracement_Indi_Ichimoku_MA_Line = LINE_TENKANSEN; // Ichimoku line for MA +INPUT int Retracement_Indi_Ichimoku_Period_Tenkan_Sen = 30; // Period Tenkan Sen +INPUT int Retracement_Indi_Ichimoku_Period_Kijun_Sen = 10; // Period Kijun Sen +INPUT int Retracement_Indi_Ichimoku_Period_Senkou_Span_B = 30; // Period Senkou Span B +INPUT int Retracement_Indi_Ichimoku_Shift = 1; // Shift +INPUT ENUM_IDATA_SOURCE_TYPE Retracement_Indi_Ichimoku_SourceType = IDATA_BUILTIN; // Source type +INPUT_GROUP("Retracement strategy: MA indicator params"); +INPUT int Retracement_Indi_MA_Period = 26; // Period +INPUT int Retracement_Indi_MA_MA_Shift = 0; // MA Shift +INPUT ENUM_MA_METHOD Retracement_Indi_MA_Method = MODE_LWMA; // MA Method +INPUT ENUM_APPLIED_PRICE Retracement_Indi_MA_Applied_Price = PRICE_WEIGHTED; // Applied Price +INPUT int Retracement_Indi_MA_Shift = 0; // Shift +INPUT ENUM_IDATA_SOURCE_TYPE Retracement_Indi_MA_SourceType = IDATA_BUILTIN; // Source type +INPUT_GROUP("Retracement strategy: Price Channel indicator params"); +INPUT int Retracement_Indi_PriceChannel_Period = 26; // Period +INPUT int Retracement_Indi_PriceChannel_Shift = 0; // Shift +INPUT ENUM_IDATA_SOURCE_TYPE Retracement_Indi_PriceChannel_SourceType = IDATA_ICUSTOM; // Source type +INPUT_GROUP("Retracement strategy: SAR indicator params"); +INPUT float Retracement_Indi_SAR_Step = 0.04f; // Step +INPUT float Retracement_Indi_SAR_Maximum_Stop = 0.4f; // Maximum stop +INPUT int Retracement_Indi_SAR_Shift = 0; // Shift +INPUT ENUM_IDATA_SOURCE_TYPE Retracement_Indi_SAR_SourceType = IDATA_ICUSTOM; // Source type +INPUT_GROUP("Retracement strategy: TEMA indicator params"); +INPUT int Retracement_Indi_TEMA_Period = 10; // Period +INPUT int Retracement_Indi_TEMA_MA_Shift = 0; // MA Shift +INPUT ENUM_APPLIED_PRICE Retracement_Indi_TEMA_Applied_Price = PRICE_WEIGHTED; // Applied Price +INPUT int Retracement_Indi_TEMA_Shift = 0; // Shift +INPUT ENUM_IDATA_SOURCE_TYPE Retracement_Indi_TEMA_SourceType = IDATA_BUILTIN; // Source type +INPUT_GROUP("Retracement strategy: VIDYA indicator params"); +INPUT int Retracement_Indi_VIDYA_Period = 30; // Period +INPUT int Retracement_Indi_VIDYA_MA_Period = 20; // MA Period +INPUT int Retracement_Indi_VIDYA_MA_Shift = 1; // MA Shift +INPUT ENUM_APPLIED_PRICE Retracement_Indi_VIDYA_Applied_Price = PRICE_WEIGHTED; // Applied Price +INPUT int Retracement_Indi_VIDYA_Shift = 0; // Shift +INPUT ENUM_IDATA_SOURCE_TYPE Retracement_Indi_VIDYA_SourceType = IDATA_BUILTIN; // Source type // Structs. // Defines struct with default user strategy values. -struct Stg_MA_Cross_Sup_Res_Params_Defaults : StgParams { - Stg_MA_Cross_Sup_Res_Params_Defaults() - : StgParams(::MA_Cross_Sup_Res_SignalOpenMethod, ::MA_Cross_Sup_Res_SignalOpenFilterMethod, - ::MA_Cross_Sup_Res_SignalOpenLevel, ::MA_Cross_Sup_Res_SignalOpenBoostMethod, - ::MA_Cross_Sup_Res_SignalCloseMethod, ::MA_Cross_Sup_Res_SignalCloseFilter, - ::MA_Cross_Sup_Res_SignalCloseLevel, ::MA_Cross_Sup_Res_PriceStopMethod, - ::MA_Cross_Sup_Res_PriceStopLevel, ::MA_Cross_Sup_Res_TickFilterMethod, ::MA_Cross_Sup_Res_MaxSpread, - ::MA_Cross_Sup_Res_Shift) { - Set(STRAT_PARAM_LS, MA_Cross_Sup_Res_LotSize); - Set(STRAT_PARAM_OCL, MA_Cross_Sup_Res_OrderCloseLoss); - Set(STRAT_PARAM_OCP, MA_Cross_Sup_Res_OrderCloseProfit); - Set(STRAT_PARAM_OCT, MA_Cross_Sup_Res_OrderCloseTime); - Set(STRAT_PARAM_SOFT, MA_Cross_Sup_Res_SignalOpenFilterTime); +struct Stg_Retracement_Params_Defaults : StgParams { + Stg_Retracement_Params_Defaults() + : StgParams(::Retracement_SignalOpenMethod, ::Retracement_SignalOpenFilterMethod, ::Retracement_SignalOpenLevel, + ::Retracement_SignalOpenBoostMethod, ::Retracement_SignalCloseMethod, ::Retracement_SignalCloseFilter, + ::Retracement_SignalCloseLevel, ::Retracement_PriceStopMethod, ::Retracement_PriceStopLevel, + ::Retracement_TickFilterMethod, ::Retracement_MaxSpread, ::Retracement_Shift) { + Set(STRAT_PARAM_LS, Retracement_LotSize); + Set(STRAT_PARAM_OCL, Retracement_OrderCloseLoss); + Set(STRAT_PARAM_OCP, Retracement_OrderCloseProfit); + Set(STRAT_PARAM_OCT, Retracement_OrderCloseTime); + Set(STRAT_PARAM_SOFT, Retracement_SignalOpenFilterTime); } }; -class Stg_MA_Cross_Sup_Res : public Strategy { +class Stg_Retracement : public Strategy { protected: - Stg_MA_Cross_Sup_Res_Params_Defaults ssparams; + Stg_Retracement_Params_Defaults ssparams; public: - Stg_MA_Cross_Sup_Res(StgParams &_sparams, TradeParams &_tparams, ChartParams &_cparams, string _name = "") + Stg_Retracement(StgParams &_sparams, TradeParams &_tparams, ChartParams &_cparams, string _name = "") : Strategy(_sparams, _tparams, _cparams, _name) {} - static Stg_MA_Cross_Sup_Res *Init(ENUM_TIMEFRAMES _tf = NULL, EA *_ea = NULL) { + static Stg_Retracement *Init(ENUM_TIMEFRAMES _tf = NULL, EA *_ea = NULL) { // Initialize strategy initial values. - Stg_MA_Cross_Sup_Res_Params_Defaults stg_ma_defaults; + Stg_Retracement_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_Sup_Res(_stg_params, _tparams, _cparams, "MA"); + Strategy *_strat = new Stg_Retracement(_stg_params, _tparams, _cparams, "MA"); return _strat; } @@ -138,95 +135,93 @@ class Stg_MA_Cross_Sup_Res : public Strategy { */ void OnInit() { // Initialize indicators. - switch (MA_Cross_Sup_Res_Type) { - case STG_MA_CROSS_SUP_RES_TYPE_AMA: // AMA + switch (Retracement_Type) { + case STG_RETRACEMENT_TYPE_AMA: // AMA { - IndiAMAParams _indi_params( - ::MA_Cross_Sup_Res_Indi_AMA_InpPeriodAMA, ::MA_Cross_Sup_Res_Indi_AMA_InpFastPeriodEMA, - ::MA_Cross_Sup_Res_Indi_AMA_InpSlowPeriodEMA, ::MA_Cross_Sup_Res_Indi_AMA_InpShiftAMA, PRICE_TYPICAL, - ::MA_Cross_Sup_Res_Indi_AMA_Shift); - _indi_params.SetDataSourceType(::MA_Cross_Sup_Res_Indi_AMA_SourceType); + IndiAMAParams _indi_params(::Retracement_Indi_AMA_InpPeriodAMA, ::Retracement_Indi_AMA_InpFastPeriodEMA, + ::Retracement_Indi_AMA_InpSlowPeriodEMA, ::Retracement_Indi_AMA_InpShiftAMA, + PRICE_TYPICAL, ::Retracement_Indi_AMA_Shift); + _indi_params.SetDataSourceType(::Retracement_Indi_AMA_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_AMA(_indi_params), ::MA_Cross_Sup_Res_Type); + SetIndicator(new Indi_AMA(_indi_params), ::Retracement_Type); break; } - case STG_MA_CROSS_SUP_RES_TYPE_DEMA: // DEMA + case STG_RETRACEMENT_TYPE_DEMA: // DEMA { - IndiDEIndiMAParams _indi_params(::MA_Cross_Sup_Res_Indi_DEMA_Period, ::MA_Cross_Sup_Res_Indi_DEMA_MA_Shift, - ::MA_Cross_Sup_Res_Indi_DEMA_Applied_Price, ::MA_Cross_Sup_Res_Indi_DEMA_Shift); - _indi_params.SetDataSourceType(::MA_Cross_Sup_Res_Indi_DEMA_SourceType); + IndiDEIndiMAParams _indi_params(::Retracement_Indi_DEMA_Period, ::Retracement_Indi_DEMA_MA_Shift, + ::Retracement_Indi_DEMA_Applied_Price, ::Retracement_Indi_DEMA_Shift); + _indi_params.SetDataSourceType(::Retracement_Indi_DEMA_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_DEMA(_indi_params), ::MA_Cross_Sup_Res_Type); + SetIndicator(new Indi_DEMA(_indi_params), ::Retracement_Type); break; } - case STG_MA_CROSS_SUP_RES_TYPE_FRAMA: // FrAMA + case STG_RETRACEMENT_TYPE_FRAMA: // FrAMA { - IndiFrAIndiMAParams _indi_params(::MA_Cross_Sup_Res_Indi_FrAMA_Period, ::MA_Cross_Sup_Res_Indi_FrAMA_MA_Shift, - ::MA_Cross_Sup_Res_Indi_FrAMA_Applied_Price, - ::MA_Cross_Sup_Res_Indi_FrAMA_Shift); - _indi_params.SetDataSourceType(::MA_Cross_Sup_Res_Indi_FrAMA_SourceType); + IndiFrAIndiMAParams _indi_params(::Retracement_Indi_FrAMA_Period, ::Retracement_Indi_FrAMA_MA_Shift, + ::Retracement_Indi_FrAMA_Applied_Price, ::Retracement_Indi_FrAMA_Shift); + _indi_params.SetDataSourceType(::Retracement_Indi_FrAMA_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_FrAMA(_indi_params), ::MA_Cross_Sup_Res_Type); + SetIndicator(new Indi_FrAMA(_indi_params), ::Retracement_Type); break; } - case STG_MA_CROSS_SUP_RES_TYPE_ICHIMOKU: // Ichimoku + case STG_RETRACEMENT_TYPE_ICHIMOKU: // Ichimoku { IndiIchimokuParams _indi_params( - ::MA_Cross_Sup_Res_Indi_Ichimoku_Period_Tenkan_Sen, ::MA_Cross_Sup_Res_Indi_Ichimoku_Period_Kijun_Sen, - ::MA_Cross_Sup_Res_Indi_Ichimoku_Period_Senkou_Span_B, ::MA_Cross_Sup_Res_Indi_Ichimoku_Shift); - _indi_params.SetDataSourceType(::MA_Cross_Sup_Res_Indi_Ichimoku_SourceType); + ::Retracement_Indi_Ichimoku_Period_Tenkan_Sen, ::Retracement_Indi_Ichimoku_Period_Kijun_Sen, + ::Retracement_Indi_Ichimoku_Period_Senkou_Span_B, ::Retracement_Indi_Ichimoku_Shift); + _indi_params.SetDataSourceType(::Retracement_Indi_Ichimoku_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_Ichimoku(_indi_params), ::MA_Cross_Sup_Res_Type); + SetIndicator(new Indi_Ichimoku(_indi_params), ::Retracement_Type); break; } - case STG_MA_CROSS_SUP_RES_TYPE_MA: // MA + case STG_RETRACEMENT_TYPE_MA: // MA { - IndiMAParams _indi_params(::MA_Cross_Sup_Res_Indi_MA_Period, ::MA_Cross_Sup_Res_Indi_MA_MA_Shift, - ::MA_Cross_Sup_Res_Indi_MA_Method, ::MA_Cross_Sup_Res_Indi_MA_Applied_Price, - ::MA_Cross_Sup_Res_Indi_MA_Shift); - _indi_params.SetDataSourceType(::MA_Cross_Sup_Res_Indi_MA_SourceType); + IndiMAParams _indi_params(::Retracement_Indi_MA_Period, ::Retracement_Indi_MA_MA_Shift, + ::Retracement_Indi_MA_Method, ::Retracement_Indi_MA_Applied_Price, + ::Retracement_Indi_MA_Shift); + _indi_params.SetDataSourceType(::Retracement_Indi_MA_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_MA(_indi_params), ::MA_Cross_Sup_Res_Type); + SetIndicator(new Indi_MA(_indi_params), ::Retracement_Type); break; } - case STG_MA_CROSS_SUP_RES_TYPE_PRICE_CHANNEL: // Price Channel + case STG_RETRACEMENT_TYPE_PRICE_CHANNEL: // Price Channel { - IndiPriceChannelParams _indi_params(::MA_Cross_Sup_Res_Indi_PriceChannel_Period, - ::MA_Cross_Sup_Res_Indi_PriceChannel_Shift); - _indi_params.SetDataSourceType(::MA_Cross_Sup_Res_Indi_PriceChannel_SourceType); + IndiPriceChannelParams _indi_params(::Retracement_Indi_PriceChannel_Period, + ::Retracement_Indi_PriceChannel_Shift); + _indi_params.SetDataSourceType(::Retracement_Indi_PriceChannel_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_PriceChannel(_indi_params), ::MA_Cross_Sup_Res_Type); + SetIndicator(new Indi_PriceChannel(_indi_params), ::Retracement_Type); break; } - case STG_MA_CROSS_SUP_RES_TYPE_SAR: // SAR + case STG_RETRACEMENT_TYPE_SAR: // SAR { - IndiSARParams _indi_params(::MA_Cross_Sup_Res_Indi_SAR_Step, ::MA_Cross_Sup_Res_Indi_SAR_Maximum_Stop, - ::MA_Cross_Sup_Res_Indi_SAR_Shift); - _indi_params.SetDataSourceType(::MA_Cross_Sup_Res_Indi_SAR_SourceType); + IndiSARParams _indi_params(::Retracement_Indi_SAR_Step, ::Retracement_Indi_SAR_Maximum_Stop, + ::Retracement_Indi_SAR_Shift); + _indi_params.SetDataSourceType(::Retracement_Indi_SAR_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_SAR(_indi_params), ::MA_Cross_Sup_Res_Type); + SetIndicator(new Indi_SAR(_indi_params), ::Retracement_Type); break; } - case STG_MA_CROSS_SUP_RES_TYPE_TEMA: // TEMA + case STG_RETRACEMENT_TYPE_TEMA: // TEMA { - IndiTEMAParams _indi_params(::MA_Cross_Sup_Res_Indi_TEMA_Period, ::MA_Cross_Sup_Res_Indi_TEMA_MA_Shift, - ::MA_Cross_Sup_Res_Indi_TEMA_Applied_Price, ::MA_Cross_Sup_Res_Indi_TEMA_Shift); - _indi_params.SetDataSourceType(::MA_Cross_Sup_Res_Indi_TEMA_SourceType); + IndiTEMAParams _indi_params(::Retracement_Indi_TEMA_Period, ::Retracement_Indi_TEMA_MA_Shift, + ::Retracement_Indi_TEMA_Applied_Price, ::Retracement_Indi_TEMA_Shift); + _indi_params.SetDataSourceType(::Retracement_Indi_TEMA_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_TEMA(_indi_params), ::MA_Cross_Sup_Res_Type); + SetIndicator(new Indi_TEMA(_indi_params), ::Retracement_Type); break; } - case STG_MA_CROSS_SUP_RES_TYPE_VIDYA: // VIDYA + case STG_RETRACEMENT_TYPE_VIDYA: // VIDYA { - IndiVIDYAParams _indi_params(::MA_Cross_Sup_Res_Indi_VIDYA_Period, ::MA_Cross_Sup_Res_Indi_VIDYA_MA_Period, - ::MA_Cross_Sup_Res_Indi_VIDYA_MA_Shift, - ::MA_Cross_Sup_Res_Indi_VIDYA_Applied_Price, ::MA_Cross_Sup_Res_Indi_VIDYA_Shift); - _indi_params.SetDataSourceType(::MA_Cross_Sup_Res_Indi_VIDYA_SourceType); + IndiVIDYAParams _indi_params(::Retracement_Indi_VIDYA_Period, ::Retracement_Indi_VIDYA_MA_Period, + ::Retracement_Indi_VIDYA_MA_Shift, ::Retracement_Indi_VIDYA_Applied_Price, + ::Retracement_Indi_VIDYA_Shift); + _indi_params.SetDataSourceType(::Retracement_Indi_VIDYA_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_VIDYA(_indi_params), ::MA_Cross_Sup_Res_Type); + SetIndicator(new Indi_VIDYA(_indi_params), ::Retracement_Type); break; } - case STG_MA_CROSS_SUP_RES_TYPE_0_NONE: // (None) + case STG_RETRACEMENT_TYPE_0_NONE: // (None) default: break; } @@ -237,7 +232,7 @@ class Stg_MA_Cross_Sup_Res : public Strategy { */ bool SignalOpen(ENUM_ORDER_TYPE _cmd, int _method = 0, float _level = 0.0f, int _shift = 0) { Chart *_chart = trade.GetChart(); - IndicatorBase *_indi = GetIndicator(::MA_Cross_Sup_Res_Type); + IndicatorBase *_indi = GetIndicator(::Retracement_Type); // uint _ishift = _indi.GetParams().GetShift(); // @todo: Convert into Get(). // bool _result = _indi.GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift); // @fixme uint _ishift = _shift; @@ -251,7 +246,7 @@ class Stg_MA_Cross_Sup_Res : public Strategy { float _pp, _r1, _r2, _r3, _r4, _s1, _s2, _s3, _s4; ChartEntry _ohlc_d1 = _chart.GetEntry(PERIOD_D1, _shift + 1, _chart.GetSymbol()); double _d1_pivot = - _ohlc_d1.bar.ohlc.GetPivots(::MA_Cross_Sup_Res_Calc_Mode, _pp, _r1, _r2, _r3, _r4, _s1, _s2, _s3, _s4); + _ohlc_d1.bar.ohlc.GetPivots(::Retracement_Calc_Mode, _pp, _r1, _r2, _r3, _r4, _s1, _s2, _s3, _s4); bool _ma_cross_r1_up = _indi[_ishift][0] > _r1 + _level_pips && _indi[_ishift + 1][0] < _r1; bool _ma_cross_r2_up = _indi[_ishift][0] > _r2 + _level_pips && _indi[_ishift + 1][0] < _r2; bool _ma_cross_r3_up = _indi[_ishift][0] > _r3 + _level_pips && _indi[_ishift + 1][0] < _r3; diff --git a/Stg_Retracement.mqproj b/Stg_Retracement.mqproj index 389c985..ef48522 100644 --- a/Stg_Retracement.mqproj +++ b/Stg_Retracement.mqproj @@ -2,9 +2,9 @@ "platform" :"mt5", "program_type":"expert", "copyright" :"Copyright 2016-2023, EA31337 Ltd", - "link" :"https:\/\/github.com\/EA31337\/Strategy-MA_Cross_Sup_Res", + "link" :"https:\/\/github.com\/EA31337\/Strategy-Retracement", "version" :"2.000", - "description" :"Strategy based on the moving average price indicators implementing support/resistance cross signal.", + "description" :"Strategy based on the Fibonacci retracement levels.", "optimize" :"0", "fpzerocheck" :"0", "tester_no_cache":"0", @@ -15,7 +15,7 @@ "files": [ { - "path":"Stg_MA_Cross_Sup_Res.mq5", + "path":"Stg_Retracement.mq5", "compile":true, "relative_to_project":true }, @@ -215,7 +215,7 @@ "relative_to_project":false }, { - "path":"Stg_MA_Cross_Sup_Res.mqh", + "path":"Stg_Retracement.mqh", "compile":false, "relative_to_project":true }, From 74784a0df0842eeafa59c7a2139374345b9dc4c4 Mon Sep 17 00:00:00 2001 From: kenorb Date: Sun, 10 Sep 2023 15:53:44 +0100 Subject: [PATCH 3/6] Renames some variables --- Stg_Retracement.mqh | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/Stg_Retracement.mqh b/Stg_Retracement.mqh index 8d2b4e5..494c2f3 100644 --- a/Stg_Retracement.mqh +++ b/Stg_Retracement.mqh @@ -18,8 +18,9 @@ enum ENUM_STG_RETRACEMENT_TYPE { // User params. INPUT_GROUP("Retracement strategy: main strategy params"); -INPUT ENUM_STG_RETRACEMENT_TYPE Retracement_Type = STG_RETRACEMENT_TYPE_TEMA; // Retracement: Indicator MA type -INPUT ENUM_PP_TYPE Retracement_Calc_Mode = PP_FLOOR; // Calculation mode +INPUT ENUM_STG_RETRACEMENT_TYPE Retracement_Indi_Type = STG_RETRACEMENT_TYPE_TEMA; // Retracement: Indicator MA type +INPUT ENUM_PP_TYPE Retracement_Levels_Calc_Method = PP_FLOOR; // Method for level calculations +INPUT ENUM_APPLIED_PRICE Retracement_Levels_Applied_Price = PRICE_TYPICAL; // Calculation mode INPUT_GROUP("Retracement strategy: strategy params"); INPUT float Retracement_LotSize = 0; // Lot size INPUT int Retracement_SignalOpenMethod = 1; // Signal open method (-3-3) @@ -135,7 +136,7 @@ class Stg_Retracement : public Strategy { */ void OnInit() { // Initialize indicators. - switch (Retracement_Type) { + switch (::Retracement_Indi_Type) { case STG_RETRACEMENT_TYPE_AMA: // AMA { IndiAMAParams _indi_params(::Retracement_Indi_AMA_InpPeriodAMA, ::Retracement_Indi_AMA_InpFastPeriodEMA, @@ -143,7 +144,7 @@ class Stg_Retracement : public Strategy { PRICE_TYPICAL, ::Retracement_Indi_AMA_Shift); _indi_params.SetDataSourceType(::Retracement_Indi_AMA_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_AMA(_indi_params), ::Retracement_Type); + SetIndicator(new Indi_AMA(_indi_params), ::Retracement_Indi_Type); break; } case STG_RETRACEMENT_TYPE_DEMA: // DEMA @@ -152,7 +153,7 @@ class Stg_Retracement : public Strategy { ::Retracement_Indi_DEMA_Applied_Price, ::Retracement_Indi_DEMA_Shift); _indi_params.SetDataSourceType(::Retracement_Indi_DEMA_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_DEMA(_indi_params), ::Retracement_Type); + SetIndicator(new Indi_DEMA(_indi_params), ::Retracement_Indi_Type); break; } case STG_RETRACEMENT_TYPE_FRAMA: // FrAMA @@ -161,7 +162,7 @@ class Stg_Retracement : public Strategy { ::Retracement_Indi_FrAMA_Applied_Price, ::Retracement_Indi_FrAMA_Shift); _indi_params.SetDataSourceType(::Retracement_Indi_FrAMA_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_FrAMA(_indi_params), ::Retracement_Type); + SetIndicator(new Indi_FrAMA(_indi_params), ::Retracement_Indi_Type); break; } case STG_RETRACEMENT_TYPE_ICHIMOKU: // Ichimoku @@ -171,7 +172,7 @@ class Stg_Retracement : public Strategy { ::Retracement_Indi_Ichimoku_Period_Senkou_Span_B, ::Retracement_Indi_Ichimoku_Shift); _indi_params.SetDataSourceType(::Retracement_Indi_Ichimoku_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_Ichimoku(_indi_params), ::Retracement_Type); + SetIndicator(new Indi_Ichimoku(_indi_params), ::Retracement_Indi_Type); break; } case STG_RETRACEMENT_TYPE_MA: // MA @@ -181,7 +182,7 @@ class Stg_Retracement : public Strategy { ::Retracement_Indi_MA_Shift); _indi_params.SetDataSourceType(::Retracement_Indi_MA_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_MA(_indi_params), ::Retracement_Type); + SetIndicator(new Indi_MA(_indi_params), ::Retracement_Indi_Type); break; } case STG_RETRACEMENT_TYPE_PRICE_CHANNEL: // Price Channel @@ -190,7 +191,7 @@ class Stg_Retracement : public Strategy { ::Retracement_Indi_PriceChannel_Shift); _indi_params.SetDataSourceType(::Retracement_Indi_PriceChannel_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_PriceChannel(_indi_params), ::Retracement_Type); + SetIndicator(new Indi_PriceChannel(_indi_params), ::Retracement_Indi_Type); break; } case STG_RETRACEMENT_TYPE_SAR: // SAR @@ -199,7 +200,7 @@ class Stg_Retracement : public Strategy { ::Retracement_Indi_SAR_Shift); _indi_params.SetDataSourceType(::Retracement_Indi_SAR_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_SAR(_indi_params), ::Retracement_Type); + SetIndicator(new Indi_SAR(_indi_params), ::Retracement_Indi_Type); break; } case STG_RETRACEMENT_TYPE_TEMA: // TEMA @@ -208,7 +209,7 @@ class Stg_Retracement : public Strategy { ::Retracement_Indi_TEMA_Applied_Price, ::Retracement_Indi_TEMA_Shift); _indi_params.SetDataSourceType(::Retracement_Indi_TEMA_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_TEMA(_indi_params), ::Retracement_Type); + SetIndicator(new Indi_TEMA(_indi_params), ::Retracement_Indi_Type); break; } case STG_RETRACEMENT_TYPE_VIDYA: // VIDYA @@ -218,7 +219,7 @@ class Stg_Retracement : public Strategy { ::Retracement_Indi_VIDYA_Shift); _indi_params.SetDataSourceType(::Retracement_Indi_VIDYA_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_VIDYA(_indi_params), ::Retracement_Type); + SetIndicator(new Indi_VIDYA(_indi_params), ::Retracement_Indi_Type); break; } case STG_RETRACEMENT_TYPE_0_NONE: // (None) @@ -232,7 +233,7 @@ class Stg_Retracement : public Strategy { */ bool SignalOpen(ENUM_ORDER_TYPE _cmd, int _method = 0, float _level = 0.0f, int _shift = 0) { Chart *_chart = trade.GetChart(); - IndicatorBase *_indi = GetIndicator(::Retracement_Type); + IndicatorBase *_indi = GetIndicator(::Retracement_Indi_Type); // uint _ishift = _indi.GetParams().GetShift(); // @todo: Convert into Get(). // bool _result = _indi.GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift); // @fixme uint _ishift = _shift; @@ -246,7 +247,7 @@ class Stg_Retracement : public Strategy { float _pp, _r1, _r2, _r3, _r4, _s1, _s2, _s3, _s4; ChartEntry _ohlc_d1 = _chart.GetEntry(PERIOD_D1, _shift + 1, _chart.GetSymbol()); double _d1_pivot = - _ohlc_d1.bar.ohlc.GetPivots(::Retracement_Calc_Mode, _pp, _r1, _r2, _r3, _r4, _s1, _s2, _s3, _s4); + _ohlc_d1.bar.ohlc.GetPivots(::Retracement_Levels_Calc_Method, _pp, _r1, _r2, _r3, _r4, _s1, _s2, _s3, _s4); bool _ma_cross_r1_up = _indi[_ishift][0] > _r1 + _level_pips && _indi[_ishift + 1][0] < _r1; bool _ma_cross_r2_up = _indi[_ishift][0] > _r2 + _level_pips && _indi[_ishift + 1][0] < _r2; bool _ma_cross_r3_up = _indi[_ishift][0] > _r3 + _level_pips && _indi[_ishift + 1][0] < _r3; From 6e3bbee8314fa9b319c2729534aed8e552fd0358 Mon Sep 17 00:00:00 2001 From: kenorb Date: Sun, 10 Sep 2023 16:53:15 +0100 Subject: [PATCH 4/6] Initial trading logic --- Stg_Retracement.mqh | 150 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 124 insertions(+), 26 deletions(-) diff --git a/Stg_Retracement.mqh b/Stg_Retracement.mqh index 494c2f3..9a1268f 100644 --- a/Stg_Retracement.mqh +++ b/Stg_Retracement.mqh @@ -21,16 +21,17 @@ INPUT_GROUP("Retracement strategy: main strategy params"); INPUT ENUM_STG_RETRACEMENT_TYPE Retracement_Indi_Type = STG_RETRACEMENT_TYPE_TEMA; // Retracement: Indicator MA type INPUT ENUM_PP_TYPE Retracement_Levels_Calc_Method = PP_FLOOR; // Method for level calculations INPUT ENUM_APPLIED_PRICE Retracement_Levels_Applied_Price = PRICE_TYPICAL; // Calculation mode +INPUT ENUM_TIMEFRAMES Retracement_Levels_Tf = PERIOD_D1; // Calculation timeframe INPUT_GROUP("Retracement strategy: strategy params"); INPUT float Retracement_LotSize = 0; // Lot size -INPUT int Retracement_SignalOpenMethod = 1; // Signal open method (-3-3) -INPUT float Retracement_SignalOpenLevel = 0.5f; // Signal open level +INPUT int Retracement_SignalOpenMethod = 0; // Signal open method (-3-3) +INPUT float Retracement_SignalOpenLevel = 4.0f; // Signal open level (-100-100) INPUT int Retracement_SignalOpenFilterMethod = 32; // Signal open filter method INPUT int Retracement_SignalOpenFilterTime = 3; // Signal open filter time INPUT int Retracement_SignalOpenBoostMethod = 0; // Signal open boost method -INPUT int Retracement_SignalCloseMethod = 1; // Signal close method (-3-3) +INPUT int Retracement_SignalCloseMethod = 0; // Signal close method (-3-3) INPUT int Retracement_SignalCloseFilter = 0; // Signal close filter (-127-127) -INPUT float Retracement_SignalCloseLevel = 0.5f; // Signal close level +INPUT float Retracement_SignalCloseLevel = 4.0f; // Signal close level (-100-100) INPUT int Retracement_PriceStopMethod = 1; // Price stop method (0-127) INPUT float Retracement_PriceStopLevel = 2; // Price stop level INPUT int Retracement_TickFilterMethod = 32; // Tick filter method @@ -112,6 +113,101 @@ struct Stg_Retracement_Params_Defaults : StgParams { } }; +struct Retracement_BarOHLC : public BarOHLC { + bool GetLevels(ENUM_PP_TYPE _type, ENUM_APPLIED_PRICE _ap, double &_pp, double &_r1, double &_r2, double &_r3, + double &_r4, double &_s1, double &_s2, double &_s3, double &_s4) { + double _range = GetRange(); + switch (_ap) { + case PRICE_HIGH: + _ap = IsBull() ? _ap : PRICE_LOW; + break; + case PRICE_LOW: + _ap = IsBear() ? _ap : PRICE_HIGH; + break; + default: + break; + } + switch (_type) { + case PP_CAMARILLA: + // A set of eight very probable levels which resemble support and resistance values for a current trend. + _pp = GetAppliedPrice(_ap); + _r1 = (double)(close + _range * 1.1 / 12); + _r2 = (double)(close + _range * 1.1 / 6); + _r3 = (double)(close + _range * 1.1 / 4); + _r4 = (double)(close + _range * 1.1 / 2); + _s1 = (double)(close - _range * 1.1 / 12); + _s2 = (double)(close - _range * 1.1 / 6); + _s3 = (double)(close - _range * 1.1 / 4); + _s4 = (double)(close - _range * 1.1 / 2); + break; + case PP_CLASSIC: + _pp = GetAppliedPrice(_ap); + _r1 = (2 * _pp) - low; // R1 = (H - L) * 1.1 / 12 + C (1.0833) + _r2 = _pp + _range; // R2 = (H - L) * 1.1 / 6 + C (1.1666) + _r3 = _pp + _range * 2; // R3 = (H - L) * 1.1 / 4 + C (1.25) + _r4 = _pp + _range * 3; // R4 = (H - L) * 1.1 / 2 + C (1.5) + _s1 = (2 * _pp) - high; // S1 = C - (H - L) * 1.1 / 12 (1.0833) + _s2 = _pp - _range; // S2 = C - (H - L) * 1.1 / 6 (1.1666) + _s3 = _pp - _range * 2; // S3 = C - (H - L) * 1.1 / 4 (1.25) + _s4 = _pp - _range * 3; // S4 = C - (H - L) * 1.1 / 2 (1.5) + break; + case PP_FIBONACCI: + _pp = GetAppliedPrice(_ap); + _r1 = (double)(_pp + 0.236 * _range); + _r2 = (double)(_pp + 0.382 * _range); + _r3 = (double)(_pp + 0.500 * _range); + _r4 = (double)(_pp + 0.618 * _range); + // _r5 = (double)(_pp + 0.786 * _range); + _s1 = (double)(_pp - 0.236 * _range); + _s2 = (double)(_pp - 0.382 * _range); + _s3 = (double)(_pp - 0.500 * _range); + _s4 = (double)(_pp - 0.618 * _range); + // _s5 = (double)(_pp - 0.786 * _range); + break; + case PP_FLOOR: + // Most basic and popular type of pivots used in Forex trading technical analysis. + _pp = GetAppliedPrice(_ap); // Pivot (P) = (H + L + C) / 3 + _r1 = (2 * _pp) - low; // Resistance (R1) = (2 * P) - L + _r2 = _pp + _range; // R2 = P + H - L + _r3 = high + 2 * (_pp - low); // R3 = H + 2 * (P - L) + _r4 = _r3; + _s1 = (2 * _pp) - high; // Support (S1) = (2 * P) - H + _s2 = _pp - _range; // S2 = P - H + L + _s3 = low - 2 * (high - _pp); // S3 = L - 2 * (H - P) + _s4 = _s3; // ? + break; + case PP_TOM_DEMARK: + // Tom DeMark's pivot point (predicted lows and highs of the period). + _pp = GetAppliedPrice(_ap); + _r1 = (2 * _pp) - low; // New High = X / 2 - L. + _r2 = _pp + _range; + _r3 = _r1 + _range; + _r4 = _r2 + _range; // ? + _s1 = (2 * _pp) - high; // New Low = X / 2 - H. + _s2 = _pp - _range; + _s3 = _s1 - _range; + _s4 = _s2 - _range; // ? + break; + case PP_WOODIE: + // Woodie's pivot point are giving more weight to the Close price of the previous period. + // They are similar to floor pivot points, but are calculated in a somewhat different way. + _pp = GetAppliedPrice(_ap); // Pivot (P) = (H + L + 2 * C) / 4 + _r1 = (2 * _pp) - low; // Resistance (R1) = (2 * P) - L + _r2 = _pp + _range; // R2 = P + H - L + _r3 = _r1 + _range; + _r4 = _r2 + _range; // ? + _s1 = (2 * _pp) - high; // Support (S1) = (2 * P) - H + _s2 = _pp - _range; // S2 = P - H + L + _s3 = _s1 - _range; + _s4 = _s2 - _range; // ? + break; + default: + break; + } + return _r4 > _r3 && _r3 > _r2 && _r2 > _r1 && _r1 > _pp && _pp > _s1 && _s1 > _s2 && _s2 > _s3 && _s3 > _s4; + } +}; + class Stg_Retracement : public Strategy { protected: Stg_Retracement_Params_Defaults ssparams; @@ -242,39 +338,41 @@ class Stg_Retracement : public Strategy { // Returns false when indicator data is not valid. return false; } - // float _level_pips = (float)(_level * _chart.GetPipSize()); - float _level_pips = (float)(_level * _chart.GetPipSize()); - float _pp, _r1, _r2, _r3, _r4, _s1, _s2, _s3, _s4; - ChartEntry _ohlc_d1 = _chart.GetEntry(PERIOD_D1, _shift + 1, _chart.GetSymbol()); - double _d1_pivot = - _ohlc_d1.bar.ohlc.GetPivots(::Retracement_Levels_Calc_Method, _pp, _r1, _r2, _r3, _r4, _s1, _s2, _s3, _s4); - bool _ma_cross_r1_up = _indi[_ishift][0] > _r1 + _level_pips && _indi[_ishift + 1][0] < _r1; - bool _ma_cross_r2_up = _indi[_ishift][0] > _r2 + _level_pips && _indi[_ishift + 1][0] < _r2; - bool _ma_cross_r3_up = _indi[_ishift][0] > _r3 + _level_pips && _indi[_ishift + 1][0] < _r3; - bool _ma_cross_r4_up = _indi[_ishift][0] > _r4 + _level_pips && _indi[_ishift + 1][0] < _r4; - bool _ma_cross_s1_down = _indi[_ishift][0] < _s1 - _level_pips && _indi[_ishift + 1][0] > _s1; - bool _ma_cross_s2_down = _indi[_ishift][0] < _s2 - _level_pips && _indi[_ishift + 1][0] > _s2; - bool _ma_cross_s3_down = _indi[_ishift][0] < _s3 - _level_pips && _indi[_ishift + 1][0] > _s3; - bool _ma_cross_s4_down = _indi[_ishift][0] < _s4 - _level_pips && _indi[_ishift + 1][0] > _s4; + double _pp, _r1, _r2, _r3, _r4, _s1, _s2, _s3, _s4; + ChartEntry _ohlc_range = _chart.GetEntry(::Retracement_Levels_Tf, _shift + 1, _chart.GetSymbol()); + Retracement_BarOHLC _bar = _ohlc_range.GetBar().GetOHLC(); + _bar.GetLevels(::Retracement_Levels_Calc_Method, ::Retracement_Levels_Applied_Price, _pp, _r1, _r2, _r3, _r4, _s1, + _s2, _s3, _s4); + float _level_value = _bar.GetRange() / 100 * _level; + float _ma_level_prox_r = (float)fmin4(fabs(_indi[_ishift][0] - _r1), fabs(_indi[_ishift][0] - _r2), + fabs(_indi[_ishift][0] - _r3), fabs(_indi[_ishift][0] - _r4)); + float _ma_level_prox_s = (float)fmin4(fabs(_indi[_ishift][0] - _s1), fabs(_indi[_ishift][0] - _s2), + fabs(_indi[_ishift][0] - _s3), fabs(_indi[_ishift][0] - _s4)); switch (_cmd) { case ORDER_TYPE_BUY: // Buy signal. - _result &= _indi.IsIncreasing(1, 0, _ishift); - _result &= (_ma_cross_r1_up || _ma_cross_r2_up || _ma_cross_r3_up || _ma_cross_r4_up); + _result &= _bar.IsBull(); + _result &= _bar.IsBull() ? _indi.IsIncreasing(1, 0, _ishift) : _indi.IsDecreasing(1, 0, _ishift); + _result &= _ma_level_prox_s <= _level_value; if (_result && _method != 0) { if (METHOD(_method, 0)) - _result &= fmax4(_indi[_ishift][0], _indi[_ishift + 1][0], _indi[_ishift + 2][0], _indi[_ishift + 3][0]) == - _indi[_ishift][0]; + _result &= _bar.IsBull() ? fmax4(_indi[_ishift][0], _indi[_ishift + 1][0], _indi[_ishift + 2][0], + _indi[_ishift + 3][0]) == _indi[_ishift][0] + : fmin4(_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 &= _indi.IsDecreasing(1, 0, _ishift); - _result &= (_ma_cross_s1_down || _ma_cross_s2_down || _ma_cross_s3_down || _ma_cross_s4_down); + _result &= _bar.IsBear(); + _result &= _bar.IsBear() ? _indi.IsDecreasing(1, 0, _ishift) : _indi.IsIncreasing(1, 0, _ishift); + _result &= _ma_level_prox_s <= _level_value; if (_result && _method != 0) { if (METHOD(_method, 0)) - _result &= fmin4(_indi[_ishift][0], _indi[_ishift + 1][0], _indi[_ishift + 2][0], _indi[_ishift + 3][0]) == - _indi[_ishift][0]; + _result &= _bar.IsBear() ? fmin4(_indi[_ishift][0], _indi[_ishift + 1][0], _indi[_ishift + 2][0], + _indi[_ishift + 3][0]) == _indi[_ishift][0] + : fmax4(_indi[_ishift][0], _indi[_ishift + 1][0], _indi[_ishift + 2][0], + _indi[_ishift + 3][0]) == _indi[_ishift][0]; } break; } From 2c5819f250b6ccfeeac9aaf35385c9a07cfa25ea Mon Sep 17 00:00:00 2001 From: kenorb Date: Sun, 10 Sep 2023 17:40:11 +0100 Subject: [PATCH 5/6] Adds price stop logic --- Stg_Retracement.mqh | 62 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 58 insertions(+), 4 deletions(-) diff --git a/Stg_Retracement.mqh b/Stg_Retracement.mqh index 9a1268f..7cb6e33 100644 --- a/Stg_Retracement.mqh +++ b/Stg_Retracement.mqh @@ -18,10 +18,10 @@ enum ENUM_STG_RETRACEMENT_TYPE { // User params. INPUT_GROUP("Retracement strategy: main strategy params"); -INPUT ENUM_STG_RETRACEMENT_TYPE Retracement_Indi_Type = STG_RETRACEMENT_TYPE_TEMA; // Retracement: Indicator MA type -INPUT ENUM_PP_TYPE Retracement_Levels_Calc_Method = PP_FLOOR; // Method for level calculations -INPUT ENUM_APPLIED_PRICE Retracement_Levels_Applied_Price = PRICE_TYPICAL; // Calculation mode -INPUT ENUM_TIMEFRAMES Retracement_Levels_Tf = PERIOD_D1; // Calculation timeframe +INPUT ENUM_STG_RETRACEMENT_TYPE Retracement_Indi_Type = STG_RETRACEMENT_TYPE_FRAMA; // Retracement: Indicator MA type +INPUT ENUM_PP_TYPE Retracement_Levels_Calc_Method = PP_CLASSIC; // Method for level calculations +INPUT ENUM_APPLIED_PRICE Retracement_Levels_Applied_Price = PRICE_HIGH; // Calculation mode +INPUT ENUM_TIMEFRAMES Retracement_Levels_Tf = PERIOD_D1; // Calculation timeframe INPUT_GROUP("Retracement strategy: strategy params"); INPUT float Retracement_LotSize = 0; // Lot size INPUT int Retracement_SignalOpenMethod = 0; // Signal open method (-3-3) @@ -324,6 +324,60 @@ class Stg_Retracement : public Strategy { } } + /** + * Gets price stop value. + */ + float PriceStop(ENUM_ORDER_TYPE _cmd, ENUM_ORDER_TYPE_VALUE _mode, int _method = 0, float _level = 0.0f, + short _bars = 4) { + float _result = 0; + if (_method == 0) { + // Ignores calculation when method is 0. + return (float)_result; + } + float _trade_dist = trade.GetTradeDistanceInValue(); + int _count = (int)fmax(fabs(_level), fabs(_method)); + int _direction = Order::OrderDirection(_cmd, _mode); + uint _ishift = 0; + Chart *_chart = trade.GetChart(); + IndicatorBase *_indi = GetIndicator(::Retracement_Indi_Type); + + double _pp, _r1, _r2, _r3, _r4, _s1, _s2, _s3, _s4; + ChartEntry _ohlc_range = _chart.GetEntry(::Retracement_Levels_Tf, _ishift + 1, _chart.GetSymbol()); + Retracement_BarOHLC _bar = _ohlc_range.GetBar().GetOHLC(); + _bar.GetLevels(::Retracement_Levels_Calc_Method, ::Retracement_Levels_Applied_Price, _pp, _r1, _r2, _r3, _r4, _s1, + _s2, _s3, _s4); + float _level_value = _bar.GetRange() / 100 * _level; + float _ma_level_prox_r = (float)fmin4(fabs(_indi[_ishift][0] - _r1), fabs(_indi[_ishift][0] - _r2), + fabs(_indi[_ishift][0] - _r3), fabs(_indi[_ishift][0] - _r4)); + float _ma_level_prox_s = (float)fmin4(fabs(_indi[_ishift][0] - _s1), fabs(_indi[_ishift][0] - _s2), + fabs(_indi[_ishift][0] - _s3), fabs(_indi[_ishift][0] - _s4)); + switch (_mode) { + case ORDER_TYPE_SL: + if (_indi[_ishift][0] > _s1) { + _result = float(_s1 - _level_value); + } else if (_indi[_ishift][0] > _s2) { + _result = float(_s2 - _level_value); + } else if (_indi[_ishift][0] > _s3) { + _result = float(_s3 - _level_value); + } else if (_indi[_ishift][0] > _s4) { + _result = float(_s4 - _level_value); + } + break; + case ORDER_TYPE_TP: + if (_indi[_ishift][0] < _r1) { + _result = float(_r1 - _level_value); + } else if (_indi[_ishift][0] < _r2) { + _result = float(_r2 - _level_value); + } else if (_indi[_ishift][0] < _r3) { + _result = float(_r3 - _level_value); + } else if (_indi[_ishift][0] < _r4) { + _result = float(_r4 - _level_value); + } + break; + } + return (float)_result; + } + /** * Check strategy's opening signal. */ From ba1b054a56b2214732a2d2738bd385af7b1e384c Mon Sep 17 00:00:00 2001 From: kenorb Date: Sun, 10 Sep 2023 17:51:40 +0100 Subject: [PATCH 6/6] Sets Ichimoku as default indicator --- Stg_Retracement.mqh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Stg_Retracement.mqh b/Stg_Retracement.mqh index 7cb6e33..cbda411 100644 --- a/Stg_Retracement.mqh +++ b/Stg_Retracement.mqh @@ -18,10 +18,11 @@ enum ENUM_STG_RETRACEMENT_TYPE { // User params. INPUT_GROUP("Retracement strategy: main strategy params"); -INPUT ENUM_STG_RETRACEMENT_TYPE Retracement_Indi_Type = STG_RETRACEMENT_TYPE_FRAMA; // Retracement: Indicator MA type -INPUT ENUM_PP_TYPE Retracement_Levels_Calc_Method = PP_CLASSIC; // Method for level calculations -INPUT ENUM_APPLIED_PRICE Retracement_Levels_Applied_Price = PRICE_HIGH; // Calculation mode -INPUT ENUM_TIMEFRAMES Retracement_Levels_Tf = PERIOD_D1; // Calculation timeframe +INPUT ENUM_STG_RETRACEMENT_TYPE Retracement_Indi_Type = + STG_RETRACEMENT_TYPE_ICHIMOKU; // Retracement: Indicator MA type +INPUT ENUM_PP_TYPE Retracement_Levels_Calc_Method = PP_CLASSIC; // Method for level calculations +INPUT ENUM_APPLIED_PRICE Retracement_Levels_Applied_Price = PRICE_HIGH; // Calculation mode +INPUT ENUM_TIMEFRAMES Retracement_Levels_Tf = PERIOD_D1; // Calculation timeframe INPUT_GROUP("Retracement strategy: strategy params"); INPUT float Retracement_LotSize = 0; // Lot size INPUT int Retracement_SignalOpenMethod = 0; // Signal open method (-3-3)