Skip to content

Commit

Permalink
Fixes compatibility with classes v3.001-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
kenorb committed Oct 11, 2024
1 parent 7b6835c commit 0857f42
Showing 1 changed file with 32 additions and 57 deletions.
89 changes: 32 additions & 57 deletions Stg_Oscillator_Overlay.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ enum ENUM_STG_OSCILLATOR_OVERLAY_TYPE {

// User input params.
INPUT_GROUP("Oscillator Overlay strategy: main strategy params");
INPUT ENUM_STG_OSCILLATOR_OVERLAY_TYPE Oscillator_Overlay_Type_Base =
INPUT ENUM_STG_OSCILLATOR_OVERLAY_TYPE Oscillator_Overlay_Type_Data =
STG_OSCILLATOR_OVERLAY_TYPE_BULLS; // Oscillator base
INPUT ENUM_STG_OSCILLATOR_OVERLAY_TYPE Oscillator_Overlay_Type_Overlayed =
STG_OSCILLATOR_OVERLAY_TYPE_RSI; // Oscillator overlayed
Expand Down Expand Up @@ -210,7 +210,7 @@ class Stg_Oscillator_Overlay : public Strategy {
/**
* Validate soscillators's entry.
*/
bool IsValidEntry(IndicatorBase *_indi, int _shift = 0) {
bool IsValidEntry(IndicatorData *_indi, int _shift = 0) {
bool _result = true;
switch (::Oscillator_Overlay_Type_Overlayed) {
case STG_OSCILLATOR_OVERLAY_TYPE_AC:
Expand Down Expand Up @@ -320,13 +320,12 @@ class Stg_Oscillator_Overlay : public Strategy {
*/
void OnInit() {
// Initialize indicators.
SetIndicatorByType(::Oscillator_Overlay_Type_Base, ::Oscillator_Overlay_Type_Base);
SetIndicatorByType(::Oscillator_Overlay_Type_Overlayed, ::Oscillator_Overlay_Type_Base + 1);
IndicatorBase *_indi_base = GetIndicator(::Oscillator_Overlay_Type_Base);
IndicatorBase *_indi_overlayed = GetIndicator(::Oscillator_Overlay_Type_Base + 1);
if (::Oscillator_Overlay_Type_Base != STG_OSCILLATOR_OVERLAY_TYPE_0_NONE &&
SetIndicatorByType(::Oscillator_Overlay_Type_Data, ::Oscillator_Overlay_Type_Data);
SetIndicatorByType(::Oscillator_Overlay_Type_Overlayed, ::Oscillator_Overlay_Type_Data + 1);
IndicatorData *_indi_base = GetIndicator(::Oscillator_Overlay_Type_Data);
IndicatorData *_indi_overlayed = GetIndicator(::Oscillator_Overlay_Type_Data + 1);
if (::Oscillator_Overlay_Type_Data != STG_OSCILLATOR_OVERLAY_TYPE_0_NONE &&
::Oscillator_Overlay_Type_Overlayed != STG_OSCILLATOR_OVERLAY_TYPE_0_NONE) {
_indi_overlayed.SetDataSource(_indi_base);
}
}

Expand All @@ -338,153 +337,136 @@ class Stg_Oscillator_Overlay : public Strategy {
case STG_OSCILLATOR_OVERLAY_TYPE_AC: // AC
{
IndiACParams _indi_params(::Oscillator_Overlay_Indi_AC_Shift);
_indi_params.SetDataSourceType(Oscillator_Overlay_Indi_AC_SourceType);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_AC(_indi_params), _index);
SetIndicator(new Indi_AC(_indi_params, ::Oscillator_Overlay_Indi_AC_SourceType), _index);
break;
}
case STG_OSCILLATOR_OVERLAY_TYPE_AD: // AD
{
IndiADParams _indi_params(::Oscillator_Overlay_Indi_AD_Shift);
_indi_params.SetDataSourceType(Oscillator_Overlay_Indi_AD_SourceType);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_AD(_indi_params), _index);
SetIndicator(new Indi_AD(_indi_params, ::Oscillator_Overlay_Indi_AD_SourceType), _index);
break;
}
case STG_OSCILLATOR_OVERLAY_TYPE_AO: // AO
{
IndiAOParams _indi_params(::Oscillator_Overlay_Indi_Awesome_Shift);
_indi_params.SetDataSourceType(Oscillator_Overlay_Indi_Awesome_SourceType);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_AO(_indi_params), _index);
SetIndicator(new Indi_AO(_indi_params, ::Oscillator_Overlay_Indi_Awesome_SourceType), _index);
break;
}
case STG_OSCILLATOR_OVERLAY_TYPE_ATR: // ATR
{
IndiATRParams _indi_params(::Oscillator_Overlay_Indi_ATR_Period, ::Oscillator_Overlay_Indi_ATR_Shift);
_indi_params.SetDataSourceType(Oscillator_Overlay_Indi_ATR_SourceType);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_ATR(_indi_params), _index);
SetIndicator(new Indi_ATR(_indi_params, ::Oscillator_Overlay_Indi_ATR_SourceType), _index);
break;
}
case STG_OSCILLATOR_OVERLAY_TYPE_BEARS: // Bears
{
IndiBearsPowerParams _indi_params(::Oscillator_Overlay_Indi_BearsPower_Period,
::Oscillator_Overlay_Indi_BearsPower_Applied_Price,
::Oscillator_Overlay_Indi_BearsPower_Shift);
_indi_params.SetDataSourceType(Oscillator_Overlay_Indi_BearsPower_SourceType);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_BearsPower(_indi_params), _index);
SetIndicator(new Indi_BearsPower(_indi_params, ::Oscillator_Overlay_Indi_BearsPower_SourceType), _index);
break;
}
case STG_OSCILLATOR_OVERLAY_TYPE_BULLS: // Bulls
{
IndiBullsPowerParams _indi_params(::Oscillator_Overlay_Indi_BullsPower_Period,
::Oscillator_Overlay_Indi_BullsPower_Applied_Price,
::Oscillator_Overlay_Indi_BullsPower_Shift);
_indi_params.SetDataSourceType(Oscillator_Overlay_Indi_BullsPower_SourceType);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_BullsPower(_indi_params), _index);
SetIndicator(new Indi_BullsPower(_indi_params, ::Oscillator_Overlay_Indi_BullsPower_SourceType), _index);
break;
}
case STG_OSCILLATOR_OVERLAY_TYPE_BWMFI: // BWMFI
{
IndiBWIndiMFIParams _indi_params(::Oscillator_Overlay_Indi_BWMFI_Shift);
_indi_params.SetDataSourceType(Oscillator_Overlay_Indi_BWMFI_SourceType);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_BWMFI(_indi_params), _index);
SetIndicator(new Indi_BWMFI(_indi_params, ::Oscillator_Overlay_Indi_BWMFI_SourceType), _index);
break;
}
case STG_OSCILLATOR_OVERLAY_TYPE_CCI: // CCI
{
IndiCCIParams _indi_params(::Oscillator_Overlay_Indi_CCI_Period, ::Oscillator_Overlay_Indi_CCI_Applied_Price,
::Oscillator_Overlay_Indi_CCI_Shift);
_indi_params.SetDataSourceType(Oscillator_Overlay_Indi_CCI_SourceType);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_CCI(_indi_params), _index);
SetIndicator(new Indi_CCI(_indi_params, ::Oscillator_Overlay_Indi_CCI_SourceType), _index);
break;
}
case STG_OSCILLATOR_OVERLAY_TYPE_CHO: // Chaikin (CHO)
{
IndiCHOParams _indi_params(::Oscillator_Overlay_Indi_CHO_InpFastMA, ::Oscillator_Overlay_Indi_CHO_InpSlowMA,
::Oscillator_Overlay_Indi_CHO_InpSmoothMethod,
::Oscillator_Overlay_Indi_CHO_InpVolumeType, ::Oscillator_Overlay_Indi_CHO_Shift);
_indi_params.SetDataSourceType(::Oscillator_Overlay_Indi_CHO_SourceType);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_CHO(_indi_params), _index);
SetIndicator(new Indi_CHO(_indi_params, ::Oscillator_Overlay_Indi_CHO_SourceType), _index);
break;
}
case STG_OSCILLATOR_OVERLAY_TYPE_CHV: // Chaikin Volatility (CHV)
{
IndiCHVParams _indi_params(::Oscillator_Overlay_Indi_CHV_Smooth_Period, ::Oscillator_Overlay_Indi_CHV_Period,
::Oscillator_Overlay_Indi_CHV_Smooth_Method, ::Oscillator_Overlay_Indi_CHV_Shift);
_indi_params.SetDataSourceType(::Oscillator_Overlay_Indi_CHV_SourceType);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_CHV(_indi_params), _index);
SetIndicator(new Indi_CHV(_indi_params, ::Oscillator_Overlay_Indi_CHV_SourceType), _index);
break;
}
case STG_OSCILLATOR_OVERLAY_TYPE_DEMARKER: // DeMarker
{
IndiDeMarkerParams _indi_params(::Oscillator_Overlay_Indi_DeMarker_Period,
::Oscillator_Overlay_Indi_DeMarker_Shift);
_indi_params.SetDataSourceType(Oscillator_Overlay_Indi_DeMarker_SourceType);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_DeMarker(_indi_params), _index);
SetIndicator(new Indi_DeMarker(_indi_params, ::Oscillator_Overlay_Indi_DeMarker_SourceType), _index);
break;
}
case STG_OSCILLATOR_OVERLAY_TYPE_MFI: // MFI
{
IndiMFIParams _indi_params(::Oscillator_Overlay_Indi_MFI_MA_Period,
::Oscillator_Overlay_Indi_MFI_Applied_Volume, ::Oscillator_Overlay_Indi_MFI_Shift);
_indi_params.SetDataSourceType(::Oscillator_Overlay_Indi_MFI_SourceType);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_MFI(_indi_params), _index);
SetIndicator(new Indi_MFI(_indi_params, ::Oscillator_Overlay_Indi_MFI_SourceType), _index);
break;
}
case STG_OSCILLATOR_OVERLAY_TYPE_MOM: // MOM
{
IndiMomentumParams _indi_params(::Oscillator_Overlay_Indi_Momentum_Period,
::Oscillator_Overlay_Indi_Momentum_Applied_Price,
::Oscillator_Overlay_Indi_Momentum_Shift);
_indi_params.SetDataSourceType(::Oscillator_Overlay_Indi_Momentum_SourceType);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_Momentum(_indi_params), _index);
SetIndicator(new Indi_Momentum(_indi_params, ::Oscillator_Overlay_Indi_Momentum_SourceType), _index);
break;
}
case STG_OSCILLATOR_OVERLAY_TYPE_OBV: // OBV
{
IndiOBVParams _indi_params(::Oscillator_Overlay_Indi_OBV_Applied_Price, ::Oscillator_Overlay_Indi_OBV_Shift);
_indi_params.SetDataSourceType(::Oscillator_Overlay_Indi_OBV_SourceType);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_OBV(_indi_params), _index);
SetIndicator(new Indi_OBV(_indi_params, ::Oscillator_Overlay_Indi_OBV_SourceType), _index);
break;
}
case STG_OSCILLATOR_OVERLAY_TYPE_PVT: // PVT
{
IndiPriceVolumeTrendParams _indi_params(::Oscillator_Overlay_Indi_PVT_InpVolumeType,
::Oscillator_Overlay_Indi_PVT_Shift);
_indi_params.SetDataSourceType(::Oscillator_Overlay_Indi_PVT_SourceType);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_PriceVolumeTrend(_indi_params), _index);
SetIndicator(new Indi_PriceVolumeTrend(_indi_params, ::Oscillator_Overlay_Indi_PVT_SourceType), _index);
break;
}
case STG_OSCILLATOR_OVERLAY_TYPE_ROC: // ROC
{
IndiRateOfChangeParams _indi_params(::Oscillator_Overlay_Indi_ROC_Period,
::Oscillator_Overlay_Indi_ROC_Applied_Price,
::Oscillator_Overlay_Indi_ROC_Shift);
_indi_params.SetDataSourceType(::Oscillator_Overlay_Indi_ROC_SourceType);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_RateOfChange(_indi_params), _index);
SetIndicator(new Indi_RateOfChange(_indi_params, ::Oscillator_Overlay_Indi_ROC_SourceType), _index);
break;
}
case STG_OSCILLATOR_OVERLAY_TYPE_RSI: // RSI
{
IndiRSIParams _indi_params(::Oscillator_Overlay_Indi_RSI_Period, ::Oscillator_Overlay_Indi_RSI_Applied_Price,
::Oscillator_Overlay_Indi_RSI_Shift);
_indi_params.SetDataSourceType(::Oscillator_Overlay_Indi_RSI_SourceType);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_RSI(_indi_params), _index);
SetIndicator(new Indi_RSI(_indi_params, ::Oscillator_Overlay_Indi_RSI_SourceType), _index);
break;
}
case STG_OSCILLATOR_OVERLAY_TYPE_STDDEV: // StdDev
Expand All @@ -493,9 +475,8 @@ class Stg_Oscillator_Overlay : public Strategy {
::Oscillator_Overlay_Indi_StdDev_MA_Period, ::Oscillator_Overlay_Indi_StdDev_MA_Shift,
::Oscillator_Overlay_Indi_StdDev_MA_Method, ::Oscillator_Overlay_Indi_StdDev_Applied_Price,
::Oscillator_Overlay_Indi_StdDev_Shift);
_indi_params.SetDataSourceType(::Oscillator_Overlay_Indi_StdDev_SourceType);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_StdDev(_indi_params), _index);
SetIndicator(new Indi_StdDev(_indi_params, ::Oscillator_Overlay_Indi_StdDev_SourceType), _index);
break;
}
case STG_OSCILLATOR_OVERLAY_TYPE_STOCH: // Stochastic
Expand All @@ -504,18 +485,16 @@ class Stg_Oscillator_Overlay : public Strategy {
::Oscillator_Overlay_Indi_Stochastic_KPeriod, ::Oscillator_Overlay_Indi_Stochastic_DPeriod,
::Oscillator_Overlay_Indi_Stochastic_Slowing, ::Oscillator_Overlay_Indi_Stochastic_MA_Method,
::Oscillator_Overlay_Indi_Stochastic_Price_Field, ::Oscillator_Overlay_Indi_Stochastic_Shift);
_indi_params.SetDataSourceType(::Oscillator_Overlay_Indi_Stochastic_SourceType);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_Stochastic(_indi_params), _index);
SetIndicator(new Indi_Stochastic(_indi_params, ::Oscillator_Overlay_Indi_Stochastic_SourceType), _index);
break;
}
case STG_OSCILLATOR_OVERLAY_TYPE_TRIX: // TRIX
{
IndiTRIXParams _indi_params(::Oscillator_Overlay_Indi_TRIX_InpPeriodEMA,
::Oscillator_Overlay_Indi_TRIX_Applied_Price, ::Oscillator_Overlay_Indi_TRIX_Shift);
_indi_params.SetDataSourceType(::Oscillator_Overlay_Indi_TRIX_SourceType);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_TRIX(_indi_params), _index);
SetIndicator(new Indi_TRIX(_indi_params, ::Oscillator_Overlay_Indi_TRIX_SourceType), _index);
break;
}
case STG_OSCILLATOR_OVERLAY_TYPE_UO: // UO
Expand All @@ -525,34 +504,30 @@ class Stg_Oscillator_Overlay : public Strategy {
::Oscillator_Overlay_Indi_UO_InpSlowPeriod, ::Oscillator_Overlay_Indi_UO_InpFastK,
::Oscillator_Overlay_Indi_UO_InpMiddleK, ::Oscillator_Overlay_Indi_UO_InpSlowK,
::Oscillator_Overlay_Indi_UO_Shift);
_indi_params.SetDataSourceType(::Oscillator_Overlay_Indi_UO_SourceType);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_UltimateOscillator(_indi_params), _index);
SetIndicator(new Indi_UltimateOscillator(_indi_params, ::Oscillator_Overlay_Indi_UO_SourceType), _index);
break;
}
case STG_OSCILLATOR_OVERLAY_TYPE_WAD: // Williams' AD
{
IndiWilliamsADParams _indi_params(::Oscillator_Overlay_Indi_WAD_Shift);
_indi_params.SetDataSourceType(Oscillator_Overlay_Indi_WAD_SourceType);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_WilliamsAD(_indi_params), _index);
SetIndicator(new Indi_WilliamsAD(_indi_params, ::Oscillator_Overlay_Indi_WAD_SourceType), _index);
break;
}
case STG_OSCILLATOR_OVERLAY_TYPE_WPR: // WPR
{
IndiWPRParams _indi_params(::Oscillator_Overlay_Indi_WPR_Period, ::Oscillator_Overlay_Indi_WPR_Shift);
_indi_params.SetDataSourceType(::Oscillator_Overlay_Indi_WPR_SourceType);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_WPR(_indi_params), _index);
SetIndicator(new Indi_WPR(_indi_params, ::Oscillator_Overlay_Indi_WPR_SourceType), _index);
break;
}
case STG_OSCILLATOR_OVERLAY_TYPE_VOL: // Volumes
{
IndiVolumesParams _indi_params(::Oscillator_Overlay_Indi_VOL_InpVolumeType,
::Oscillator_Overlay_Indi_VOL_Shift);
_indi_params.SetDataSourceType(::Oscillator_Overlay_Indi_VOL_SourceType);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_Volumes(_indi_params), _index);
SetIndicator(new Indi_Volumes(_indi_params, ::Oscillator_Overlay_Indi_VOL_SourceType), _index);
break;
}
case STG_OSCILLATOR_OVERLAY_TYPE_0_NONE: // (None)
Expand All @@ -565,7 +540,7 @@ class Stg_Oscillator_Overlay : 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_Overlay_Type_Base + 1);
IndicatorData *_indi = GetIndicator(::Oscillator_Overlay_Type_Data + 1);
// uint _ishift = _indi.GetShift();
bool _result =
::Oscillator_Overlay_Type_Overlayed != STG_OSCILLATOR_OVERLAY_TYPE_0_NONE && IsValidEntry(_indi, _shift);
Expand Down

0 comments on commit 0857f42

Please sign in to comment.