Skip to content

Commit

Permalink
Adds ROC
Browse files Browse the repository at this point in the history
  • Loading branch information
kenorb committed Aug 28, 2023
1 parent 8a9b746 commit fdebb39
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions Stg_Oscillator.mq5
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <EA31337-classes/Indicators/Indi_Momentum.mqh>
#include <EA31337-classes/Indicators/Indi_OBV.mqh>
#include <EA31337-classes/Indicators/Indi_PriceVolumeTrend.mqh>
#include <EA31337-classes/Indicators/Indi_RateOfChange.mqh>
#include <EA31337-classes/Indicators/Indi_RSI.mqh>
#include <EA31337-classes/Indicators/Indi_StdDev.mqh>
#include <EA31337-classes/Indicators/Indi_Stochastic.mqh>
Expand Down
18 changes: 18 additions & 0 deletions Stg_Oscillator.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ enum ENUM_STG_OSCILLATOR_TYPE {
STG_OSCILLATOR_TYPE_MOM, // MOM: Momentum
STG_OSCILLATOR_TYPE_OBV, // OBV: On Balance Volume
STG_OSCILLATOR_TYPE_PVT, // PVT: Price and Volume Trend
STG_OSCILLATOR_TYPE_ROC, // ROC: Rate of Change
STG_OSCILLATOR_TYPE_RSI, // RSI
STG_OSCILLATOR_TYPE_STDDEV, // StdDev: Standard Deviation
STG_OSCILLATOR_TYPE_STOCH, // Stochastic
Expand Down Expand Up @@ -108,6 +109,11 @@ INPUT_GROUP("Oscillator strategy: PVT oscillator params");
INPUT ENUM_APPLIED_VOLUME Oscillator_Indi_PVT_InpVolumeType = VOLUME_TICK; // Volumes
INPUT int Oscillator_Indi_PVT_Shift = 0; // Shift
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Indi_PVT_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator strategy: ROC oscillator params");
INPUT int Oscillator_Indi_ROC_Period = 16; // Period
INPUT ENUM_APPLIED_PRICE Oscillator_Indi_ROC_Applied_Price = PRICE_WEIGHTED; // Applied Price
INPUT int Oscillator_Indi_ROC_Shift = 0; // Shift
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Indi_ROC_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator strategy: RSI oscillator params");
INPUT int Oscillator_Indi_RSI_Period = 16; // Period
INPUT ENUM_APPLIED_PRICE Oscillator_Indi_RSI_Applied_Price = PRICE_WEIGHTED; // Applied Price
Expand Down Expand Up @@ -225,6 +231,10 @@ class Stg_Oscillator : public Strategy {
_result &= dynamic_cast<Indi_OBV *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift) &&
dynamic_cast<Indi_OBV *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift + 1);
break;
case STG_OSCILLATOR_TYPE_ROC:
_result &= dynamic_cast<Indi_RateOfChange *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift) &&
dynamic_cast<Indi_RateOfChange *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift + 1);
break;
case STG_OSCILLATOR_TYPE_RSI:
_result &= dynamic_cast<Indi_RSI *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift) &&
dynamic_cast<Indi_RSI *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift + 1);
Expand Down Expand Up @@ -371,6 +381,14 @@ class Stg_Oscillator : public Strategy {
SetIndicator(new Indi_PriceVolumeTrend(_indi_params), ::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<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_RateOfChange(_indi_params), ::Oscillator_Type);
break;
}
case STG_OSCILLATOR_TYPE_RSI: // RSI
{
IndiRSIParams _indi_params(::Oscillator_Indi_RSI_Period, ::Oscillator_Indi_RSI_Applied_Price,
Expand Down

0 comments on commit fdebb39

Please sign in to comment.