diff --git a/Stg_Oscillator.mqh b/Stg_Oscillator.mqh index 8bfdbd3..f7c2ae8 100644 --- a/Stg_Oscillator.mqh +++ b/Stg_Oscillator.mqh @@ -319,33 +319,29 @@ class Stg_Oscillator : public Strategy { case STG_OSCILLATOR_TYPE_AC: // AC { IndiACParams _indi_params(::Oscillator_Indi_AC_Shift); - _indi_params.SetDataSourceType(Oscillator_Indi_AC_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_AC(_indi_params), ::Oscillator_Type); + SetIndicator(new Indi_AC(_indi_params, ::Oscillator_Indi_AC_SourceType), ::Oscillator_Type); break; } case STG_OSCILLATOR_TYPE_AD: // AD { IndiADParams _indi_params(::Oscillator_Indi_AD_Shift); - _indi_params.SetDataSourceType(Oscillator_Indi_AD_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_AD(_indi_params), ::Oscillator_Type); + SetIndicator(new Indi_AD(_indi_params, ::Oscillator_Indi_AD_SourceType), ::Oscillator_Type); break; } case STG_OSCILLATOR_TYPE_AO: // AO { IndiAOParams _indi_params(::Oscillator_Indi_Awesome_Shift); - _indi_params.SetDataSourceType(Oscillator_Indi_Awesome_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_AO(_indi_params), ::Oscillator_Type); + SetIndicator(new Indi_AO(_indi_params, ::Oscillator_Indi_Awesome_SourceType), ::Oscillator_Type); break; } case STG_OSCILLATOR_TYPE_ATR: // ATR { IndiATRParams _indi_params(::Oscillator_Indi_ATR_Period, ::Oscillator_Indi_ATR_Shift); - _indi_params.SetDataSourceType(Oscillator_Indi_ATR_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_ATR(_indi_params), ::Oscillator_Type); + SetIndicator(new Indi_ATR(_indi_params, ::Oscillator_Indi_ATR_SourceType), ::Oscillator_Type); break; } case STG_OSCILLATOR_TYPE_BEARS: // Bears @@ -353,9 +349,8 @@ class Stg_Oscillator : public Strategy { IndiBearsPowerParams _indi_params(::Oscillator_Indi_BearsPower_Period, ::Oscillator_Indi_BearsPower_Applied_Price, ::Oscillator_Indi_BearsPower_Shift); - _indi_params.SetDataSourceType(Oscillator_Indi_BearsPower_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_BearsPower(_indi_params), ::Oscillator_Type); + SetIndicator(new Indi_BearsPower(_indi_params, ::Oscillator_Indi_BearsPower_SourceType), ::Oscillator_Type); break; } case STG_OSCILLATOR_TYPE_BULLS: // Bulls @@ -363,26 +358,23 @@ class Stg_Oscillator : public Strategy { IndiBullsPowerParams _indi_params(::Oscillator_Indi_BullsPower_Period, ::Oscillator_Indi_BullsPower_Applied_Price, ::Oscillator_Indi_BullsPower_Shift); - _indi_params.SetDataSourceType(Oscillator_Indi_BullsPower_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_BullsPower(_indi_params), ::Oscillator_Type); + SetIndicator(new Indi_BullsPower(_indi_params, ::Oscillator_Indi_BullsPower_SourceType), ::Oscillator_Type); break; } case STG_OSCILLATOR_TYPE_BWMFI: // BWMFI { IndiBWIndiMFIParams _indi_params(::Oscillator_Indi_BWMFI_Shift); - _indi_params.SetDataSourceType(Oscillator_Indi_BWMFI_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_BWMFI(_indi_params), ::Oscillator_Type); + SetIndicator(new Indi_BWMFI(_indi_params, ::Oscillator_Indi_BWMFI_SourceType), ::Oscillator_Type); break; } case STG_OSCILLATOR_TYPE_CCI: // CCI { IndiCCIParams _indi_params(::Oscillator_Indi_CCI_Period, ::Oscillator_Indi_CCI_Applied_Price, ::Oscillator_Indi_CCI_Shift); - _indi_params.SetDataSourceType(Oscillator_Indi_CCI_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_CCI(_indi_params), ::Oscillator_Type); + SetIndicator(new Indi_CCI(_indi_params, ::Oscillator_Indi_CCI_SourceType), ::Oscillator_Type); break; } case STG_OSCILLATOR_TYPE_CHO: // Chaikin (CHO) @@ -390,78 +382,69 @@ class Stg_Oscillator : public Strategy { IndiCHOParams _indi_params(::Oscillator_Indi_CHO_InpFastMA, ::Oscillator_Indi_CHO_InpSlowMA, ::Oscillator_Indi_CHO_InpSmoothMethod, ::Oscillator_Indi_CHO_InpVolumeType, ::Oscillator_Indi_CHO_Shift); - _indi_params.SetDataSourceType(::Oscillator_Indi_CHO_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_CHO(_indi_params), ::Oscillator_Type); + SetIndicator(new Indi_CHO(_indi_params, ::Oscillator_Indi_CHO_SourceType), ::Oscillator_Type); break; } case STG_OSCILLATOR_TYPE_CHV: // Chaikin Volatility (CHV) { IndiCHVParams _indi_params(::Oscillator_Indi_CHV_Smooth_Period, ::Oscillator_Indi_CHV_Period, ::Oscillator_Indi_CHV_Smooth_Method, ::Oscillator_Indi_CHV_Shift); - _indi_params.SetDataSourceType(::Oscillator_Indi_CHV_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_CHV(_indi_params), ::Oscillator_Type); + SetIndicator(new Indi_CHV(_indi_params, ::Oscillator_Indi_CHV_SourceType), ::Oscillator_Type); break; } case STG_OSCILLATOR_TYPE_DEMARKER: // DeMarker { IndiDeMarkerParams _indi_params(::Oscillator_Indi_DeMarker_Period, ::Oscillator_Indi_DeMarker_Shift); - _indi_params.SetDataSourceType(Oscillator_Indi_DeMarker_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_DeMarker(_indi_params), ::Oscillator_Type); + SetIndicator(new Indi_DeMarker(_indi_params, ::Oscillator_Indi_DeMarker_SourceType), ::Oscillator_Type); break; } case STG_OSCILLATOR_TYPE_MFI: // MFI { IndiMFIParams _indi_params(::Oscillator_Indi_MFI_MA_Period, ::Oscillator_Indi_MFI_Applied_Volume, ::Oscillator_Indi_MFI_Shift); - _indi_params.SetDataSourceType(::Oscillator_Indi_MFI_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_MFI(_indi_params), ::Oscillator_Type); + SetIndicator(new Indi_MFI(_indi_params, ::Oscillator_Indi_MFI_SourceType), ::Oscillator_Type); break; } case STG_OSCILLATOR_TYPE_MOM: // MOM { IndiMomentumParams _indi_params(::Oscillator_Indi_Momentum_Period, ::Oscillator_Indi_Momentum_Applied_Price, ::Oscillator_Indi_Momentum_Shift); - _indi_params.SetDataSourceType(::Oscillator_Indi_Momentum_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_Momentum(_indi_params), ::Oscillator_Type); + SetIndicator(new Indi_Momentum(_indi_params, ::Oscillator_Indi_Momentum_SourceType), ::Oscillator_Type); break; } case STG_OSCILLATOR_TYPE_OBV: // OBV { IndiOBVParams _indi_params(::Oscillator_Indi_OBV_Applied_Price, ::Oscillator_Indi_OBV_Shift); - _indi_params.SetDataSourceType(::Oscillator_Indi_OBV_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_OBV(_indi_params), ::Oscillator_Type); + SetIndicator(new Indi_OBV(_indi_params, ::Oscillator_Indi_OBV_SourceType), ::Oscillator_Type); break; } case STG_OSCILLATOR_TYPE_PVT: // PVT { IndiPriceVolumeTrendParams _indi_params(::Oscillator_Indi_PVT_InpVolumeType, ::Oscillator_Indi_PVT_Shift); - _indi_params.SetDataSourceType(::Oscillator_Indi_PVT_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_PriceVolumeTrend(_indi_params), ::Oscillator_Type); + SetIndicator(new Indi_PriceVolumeTrend(_indi_params, ::Oscillator_Indi_PVT_SourceType), ::Oscillator_Type); break; } case STG_OSCILLATOR_TYPE_ROC: // ROC { IndiRateOfChangeParams _indi_params(::Oscillator_Indi_ROC_Period, ::Oscillator_Indi_ROC_Applied_Price, ::Oscillator_Indi_ROC_Shift); - _indi_params.SetDataSourceType(::Oscillator_Indi_ROC_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_RateOfChange(_indi_params), ::Oscillator_Type); + SetIndicator(new Indi_RateOfChange(_indi_params, ::Oscillator_Indi_ROC_SourceType), ::Oscillator_Type); break; } case STG_OSCILLATOR_TYPE_RSI: // RSI { IndiRSIParams _indi_params(::Oscillator_Indi_RSI_Period, ::Oscillator_Indi_RSI_Applied_Price, ::Oscillator_Indi_RSI_Shift); - _indi_params.SetDataSourceType(::Oscillator_Indi_RSI_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_RSI(_indi_params), ::Oscillator_Type); + SetIndicator(new Indi_RSI(_indi_params, ::Oscillator_Indi_RSI_SourceType), ::Oscillator_Type); break; } case STG_OSCILLATOR_TYPE_STDDEV: // StdDev @@ -469,9 +452,8 @@ class Stg_Oscillator : public Strategy { IndiStdDevParams _indi_params(::Oscillator_Indi_StdDev_MA_Period, ::Oscillator_Indi_StdDev_MA_Shift, ::Oscillator_Indi_StdDev_MA_Method, ::Oscillator_Indi_StdDev_Applied_Price, ::Oscillator_Indi_StdDev_Shift); - _indi_params.SetDataSourceType(::Oscillator_Indi_StdDev_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_StdDev(_indi_params), ::Oscillator_Type); + SetIndicator(new Indi_StdDev(_indi_params, ::Oscillator_Indi_StdDev_SourceType), ::Oscillator_Type); break; } case STG_OSCILLATOR_TYPE_STOCH: // Stochastic @@ -479,18 +461,16 @@ class Stg_Oscillator : public Strategy { IndiStochParams _indi_params(::Oscillator_Indi_Stochastic_KPeriod, ::Oscillator_Indi_Stochastic_DPeriod, ::Oscillator_Indi_Stochastic_Slowing, ::Oscillator_Indi_Stochastic_MA_Method, ::Oscillator_Indi_Stochastic_Price_Field, ::Oscillator_Indi_Stochastic_Shift); - _indi_params.SetDataSourceType(::Oscillator_Indi_Stochastic_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_Stochastic(_indi_params), ::Oscillator_Type); + SetIndicator(new Indi_Stochastic(_indi_params, ::Oscillator_Indi_Stochastic_SourceType), ::Oscillator_Type); break; } case STG_OSCILLATOR_TYPE_TRIX: // TRIX { IndiTRIXParams _indi_params(::Oscillator_Indi_TRIX_InpPeriodEMA, ::Oscillator_Indi_TRIX_Applied_Price, ::Oscillator_Indi_TRIX_Shift); - _indi_params.SetDataSourceType(::Oscillator_Indi_TRIX_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_TRIX(_indi_params), ::Oscillator_Type); + SetIndicator(new Indi_TRIX(_indi_params, ::Oscillator_Indi_TRIX_SourceType), ::Oscillator_Type); break; } case STG_OSCILLATOR_TYPE_UO: // UO @@ -499,33 +479,29 @@ class Stg_Oscillator : public Strategy { ::Oscillator_Indi_UO_InpFastPeriod, ::Oscillator_Indi_UO_InpMiddlePeriod, ::Oscillator_Indi_UO_InpSlowPeriod, ::Oscillator_Indi_UO_InpFastK, ::Oscillator_Indi_UO_InpMiddleK, ::Oscillator_Indi_UO_InpSlowK, ::Oscillator_Indi_UO_Shift); - _indi_params.SetDataSourceType(::Oscillator_Indi_UO_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_UltimateOscillator(_indi_params), ::Oscillator_Type); + SetIndicator(new Indi_UltimateOscillator(_indi_params, ::Oscillator_Indi_UO_SourceType), ::Oscillator_Type); break; } case STG_OSCILLATOR_TYPE_WAD: // Williams' AD { IndiWilliamsADParams _indi_params(::Oscillator_Indi_WAD_Shift); - _indi_params.SetDataSourceType(Oscillator_Indi_WAD_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_WilliamsAD(_indi_params), ::Oscillator_Type); + SetIndicator(new Indi_WilliamsAD(_indi_params, ::Oscillator_Indi_WAD_SourceType), ::Oscillator_Type); break; } case STG_OSCILLATOR_TYPE_WPR: // WPR { IndiWPRParams _indi_params(::Oscillator_Indi_WPR_Period, ::Oscillator_Indi_WPR_Shift); - _indi_params.SetDataSourceType(::Oscillator_Indi_WPR_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_WPR(_indi_params), ::Oscillator_Type); + SetIndicator(new Indi_WPR(_indi_params, ::Oscillator_Indi_WPR_SourceType), ::Oscillator_Type); break; } case STG_OSCILLATOR_TYPE_VOL: // Volumes { IndiVolumesParams _indi_params(::Oscillator_Indi_VOL_InpVolumeType, ::Oscillator_Indi_VOL_Shift); - _indi_params.SetDataSourceType(::Oscillator_Indi_VOL_SourceType); _indi_params.SetTf(Get(STRAT_PARAM_TF)); - SetIndicator(new Indi_Volumes(_indi_params), ::Oscillator_Type); + SetIndicator(new Indi_Volumes(_indi_params, ::Oscillator_Indi_VOL_SourceType), ::Oscillator_Type); break; } case STG_OSCILLATOR_TYPE_0_NONE: // (None) @@ -538,7 +514,7 @@ class Stg_Oscillator : public Strategy { * Check strategy's opening signal. */ bool SignalOpen(ENUM_ORDER_TYPE _cmd, int _method, float _level = 0.0f, int _shift = 0) { - IndicatorBase *_indi = GetIndicator(::Oscillator_Type); + IndicatorData *_indi = GetIndicator(::Oscillator_Type); // uint _ishift = _indi.GetShift(); bool _result = Oscillator_Type != STG_OSCILLATOR_TYPE_0_NONE && IsValidEntry(_indi, _shift); if (!_result) {