Skip to content

Commit

Permalink
Adds OsMA
Browse files Browse the repository at this point in the history
  • Loading branch information
kenorb committed Aug 28, 2023
1 parent 36164d3 commit 2bc1d47
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions Stg_Oscillator_Multi.mq5
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <EA31337-classes/Indicators/Indi_ADXW.mqh>
#include <EA31337-classes/Indicators/Indi_Gator.mqh>
#include <EA31337-classes/Indicators/Indi_MACD.mqh>
#include <EA31337-classes/Indicators/Indi_OsMA.mqh>
#include <EA31337-classes/Indicators/Indi_RVI.mqh>
// #include <EA31337-classes/Indicators/Oscillator_Multi/includes.h>
#include <EA31337-classes/Strategy.mqh>
Expand Down
25 changes: 25 additions & 0 deletions Stg_Oscillator_Multi.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ enum ENUM_STG_OSCILLATOR_MULTI_TYPE {
STG_OSCILLATOR_MULTI_TYPE_ADXW, // ADXW
STG_OSCILLATOR_MULTI_TYPE_GATOR, // Gator
STG_OSCILLATOR_MULTI_TYPE_MACD, // MACD
STG_OSCILLATOR_MULTI_TYPE_OSMA, // OsMA: Moving Average of Oscillator (aka MACD histogram)
STG_OSCILLATOR_MULTI_TYPE_RVI, // RVI: Relative Vigor Index
};

Expand Down Expand Up @@ -61,6 +62,13 @@ INPUT int Oscillator_Indi_MACD_Period_Slow = 34; // Pe
INPUT int Oscillator_Indi_MACD_Period_Signal = 10; // Period Signal
INPUT ENUM_APPLIED_PRICE Oscillator_Indi_MACD_Applied_Price = PRICE_OPEN; // Applied Price
INPUT int Oscillator_Indi_MACD_Shift = 0; // Shift
INPUT_GROUP("Oscillator strategy: OsMA indicator params");
INPUT int Oscillator_Indi_OsMA_Period_Fast = 14; // Period fast
INPUT int Oscillator_Indi_OsMA_Period_Slow = 30; // Period slow
INPUT int Oscillator_Indi_OsMA_Period_Signal = 12; // Period signal
INPUT ENUM_APPLIED_PRICE Oscillator_Indi_OsMA_Applied_Price = PRICE_OPEN; // Applied price
INPUT int Oscillator_Indi_OsMA_Shift = 0; // Shift
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Multi_Indi_OsMA_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator strategy: RVI indicator params");
INPUT unsigned int Oscillator_Indi_RVI_Period = 12; // Averaging period
INPUT int Oscillator_Indi_RVI_Shift = 0; // Shift
Expand Down Expand Up @@ -119,6 +127,9 @@ class Stg_Oscillator_Multi : public Strategy {
case STG_OSCILLATOR_MULTI_TYPE_MACD:
_result = dynamic_cast<Indi_MACD *>(_indi).GetParams().GetMaxModes();
break;
case STG_OSCILLATOR_MULTI_TYPE_OSMA:
_result = dynamic_cast<Indi_OsMA *>(_indi).GetParams().GetMaxModes();
break;
case STG_OSCILLATOR_MULTI_TYPE_RVI:
_result = dynamic_cast<Indi_RVI *>(_indi).GetParams().GetMaxModes();
break;
Expand Down Expand Up @@ -150,6 +161,10 @@ class Stg_Oscillator_Multi : public Strategy {
_result &= dynamic_cast<Indi_MACD *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift) &&
dynamic_cast<Indi_MACD *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift + 1);
break;
case STG_OSCILLATOR_MULTI_TYPE_OSMA:
_result &= dynamic_cast<Indi_OsMA *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift) &&
dynamic_cast<Indi_OsMA *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift + 1);
break;
case STG_OSCILLATOR_MULTI_TYPE_RVI:
_result &= dynamic_cast<Indi_RVI *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift) &&
dynamic_cast<Indi_RVI *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift + 1);
Expand Down Expand Up @@ -204,6 +219,16 @@ class Stg_Oscillator_Multi : public Strategy {
SetIndicator(new Indi_MACD(_indi_params), ::Oscillator_Multi_Type);
break;
}
case STG_OSCILLATOR_MULTI_TYPE_OSMA: // OsMA
{
IndiOsMAParams _indi_params(::Oscillator_Indi_OsMA_Period_Fast, ::Oscillator_Indi_OsMA_Period_Slow,
::Oscillator_Indi_OsMA_Period_Signal, ::Oscillator_Indi_OsMA_Applied_Price,
::Oscillator_Indi_OsMA_Shift);
_indi_params.SetDataSourceType(::Oscillator_Multi_Indi_OsMA_SourceType);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_OsMA(_indi_params), ::Oscillator_Multi_Type);
break;
}
case STG_OSCILLATOR_MULTI_TYPE_RVI: // RVI
{
IndiRVIParams _indi_params(::Oscillator_Indi_RVI_Period, ::Oscillator_Indi_RVI_Shift);
Expand Down

0 comments on commit 2bc1d47

Please sign in to comment.