Skip to content

Commit

Permalink
Adds Awesome
Browse files Browse the repository at this point in the history
  • Loading branch information
kenorb committed Aug 28, 2023
1 parent 2ccd6ea commit af0c059
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
4 changes: 3 additions & 1 deletion Stg_Oscillator.mq5
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <EA31337-classes/EA.mqh>
#include <EA31337-classes/Indicators/Indi_AC.mqh>
#include <EA31337-classes/Indicators/Indi_AD.mqh>
#include <EA31337-classes/Indicators/Indi_ADX.mqh>
#include <EA31337-classes/Indicators/Indi_AO.mqh>
#include <EA31337-classes/Indicators/Indi_CCI.mqh>
#include <EA31337-classes/Indicators/Indi_RSI.mqh>
#include <EA31337-classes/Indicators/Indi_Stochastic.mqh>
Expand All @@ -29,7 +31,7 @@ input bool Info_On_Chart = true; // Display info on chart.
// Defines.
#define ea_name "Strategy Oscillator"
#define ea_version "2.000"
#define ea_desc "Strategy based on selected oscillator-type single-valued indicators."
#define ea_desc "Strategy based on selected oscillator-type multi-valued indicators."
#define ea_link "https://github.com/EA31337/Strategy-Oscillator"
#define ea_author "EA31337 Ltd"

Expand Down
27 changes: 21 additions & 6 deletions Stg_Oscillator.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ enum ENUM_STG_OSCILLATOR_TYPE {
STG_OSCILLATOR_TYPE_0_NONE = 0, // (None)
STG_OSCILLATOR_TYPE_AC, // AC
STG_OSCILLATOR_TYPE_AD, // AD
STG_OSCILLATOR_TYPE_AO, // Awesome
STG_OSCILLATOR_TYPE_CCI, // CCI
STG_OSCILLATOR_TYPE_RSI, // RSI
STG_OSCILLATOR_TYPE_STOCH, // Stochastic
Expand Down Expand Up @@ -40,22 +41,24 @@ INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Indi_AC_SourceType = IDATA_BUILTIN; //
INPUT_GROUP("Oscillator strategy: AD oscillator params");
INPUT int Oscillator_Indi_AD_Shift = 0; // Shift
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Indi_AD_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator strategy: CCI indicator params");
INPUT_GROUP("Oscillator strategy: Awesome oscillator params");
INPUT int Oscillator_Indi_Awesome_Shift = 0; // Shift
INPUT_GROUP("Oscillator strategy: CCI oscillator params");
INPUT int Oscillator_Indi_CCI_Period = 20; // Period
INPUT ENUM_APPLIED_PRICE Oscillator_Indi_CCI_Applied_Price = PRICE_TYPICAL; // Applied Price
INPUT int Oscillator_Indi_CCI_Shift = 0; // Shift
INPUT_GROUP("Oscillator strategy: RSI indicator params");
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
INPUT int Oscillator_Indi_RSI_Shift = 0; // Shift
INPUT_GROUP("Oscillator strategy: Stochastic indicator params");
INPUT_GROUP("Oscillator strategy: Stochastic oscillator params");
INPUT int Oscillator_Indi_Stochastic_KPeriod = 8; // K line period
INPUT int Oscillator_Indi_Stochastic_DPeriod = 12; // D line period
INPUT int Oscillator_Indi_Stochastic_Slowing = 12; // Slowing
INPUT ENUM_MA_METHOD Oscillator_Indi_Stochastic_MA_Method = MODE_EMA; // Moving Average method
INPUT ENUM_STO_PRICE Oscillator_Indi_Stochastic_Price_Field = 0; // Price (0 - Low/High or 1 - Close/Close)
INPUT int Oscillator_Indi_Stochastic_Shift = 0; // Shift
INPUT_GROUP("Oscillator strategy: WPR indicator params");
INPUT_GROUP("Oscillator strategy: WPR oscillator params");
INPUT int Oscillator_Indi_WPR_Period = 18; // Period
INPUT int Oscillator_Indi_WPR_Shift = 0; // Shift

Expand Down Expand Up @@ -106,6 +109,10 @@ class Stg_Oscillator : public Strategy {
_result &= dynamic_cast<Indi_AD *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift) &&
dynamic_cast<Indi_AD *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift + 1);
break;
case STG_OSCILLATOR_TYPE_AO:
_result &= dynamic_cast<Indi_AO *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift) &&
dynamic_cast<Indi_AO *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift + 1);
break;
case STG_OSCILLATOR_TYPE_CCI:
_result &= dynamic_cast<Indi_CCI *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift) &&
dynamic_cast<Indi_CCI *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift + 1);
Expand Down Expand Up @@ -150,11 +157,19 @@ class Stg_Oscillator : public Strategy {
SetIndicator(new Indi_AD(ad_params), ::Oscillator_Type);
break;
}
case STG_OSCILLATOR_TYPE_AO: // AO
{
IndiAOParams _indi_params(::Oscillator_Indi_Awesome_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_AO(_indi_params), ::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);
IndiCCIParams _indi_params(::Oscillator_Indi_CCI_Period, ::Oscillator_Indi_CCI_Applied_Price,
::Oscillator_Indi_CCI_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_CCI(_indi_params));
SetIndicator(new Indi_CCI(_indi_params), ::Oscillator_Type);
break;
}
case STG_OSCILLATOR_TYPE_RSI: // RSI
Expand Down

0 comments on commit af0c059

Please sign in to comment.