From 65917ed8e72c78d7252f74f1c8acef738f519780 Mon Sep 17 00:00:00 2001 From: kenorb Date: Sat, 23 Sep 2023 13:59:29 +0100 Subject: [PATCH] Replaces MA with MA Breakout --- Stg_MA_Breakout.mq4 | 2 +- Stg_MA_Breakout.mq5 | 8 +- Stg_MA_Breakout.mqh | 298 ++++++++++++++++++++--------------------- Stg_MA_Breakout.mqproj | 93 ++++++++++++- 4 files changed, 243 insertions(+), 158 deletions(-) diff --git a/Stg_MA_Breakout.mq4 b/Stg_MA_Breakout.mq4 index 3a6eb51..b5a0787 100644 --- a/Stg_MA_Breakout.mq4 +++ b/Stg_MA_Breakout.mq4 @@ -6,7 +6,7 @@ /** * @file - * Implements MA strategy. + * Implements MA Breakout strategy. */ // Includes the main code. diff --git a/Stg_MA_Breakout.mq5 b/Stg_MA_Breakout.mq5 index 79db48a..4f51ba9 100644 --- a/Stg_MA_Breakout.mq5 +++ b/Stg_MA_Breakout.mq5 @@ -30,10 +30,10 @@ input bool Info_On_Chart = true; // Display info on chart. #include "Stg_MA_Breakout.mqh" // Defines. -#define ea_name "Strategy MA" +#define ea_name "Strategy MA Breakout" #define ea_version "2.000" -#define ea_desc "Strategy based on the moving average price indicators." -#define ea_link "https://github.com/EA31337/Strategy-MA" +#define ea_desc "Strategy based on the moving average price indicators implementing breakout signal." +#define ea_link "https://github.com/EA31337/Strategy-MA_Breakout" #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_MA_Breakout.mqh b/Stg_MA_Breakout.mqh index a3262c0..c204815 100644 --- a/Stg_MA_Breakout.mqh +++ b/Stg_MA_Breakout.mqh @@ -1,127 +1,127 @@ /** * @file - * Implements MA strategy based the moving average price indicators. + * Implements strategy based on the moving average price indicators implementing breakout signal. */ -enum ENUM_STG_MA_TYPE { - STG_MA_TYPE_0_NONE = 0, // (None) - STG_MA_TYPE_AMA, // AMA: Adaptive Moving Average - STG_MA_TYPE_DEMA, // DEMA: Double Exponential Moving Average - STG_MA_TYPE_FRAMA, // FrAMA: Fractal Adaptive Moving Average - STG_MA_TYPE_ICHIMOKU, // Ichimoku - STG_MA_TYPE_MA, // MA: Moving Average - STG_MA_TYPE_PRICE_CHANNEL, // Price Channel - STG_MA_TYPE_SAR, // SAR: Parabolic Stop and Reverse - STG_MA_TYPE_TEMA, // TEMA: Triple Exponential Moving Average - STG_MA_TYPE_VIDYA, // VIDYA: Variable Index Dynamic Average +enum ENUM_STG_MA_BREAKOUT_TYPE { + STG_MA_BREAKOUT_TYPE_0_NONE = 0, // (None) + STG_MA_BREAKOUT_TYPE_AMA, // AMA: Adaptive Moving Average + STG_MA_BREAKOUT_TYPE_DEMA, // DEMA: Double Exponential Moving Average + STG_MA_BREAKOUT_TYPE_FRAMA, // FrAMA: Fractal Adaptive Moving Average + STG_MA_BREAKOUT_TYPE_ICHIMOKU, // Ichimoku + STG_MA_BREAKOUT_TYPE_MA, // MA: Moving Average + STG_MA_BREAKOUT_TYPE_PRICE_CHANNEL, // Price Channel + STG_MA_BREAKOUT_TYPE_SAR, // SAR: Parabolic Stop and Reverse + STG_MA_BREAKOUT_TYPE_TEMA, // TEMA: Triple Exponential Moving Average + STG_MA_BREAKOUT_TYPE_VIDYA, // VIDYA: Variable Index Dynamic Average }; // User params. -INPUT_GROUP("MA strategy: main strategy params"); -INPUT ENUM_STG_MA_TYPE MA_Type = STG_MA_TYPE_MA; // Indicator MA type -INPUT_GROUP("MA strategy: strategy params"); -INPUT float MA_LotSize = 0; // Lot size -INPUT int MA_SignalOpenMethod = 1; // Signal open method (-127-127) -INPUT float MA_SignalOpenLevel = 0.2f; // Signal open level -INPUT int MA_SignalOpenFilterMethod = 32; // Signal open filter method -INPUT int MA_SignalOpenFilterTime = 3; // Signal open filter time -INPUT int MA_SignalOpenBoostMethod = 0; // Signal open boost method -INPUT int MA_SignalCloseMethod = 1; // Signal close method (-127-127) -INPUT int MA_SignalCloseFilter = 0; // Signal close filter (-127-127) -INPUT float MA_SignalCloseLevel = 0.0f; // Signal close level -INPUT int MA_PriceStopMethod = 1; // Price stop method (0-127) -INPUT float MA_PriceStopLevel = 2; // Price stop level -INPUT int MA_TickFilterMethod = 32; // Tick filter method -INPUT float MA_MaxSpread = 4.0; // Max spread to trade (pips) -INPUT short MA_Shift = 0; // Shift -INPUT float MA_OrderCloseLoss = 80; // Order close loss -INPUT float MA_OrderCloseProfit = 80; // Order close profit -INPUT int MA_OrderCloseTime = -30; // Order close time in mins (>0) or bars (<0) -INPUT_GROUP("MA strategy: AMA indicator params"); -INPUT int MA_Indi_AMA_InpPeriodAMA = 20; // AMA period -INPUT int MA_Indi_AMA_InpFastPeriodEMA = 4; // Fast EMA period -INPUT int MA_Indi_AMA_InpSlowPeriodEMA = 30; // Slow EMA period -INPUT int MA_Indi_AMA_InpShiftAMA = 4; // AMA shift -INPUT int MA_Indi_AMA_Shift = 0; // Shift -INPUT ENUM_IDATA_SOURCE_TYPE MA_Indi_AMA_SourceType = IDATA_BUILTIN; // Source type -INPUT_GROUP("MA strategy: DEMA indicator params"); -INPUT int MA_Indi_DEMA_Period = 25; // Period -INPUT int MA_Indi_DEMA_MA_Shift = 6; // MA Shift -INPUT ENUM_APPLIED_PRICE MA_Indi_DEMA_Applied_Price = PRICE_TYPICAL; // Applied Price -INPUT int MA_Indi_DEMA_Shift = 0; // DEMA Shift -INPUT ENUM_IDATA_SOURCE_TYPE MA_Indi_DEMA_SourceType = IDATA_BUILTIN; // Source type -INPUT_GROUP("MA strategy: FrAMA indicator params"); -INPUT int MA_Indi_FrAMA_Period = 10; // Period -INPUT ENUM_APPLIED_PRICE MA_Indi_FrAMA_Applied_Price = PRICE_MEDIAN; // Applied Price -INPUT int MA_Indi_FrAMA_MA_Shift = 0; // MA Shift -INPUT int MA_Indi_FrAMA_Shift = 0; // Shift -INPUT ENUM_IDATA_SOURCE_TYPE MA_Indi_FrAMA_SourceType = IDATA_BUILTIN; // Source type -INPUT_GROUP("MA strategy: Ichimoku indicator params"); -// INPUT ENUM_ICHIMOKU_LINE MA_Indi_Ichimoku_MA_Line = LINE_TENKANSEN; // Ichimoku line for MA -INPUT int MA_Indi_Ichimoku_Period_Tenkan_Sen = 30; // Period Tenkan Sen -INPUT int MA_Indi_Ichimoku_Period_Kijun_Sen = 10; // Period Kijun Sen -INPUT int MA_Indi_Ichimoku_Period_Senkou_Span_B = 30; // Period Senkou Span B -INPUT int MA_Indi_Ichimoku_Shift = 1; // Shift -INPUT ENUM_IDATA_SOURCE_TYPE MA_Indi_Ichimoku_SourceType = IDATA_BUILTIN; // Source type -INPUT_GROUP("MA strategy: MA indicator params"); -INPUT int MA_Indi_MA_Period = 26; // Period -INPUT int MA_Indi_MA_MA_Shift = 0; // MA Shift -INPUT ENUM_MA_METHOD MA_Indi_MA_Method = MODE_LWMA; // MA Method -INPUT ENUM_APPLIED_PRICE MA_Indi_MA_Applied_Price = PRICE_WEIGHTED; // Applied Price -INPUT int MA_Indi_MA_Shift = 0; // Shift -INPUT ENUM_IDATA_SOURCE_TYPE MA_Indi_MA_SourceType = IDATA_BUILTIN; // Source type -INPUT_GROUP("MA strategy: Price Channel indicator params"); -INPUT int MA_Indi_PriceChannel_Period = 26; // Period -INPUT int MA_Indi_PriceChannel_Shift = 0; // Shift -INPUT ENUM_IDATA_SOURCE_TYPE MA_Indi_PriceChannel_SourceType = IDATA_ICUSTOM; // Source type -INPUT_GROUP("MA strategy: SAR indicator params"); -INPUT float MA_Indi_SAR_Step = 0.04f; // Step -INPUT float MA_Indi_SAR_Maximum_Stop = 0.4f; // Maximum stop -INPUT int MA_Indi_SAR_Shift = 0; // Shift -INPUT ENUM_IDATA_SOURCE_TYPE MA_Indi_SAR_SourceType = IDATA_ICUSTOM; // Source type -INPUT_GROUP("MA strategy: TEMA indicator params"); -INPUT int MA_Indi_TEMA_Period = 10; // Period -INPUT int MA_Indi_TEMA_MA_Shift = 0; // MA Shift -INPUT ENUM_APPLIED_PRICE MA_Indi_TEMA_Applied_Price = PRICE_WEIGHTED; // Applied Price -INPUT int MA_Indi_TEMA_Shift = 0; // Shift -INPUT ENUM_IDATA_SOURCE_TYPE MA_Indi_TEMA_SourceType = IDATA_BUILTIN; // Source type -INPUT_GROUP("MA strategy: VIDYA indicator params"); -INPUT int MA_Indi_VIDYA_Period = 30; // Period -INPUT int MA_Indi_VIDYA_MA_Period = 20; // MA Period -INPUT int MA_Indi_VIDYA_MA_Shift = 1; // MA Shift -INPUT ENUM_APPLIED_PRICE MA_Indi_VIDYA_Applied_Price = PRICE_WEIGHTED; // Applied Price -INPUT int MA_Indi_VIDYA_Shift = 0; // Shift -INPUT ENUM_IDATA_SOURCE_TYPE MA_Indi_VIDYA_SourceType = IDATA_BUILTIN; // Source type +INPUT_GROUP("MA Breakout strategy: main strategy params"); +INPUT ENUM_STG_MA_BREAKOUT_TYPE MA_Breakout_Type = STG_MA_BREAKOUT_TYPE_MA; // Indicator MA type +INPUT_GROUP("MA Breakout strategy: strategy params"); +INPUT float MA_Breakout_LotSize = 0; // Lot size +INPUT int MA_Breakout_SignalOpenMethod = 1; // Signal open method (-127-127) +INPUT float MA_Breakout_SignalOpenLevel = 0.2f; // Signal open level +INPUT int MA_Breakout_SignalOpenFilterMethod = 32; // Signal open filter method +INPUT int MA_Breakout_SignalOpenFilterTime = 3; // Signal open filter time +INPUT int MA_Breakout_SignalOpenBoostMethod = 0; // Signal open boost method +INPUT int MA_Breakout_SignalCloseMethod = 1; // Signal close method (-127-127) +INPUT int MA_Breakout_SignalCloseFilter = 0; // Signal close filter (-127-127) +INPUT float MA_Breakout_SignalCloseLevel = 0.0f; // Signal close level +INPUT int MA_Breakout_PriceStopMethod = 1; // Price stop method (0-127) +INPUT float MA_Breakout_PriceStopLevel = 2; // Price stop level +INPUT int MA_Breakout_TickFilterMethod = 32; // Tick filter method +INPUT float MA_Breakout_MaxSpread = 4.0; // Max spread to trade (pips) +INPUT short MA_Breakout_Shift = 0; // Shift +INPUT float MA_Breakout_OrderCloseLoss = 80; // Order close loss +INPUT float MA_Breakout_OrderCloseProfit = 80; // Order close profit +INPUT int MA_Breakout_OrderCloseTime = -30; // Order close time in mins (>0) or bars (<0) +INPUT_GROUP("MA Breakout strategy: AMA indicator params"); +INPUT int MA_Breakout_Indi_AMA_InpPeriodAMA = 20; // AMA period +INPUT int MA_Breakout_Indi_AMA_InpFastPeriodEMA = 4; // Fast EMA period +INPUT int MA_Breakout_Indi_AMA_InpSlowPeriodEMA = 30; // Slow EMA period +INPUT int MA_Breakout_Indi_AMA_InpShiftAMA = 4; // AMA Breakout shift +INPUT int MA_Breakout_Indi_AMA_Shift = 0; // Shift +INPUT ENUM_IDATA_SOURCE_TYPE MA_Breakout_Indi_AMA_SourceType = IDATA_BUILTIN; // Source type +INPUT_GROUP("MA Breakout strategy: DEMA indicator params"); +INPUT int MA_Breakout_Indi_DEMA_Period = 25; // Period +INPUT int MA_Breakout_Indi_DEMA_MA_Shift = 6; // MA Shift +INPUT ENUM_APPLIED_PRICE MA_Breakout_Indi_DEMA_Applied_Price = PRICE_TYPICAL; // Applied Price +INPUT int MA_Breakout_Indi_DEMA_Shift = 0; // DEMA Shift +INPUT ENUM_IDATA_SOURCE_TYPE MA_Breakout_Indi_DEMA_SourceType = IDATA_BUILTIN; // Source type +INPUT_GROUP("MA Breakout strategy: FrAMA indicator params"); +INPUT int MA_Breakout_Indi_FrAMA_Period = 10; // Period +INPUT ENUM_APPLIED_PRICE MA_Breakout_Indi_FrAMA_Applied_Price = PRICE_MEDIAN; // Applied Price +INPUT int MA_Breakout_Indi_FrAMA_MA_Shift = 0; // MA Shift +INPUT int MA_Breakout_Indi_FrAMA_Shift = 0; // Shift +INPUT ENUM_IDATA_SOURCE_TYPE MA_Breakout_Indi_FrAMA_SourceType = IDATA_BUILTIN; // Source type +INPUT_GROUP("MA Breakout strategy: Ichimoku indicator params"); +// INPUT ENUM_ICHIMOKU_LINE MA_Breakout_Indi_Ichimoku_MA_Line = LINE_TENKANSEN; // Ichimoku line for MA +INPUT int MA_Breakout_Indi_Ichimoku_Period_Tenkan_Sen = 30; // Period Tenkan Sen +INPUT int MA_Breakout_Indi_Ichimoku_Period_Kijun_Sen = 10; // Period Kijun Sen +INPUT int MA_Breakout_Indi_Ichimoku_Period_Senkou_Span_B = 30; // Period Senkou Span B +INPUT int MA_Breakout_Indi_Ichimoku_Shift = 1; // Shift +INPUT ENUM_IDATA_SOURCE_TYPE MA_Breakout_Indi_Ichimoku_SourceType = IDATA_BUILTIN; // Source type +INPUT_GROUP("MA Breakout strategy: MA indicator params"); +INPUT int MA_Breakout_Indi_MA_Period = 26; // Period +INPUT int MA_Breakout_Indi_MA_MA_Shift = 0; // MA Shift +INPUT ENUM_MA_METHOD MA_Breakout_Indi_MA_Method = MODE_LWMA; // MA Method +INPUT ENUM_APPLIED_PRICE MA_Breakout_Indi_MA_Applied_Price = PRICE_WEIGHTED; // Applied Price +INPUT int MA_Breakout_Indi_MA_Shift = 0; // Shift +INPUT ENUM_IDATA_SOURCE_TYPE MA_Breakout_Indi_MA_SourceType = IDATA_BUILTIN; // Source type +INPUT_GROUP("MA Breakout strategy: Price Channel indicator params"); +INPUT int MA_Breakout_Indi_PriceChannel_Period = 26; // Period +INPUT int MA_Breakout_Indi_PriceChannel_Shift = 0; // Shift +INPUT ENUM_IDATA_SOURCE_TYPE MA_Breakout_Indi_PriceChannel_SourceType = IDATA_ICUSTOM; // Source type +INPUT_GROUP("MA Breakout strategy: SAR indicator params"); +INPUT float MA_Breakout_Indi_SAR_Step = 0.04f; // Step +INPUT float MA_Breakout_Indi_SAR_Maximum_Stop = 0.4f; // Maximum stop +INPUT int MA_Breakout_Indi_SAR_Shift = 0; // Shift +INPUT ENUM_IDATA_SOURCE_TYPE MA_Breakout_Indi_SAR_SourceType = IDATA_ICUSTOM; // Source type +INPUT_GROUP("MA Breakout strategy: TEMA indicator params"); +INPUT int MA_Breakout_Indi_TEMA_Period = 10; // Period +INPUT int MA_Breakout_Indi_TEMA_MA_Shift = 0; // MA Shift +INPUT ENUM_APPLIED_PRICE MA_Breakout_Indi_TEMA_Applied_Price = PRICE_WEIGHTED; // Applied Price +INPUT int MA_Breakout_Indi_TEMA_Shift = 0; // Shift +INPUT ENUM_IDATA_SOURCE_TYPE MA_Breakout_Indi_TEMA_SourceType = IDATA_BUILTIN; // Source type +INPUT_GROUP("MA Breakout strategy: VIDYA indicator params"); +INPUT int MA_Breakout_Indi_VIDYA_Period = 30; // Period +INPUT int MA_Breakout_Indi_VIDYA_MA_Period = 20; // MA Period +INPUT int MA_Breakout_Indi_VIDYA_MA_Shift = 1; // MA Shift +INPUT ENUM_APPLIED_PRICE MA_Breakout_Indi_VIDYA_Applied_Price = PRICE_WEIGHTED; // Applied Price +INPUT int MA_Breakout_Indi_VIDYA_Shift = 0; // Shift +INPUT ENUM_IDATA_SOURCE_TYPE MA_Breakout_Indi_VIDYA_SourceType = IDATA_BUILTIN; // Source type // Structs. // Defines struct with default user strategy values. -struct Stg_MA_Params_Defaults : StgParams { - Stg_MA_Params_Defaults() - : StgParams(::MA_SignalOpenMethod, ::MA_SignalOpenFilterMethod, ::MA_SignalOpenLevel, ::MA_SignalOpenBoostMethod, - ::MA_SignalCloseMethod, ::MA_SignalCloseFilter, ::MA_SignalCloseLevel, ::MA_PriceStopMethod, - ::MA_PriceStopLevel, ::MA_TickFilterMethod, ::MA_MaxSpread, ::MA_Shift) { - Set(STRAT_PARAM_LS, MA_LotSize); - Set(STRAT_PARAM_OCL, MA_OrderCloseLoss); - Set(STRAT_PARAM_OCP, MA_OrderCloseProfit); - Set(STRAT_PARAM_OCT, MA_OrderCloseTime); - Set(STRAT_PARAM_SOFT, MA_SignalOpenFilterTime); +struct Stg_MA_Breakout_Params_Defaults : StgParams { + Stg_MA_Breakout_Params_Defaults() + : StgParams(::MA_Breakout_SignalOpenMethod, ::MA_Breakout_SignalOpenFilterMethod, ::MA_Breakout_SignalOpenLevel, ::MA_Breakout_SignalOpenBoostMethod, + ::MA_Breakout_SignalCloseMethod, ::MA_Breakout_SignalCloseFilter, ::MA_Breakout_SignalCloseLevel, ::MA_Breakout_PriceStopMethod, + ::MA_Breakout_PriceStopLevel, ::MA_Breakout_TickFilterMethod, ::MA_Breakout_MaxSpread, ::MA_Breakout_Shift) { + Set(STRAT_PARAM_LS, MA_Breakout_LotSize); + Set(STRAT_PARAM_OCL, MA_Breakout_OrderCloseLoss); + Set(STRAT_PARAM_OCP, MA_Breakout_OrderCloseProfit); + Set(STRAT_PARAM_OCT, MA_Breakout_OrderCloseTime); + Set(STRAT_PARAM_SOFT, MA_Breakout_SignalOpenFilterTime); } }; -class Stg_MA : public Strategy { +class Stg_MA_Breakout : public Strategy { public: - Stg_MA(StgParams &_sparams, TradeParams &_tparams, ChartParams &_cparams, string _name = "") + Stg_MA_Breakout(StgParams &_sparams, TradeParams &_tparams, ChartParams &_cparams, string _name = "") : Strategy(_sparams, _tparams, _cparams, _name) {} - static Stg_MA *Init(ENUM_TIMEFRAMES _tf = NULL, EA *_ea = NULL) { + static Stg_MA_Breakout *Init(ENUM_TIMEFRAMES _tf = NULL, EA *_ea = NULL) { // Initialize strategy initial values. - Stg_MA_Params_Defaults stg_ma_defaults; + Stg_MA_Breakout_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(_stg_params, _tparams, _cparams, "MA"); + Strategy *_strat = new Stg_MA_Breakout(_stg_params, _tparams, _cparams, "MA"); return _strat; } @@ -130,88 +130,88 @@ class Stg_MA : public Strategy { */ void OnInit() { // Initialize indicators. - switch (MA_Type) { - case STG_MA_TYPE_AMA: // AMA + switch (::MA_Breakout_Type) { + case STG_MA_BREAKOUT_TYPE_AMA: // AMA { - IndiAMAParams _indi_params(::MA_Indi_AMA_InpPeriodAMA, ::MA_Indi_AMA_InpFastPeriodEMA, - ::MA_Indi_AMA_InpSlowPeriodEMA, ::MA_Indi_AMA_InpShiftAMA, PRICE_TYPICAL, - ::MA_Indi_AMA_Shift); - _indi_params.SetDataSourceType(::MA_Indi_AMA_SourceType); + IndiAMAParams _indi_params(::MA_Breakout_Indi_AMA_InpPeriodAMA, ::MA_Breakout_Indi_AMA_InpFastPeriodEMA, + ::MA_Breakout_Indi_AMA_InpSlowPeriodEMA, ::MA_Breakout_Indi_AMA_InpShiftAMA, PRICE_TYPICAL, + ::MA_Breakout_Indi_AMA_Shift); + _indi_params.SetDataSourceType(::MA_Breakout_Indi_AMA_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_AMA(_indi_params), ::MA_Type); + SetIndicator(new Indi_AMA(_indi_params), ::MA_Breakout_Type); break; } - case STG_MA_TYPE_DEMA: // DEMA + case STG_MA_BREAKOUT_TYPE_DEMA: // DEMA { - IndiDEIndiMAParams _indi_params(::MA_Indi_DEMA_Period, ::MA_Indi_DEMA_MA_Shift, ::MA_Indi_DEMA_Applied_Price, - ::MA_Indi_DEMA_Shift); - _indi_params.SetDataSourceType(::MA_Indi_DEMA_SourceType); + IndiDEIndiMAParams _indi_params(::MA_Breakout_Indi_DEMA_Period, ::MA_Breakout_Indi_DEMA_MA_Shift, ::MA_Breakout_Indi_DEMA_Applied_Price, + ::MA_Breakout_Indi_DEMA_Shift); + _indi_params.SetDataSourceType(::MA_Breakout_Indi_DEMA_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_DEMA(_indi_params), ::MA_Type); + SetIndicator(new Indi_DEMA(_indi_params), ::MA_Breakout_Type); break; } - case STG_MA_TYPE_FRAMA: // FrAMA + case STG_MA_BREAKOUT_TYPE_FRAMA: // FrAMA { - IndiFrAIndiMAParams _indi_params(::MA_Indi_FrAMA_Period, ::MA_Indi_FrAMA_MA_Shift, - ::MA_Indi_FrAMA_Applied_Price, ::MA_Indi_FrAMA_Shift); - _indi_params.SetDataSourceType(::MA_Indi_FrAMA_SourceType); + IndiFrAIndiMAParams _indi_params(::MA_Breakout_Indi_FrAMA_Period, ::MA_Breakout_Indi_FrAMA_MA_Shift, + ::MA_Breakout_Indi_FrAMA_Applied_Price, ::MA_Breakout_Indi_FrAMA_Shift); + _indi_params.SetDataSourceType(::MA_Breakout_Indi_FrAMA_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_FrAMA(_indi_params), ::MA_Type); + SetIndicator(new Indi_FrAMA(_indi_params), ::MA_Breakout_Type); break; } - case STG_MA_TYPE_ICHIMOKU: // Ichimoku + case STG_MA_BREAKOUT_TYPE_ICHIMOKU: // Ichimoku { - IndiIchimokuParams _indi_params(::MA_Indi_Ichimoku_Period_Tenkan_Sen, ::MA_Indi_Ichimoku_Period_Kijun_Sen, - ::MA_Indi_Ichimoku_Period_Senkou_Span_B, ::MA_Indi_Ichimoku_Shift); - _indi_params.SetDataSourceType(::MA_Indi_Ichimoku_SourceType); + IndiIchimokuParams _indi_params(::MA_Breakout_Indi_Ichimoku_Period_Tenkan_Sen, ::MA_Breakout_Indi_Ichimoku_Period_Kijun_Sen, + ::MA_Breakout_Indi_Ichimoku_Period_Senkou_Span_B, ::MA_Breakout_Indi_Ichimoku_Shift); + _indi_params.SetDataSourceType(::MA_Breakout_Indi_Ichimoku_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_Ichimoku(_indi_params), ::MA_Type); + SetIndicator(new Indi_Ichimoku(_indi_params), ::MA_Breakout_Type); break; } - case STG_MA_TYPE_MA: // MA + case STG_MA_BREAKOUT_TYPE_MA: // MA { - IndiMAParams _indi_params(::MA_Indi_MA_Period, ::MA_Indi_MA_MA_Shift, ::MA_Indi_MA_Method, - ::MA_Indi_MA_Applied_Price, ::MA_Indi_MA_Shift); - _indi_params.SetDataSourceType(::MA_Indi_MA_SourceType); + IndiMAParams _indi_params(::MA_Breakout_Indi_MA_Period, ::MA_Breakout_Indi_MA_MA_Shift, ::MA_Breakout_Indi_MA_Method, + ::MA_Breakout_Indi_MA_Applied_Price, ::MA_Breakout_Indi_MA_Shift); + _indi_params.SetDataSourceType(::MA_Breakout_Indi_MA_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_MA(_indi_params), ::MA_Type); + SetIndicator(new Indi_MA(_indi_params), ::MA_Breakout_Type); break; } - case STG_MA_TYPE_PRICE_CHANNEL: // Price Channel + case STG_MA_BREAKOUT_TYPE_PRICE_CHANNEL: // Price Channel { - IndiPriceChannelParams _indi_params(::MA_Indi_PriceChannel_Period, ::MA_Indi_PriceChannel_Shift); - _indi_params.SetDataSourceType(::MA_Indi_PriceChannel_SourceType); + IndiPriceChannelParams _indi_params(::MA_Breakout_Indi_PriceChannel_Period, ::MA_Breakout_Indi_PriceChannel_Shift); + _indi_params.SetDataSourceType(::MA_Breakout_Indi_PriceChannel_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_PriceChannel(_indi_params), ::MA_Type); + SetIndicator(new Indi_PriceChannel(_indi_params), ::MA_Breakout_Type); break; } - case STG_MA_TYPE_SAR: // SAR + case STG_MA_BREAKOUT_TYPE_SAR: // SAR { - IndiSARParams _indi_params(::MA_Indi_SAR_Step, ::MA_Indi_SAR_Maximum_Stop, ::MA_Indi_SAR_Shift); - _indi_params.SetDataSourceType(::MA_Indi_SAR_SourceType); + IndiSARParams _indi_params(::MA_Breakout_Indi_SAR_Step, ::MA_Breakout_Indi_SAR_Maximum_Stop, ::MA_Breakout_Indi_SAR_Shift); + _indi_params.SetDataSourceType(::MA_Breakout_Indi_SAR_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_SAR(_indi_params), ::MA_Type); + SetIndicator(new Indi_SAR(_indi_params), ::MA_Breakout_Type); break; } - case STG_MA_TYPE_TEMA: // TEMA + case STG_MA_BREAKOUT_TYPE_TEMA: // TEMA { - IndiTEMAParams _indi_params(::MA_Indi_TEMA_Period, ::MA_Indi_TEMA_MA_Shift, ::MA_Indi_TEMA_Applied_Price, - ::MA_Indi_TEMA_Shift); - _indi_params.SetDataSourceType(::MA_Indi_TEMA_SourceType); + IndiTEMAParams _indi_params(::MA_Breakout_Indi_TEMA_Period, ::MA_Breakout_Indi_TEMA_MA_Shift, ::MA_Breakout_Indi_TEMA_Applied_Price, + ::MA_Breakout_Indi_TEMA_Shift); + _indi_params.SetDataSourceType(::MA_Breakout_Indi_TEMA_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_TEMA(_indi_params), ::MA_Type); + SetIndicator(new Indi_TEMA(_indi_params), ::MA_Breakout_Type); break; } - case STG_MA_TYPE_VIDYA: // VIDYA + case STG_MA_BREAKOUT_TYPE_VIDYA: // VIDYA { - IndiVIDYAParams _indi_params(::MA_Indi_VIDYA_Period, ::MA_Indi_VIDYA_MA_Period, ::MA_Indi_VIDYA_MA_Shift, - ::MA_Indi_VIDYA_Applied_Price, ::MA_Indi_VIDYA_Shift); - _indi_params.SetDataSourceType(::MA_Indi_VIDYA_SourceType); + IndiVIDYAParams _indi_params(::MA_Breakout_Indi_VIDYA_Period, ::MA_Breakout_Indi_VIDYA_MA_Period, ::MA_Breakout_Indi_VIDYA_MA_Shift, + ::MA_Breakout_Indi_VIDYA_Applied_Price, ::MA_Breakout_Indi_VIDYA_Shift); + _indi_params.SetDataSourceType(::MA_Breakout_Indi_VIDYA_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_VIDYA(_indi_params), ::MA_Type); + SetIndicator(new Indi_VIDYA(_indi_params), ::MA_Breakout_Type); break; } - case STG_MA_TYPE_0_NONE: // (None) + case STG_MA_BREAKOUT_TYPE_0_NONE: // (None) default: break; } @@ -222,7 +222,7 @@ class Stg_MA : 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_Type); + IndicatorBase *_indi = GetIndicator(::MA_Breakout_Type); uint _ishift = _shift; // @todo: _indi.GetShift(); // bool _result = _indi.GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift); // @fixme bool _result = true; diff --git a/Stg_MA_Breakout.mqproj b/Stg_MA_Breakout.mqproj index 486d5dc..2b50749 100644 --- a/Stg_MA_Breakout.mqproj +++ b/Stg_MA_Breakout.mqproj @@ -2,7 +2,7 @@ "platform" :"mt5", "program_type":"expert", "copyright" :"Copyright 2016-2023, EA31337 Ltd", - "link" :"https:\/\/github.com\/EA31337\/Strategy-MA", + "link" :"https:\/\/github.com\/EA31337\/Strategy-MA_Breakout", "version" :"2.000", "description" :"Strategy based on the moving average price indicators.", "optimize" :"0", @@ -15,7 +15,7 @@ "files": [ { - "path":"Stg_MA.mq5", + "path":"Stg_MA_Breakout.mq5", "compile":true, "relative_to_project":true }, @@ -215,7 +215,7 @@ "relative_to_project":false }, { - "path":"Stg_MA.mqh", + "path":"Stg_MA_Breakout.mqh", "compile":false, "relative_to_project":true }, @@ -708,6 +708,91 @@ "path":"MQL5\\Include\\EA31337-classes\\Storage\\Singleton.h", "compile":false, "relative_to_project":false + }, + { + "path":"MQL5\\Include\\EA31337-classes\\Indicators\\Indi_AMA.mqh", + "compile":false, + "relative_to_project":false + }, + { + "path":"MQL5\\Include\\EA31337-classes\\Storage\\ValueStorage.price.h", + "compile":false, + "relative_to_project":false + }, + { + "path":"MQL5\\Include\\EA31337-classes\\Storage\\ObjectsCache.h", + "compile":false, + "relative_to_project":false + }, + { + "path":"MQL5\\Include\\EA31337-classes\\Indicators\\Price\\Indi_Price.mqh", + "compile":false, + "relative_to_project":false + }, + { + "path":"MQL5\\Include\\EA31337-classes\\Indicators\\Indi_DEMA.mqh", + "compile":false, + "relative_to_project":false + }, + { + "path":"MQL5\\Include\\EA31337-classes\\Indicators\\Indi_FractalAdaptiveMA.mqh", + "compile":false, + "relative_to_project":false + }, + { + "path":"MQL5\\Include\\EA31337-classes\\Storage\\ValueStorage.all.h", + "compile":false, + "relative_to_project":false + }, + { + "path":"MQL5\\Include\\EA31337-classes\\Storage\\ValueStorage.spread.h", + "compile":false, + "relative_to_project":false + }, + { + "path":"MQL5\\Include\\EA31337-classes\\Storage\\ValueStorage.tick_volume.h", + "compile":false, + "relative_to_project":false + }, + { + "path":"MQL5\\Include\\EA31337-classes\\Storage\\ValueStorage.time.h", + "compile":false, + "relative_to_project":false + }, + { + "path":"MQL5\\Include\\EA31337-classes\\Storage\\ValueStorage.volume.h", + "compile":false, + "relative_to_project":false + }, + { + "path":"MQL5\\Include\\EA31337-classes\\Indicators\\Indi_Ichimoku.mqh", + "compile":false, + "relative_to_project":false + }, + { + "path":"MQL5\\Include\\EA31337-classes\\Indicators\\Indi_PriceChannel.mqh", + "compile":false, + "relative_to_project":false + }, + { + "path":"MQL5\\Include\\EA31337-classes\\Indicators\\Indi_ZigZag.mqh", + "compile":false, + "relative_to_project":false + }, + { + "path":"MQL5\\Include\\EA31337-classes\\Indicators\\Indi_SAR.mqh", + "compile":false, + "relative_to_project":false + }, + { + "path":"MQL5\\Include\\EA31337-classes\\Indicators\\Indi_TEMA.mqh", + "compile":false, + "relative_to_project":false + }, + { + "path":"MQL5\\Include\\EA31337-classes\\Indicators\\Indi_VIDYA.mqh", + "compile":false, + "relative_to_project":false } ] -} +} \ No newline at end of file