Skip to content

Commit

Permalink
Merge remote-tracking branch 'nseam/dev-indis-wip' into dev-indis-tests
Browse files Browse the repository at this point in the history
* nseam/dev-indis-wip:
  Indicators' constructors and Indicators Params' constructors refactoring.
  • Loading branch information
kenorb committed Sep 27, 2021
2 parents dfdc1e8 + 9a46c20 commit e3cf937
Show file tree
Hide file tree
Showing 66 changed files with 401 additions and 892 deletions.
1 change: 1 addition & 0 deletions Indicators/Bitwise/Indi_Candle.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ struct CandleParams : IndicatorParams {
max_modes = 1;
SetDataValueType(TYPE_INT);
SetDataValueRange(IDATA_RANGE_RANGE);
SetDataSourceType(IDATA_BUILTIN);
shift = _shift;
tf = _tf;
};
Expand Down
15 changes: 6 additions & 9 deletions Indicators/Indi_AC.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,13 @@ double iAC(string _symbol, int _tf, int _shift) { return Indi_AC::iAC(_symbol, (
// Structs.
struct ACParams : IndicatorParams {
// Struct constructor.
void ACParams(int _shift = 0, ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) {
void ACParams(int _shift = 0) {
itype = INDI_AC;
max_modes = 1;
SetDataValueType(TYPE_DOUBLE);
SetDataValueRange(IDATA_RANGE_MIXED);
SetCustomIndicatorName("Examples\\Accelerator");
shift = _shift;
tf = _tf;
};
void ACParams(ACParams &_params, ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) {
this = _params;
tf = _tf;
};
};

Expand All @@ -58,8 +53,10 @@ class Indi_AC : public Indicator {
/**
* Class constructor.
*/
Indi_AC(ACParams &_params) : Indicator((IndicatorParams)_params) { params = _params; };
Indi_AC(ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) : Indicator(INDI_AC, _tf) { params.SetTf(_tf); };
Indi_AC(ACParams &_params, ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) : Indicator((IndicatorParams)_params, _tf) {
params = _params;
}
Indi_AC(ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) : Indicator(INDI_AC, _tf){};

/**
* Returns the indicator value.
Expand Down Expand Up @@ -111,7 +108,7 @@ class Indi_AC : public Indicator {
switch (params.idstype) {
case IDATA_BUILTIN:
istate.handle = istate.is_changed ? INVALID_HANDLE : istate.handle;
_value = Indi_AC::iAC(GetSymbol(), GetTf(), _shift, GetPointer(this));
_value = Indi_AC::iAC(GetSymbol(), GetTf(), _shift, THIS_PTR);
break;
case IDATA_ICUSTOM:
_value = iCustom(istate.handle, GetSymbol(), GetTf(), params.GetCustomIndicatorName(), _mode, _shift);
Expand Down
17 changes: 5 additions & 12 deletions Indicators/Indi_AD.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,13 @@ double iAD(string _symbol, int _tf, int _shift) { return Indi_AD::iAD(_symbol, (
// Structs.
struct ADParams : IndicatorParams {
// Struct constructor.
ADParams(int _shift = 0, ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) {
ADParams(int _shift = 0) {
itype = INDI_AD;
max_modes = 1;
SetDataValueType(TYPE_DOUBLE);
SetDataValueRange(IDATA_RANGE_MIXED);
SetCustomIndicatorName("Examples\\AD");
shift = _shift;
tf = _tf;
};
ADParams(ADParams &_params, ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) {
this = _params;
tf = _tf;
};
};

Expand All @@ -57,8 +52,8 @@ class Indi_AD : public Indicator {
/**
* Class constructor.
*/
Indi_AD(ADParams &_p) : Indicator((IndicatorParams)_p) { params = _p; };
Indi_AD(ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) : Indicator(INDI_AD, _tf) { params.SetTf(_tf); };
Indi_AD(ADParams &_p, ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) : Indicator((IndicatorParams)_p, _tf) { params = _p; };
Indi_AD(ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) : Indicator(INDI_AD, _tf){};

/**
* Returns the indicator value.
Expand Down Expand Up @@ -110,12 +105,10 @@ class Indi_AD : public Indicator {
switch (params.idstype) {
case IDATA_BUILTIN:
istate.handle = istate.is_changed ? INVALID_HANDLE : istate.handle;
_value = Indi_AD::iAD(Get<string>(CHART_PARAM_SYMBOL), Get<ENUM_TIMEFRAMES>(CHART_PARAM_TF), _shift,
GetPointer(this));
_value = Indi_AD::iAD(GetSymbol(), GetTf(), _shift, THIS_PTR);
break;
case IDATA_ICUSTOM:
_value = iCustom(istate.handle, Get<string>(CHART_PARAM_SYMBOL), Get<ENUM_TIMEFRAMES>(CHART_PARAM_TF),
params.GetCustomIndicatorName(), _mode, _shift);
_value = iCustom(istate.handle, GetSymbol(), GetTf(), params.GetCustomIndicatorName(), _mode, _shift);
break;
default:
SetUserError(ERR_INVALID_PARAMETER);
Expand Down
25 changes: 4 additions & 21 deletions Indicators/Indi_ADX.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,6 @@ struct ADXParams : IndicatorParams {
SetDataValueRange(IDATA_RANGE_RANGE);
SetMaxModes(FINAL_INDI_ADX_LINE_ENTRY);
SetShift(_shift);
switch (idstype) {
case IDATA_ICUSTOM:
if (custom_indi_name == "") {
SetCustomIndicatorName("Examples\\ADX");
}
break;
case IDATA_INDICATOR:
if (indi_data_source == NULL) {
SetDataSource(Indi_Price::GetCached(_shift, _tf, applied_price, _period));
}
break;
}
};
void ADXParams(ADXParams &_params, ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) {
this = _params;
tf = _tf;
};
};

Expand All @@ -76,7 +60,7 @@ class Indi_ADX : public Indicator {
/**
* Class constructor.
*/
Indi_ADX(ADXParams &_p) : params(_p.period, _p.applied_price), Indicator((IndicatorParams)_p) { params = _p; }
Indi_ADX(ADXParams &_p, ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) : Indicator((IndicatorParams)_p, _tf) { params = _p; }
Indi_ADX(ENUM_TIMEFRAMES _tf) : Indicator(INDI_ADX, _tf) {}

/**
Expand Down Expand Up @@ -132,12 +116,11 @@ class Indi_ADX : public Indicator {
switch (params.idstype) {
case IDATA_BUILTIN:
istate.handle = istate.is_changed ? INVALID_HANDLE : istate.handle;
_value = Indi_ADX::iADX(Get<string>(CHART_PARAM_SYMBOL), Get<ENUM_TIMEFRAMES>(CHART_PARAM_TF), GetPeriod(),
GetAppliedPrice(), _mode, _shift, GetPointer(this));
_value = Indi_ADX::iADX(GetSymbol(), GetTf(), GetPeriod(), GetAppliedPrice(), _mode, _shift, THIS_PTR);
break;
case IDATA_ICUSTOM:
_value = iCustom(istate.handle, Get<string>(CHART_PARAM_SYMBOL), Get<ENUM_TIMEFRAMES>(CHART_PARAM_TF),
params.GetCustomIndicatorName(), /*[*/ GetPeriod() /*]*/, _mode, _shift);
_value = iCustom(istate.handle, GetSymbol(), GetTf(), params.GetCustomIndicatorName(), /*[*/ GetPeriod() /*]*/,
_mode, _shift);
break;
default:
SetUserError(ERR_INVALID_PARAMETER);
Expand Down
10 changes: 6 additions & 4 deletions Indicators/Indi_ADXW.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ struct ADXWParams : ADXParams {
break;
}
};
void ADXWParams(ADXWParams &_params, ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) : ADXParams(_params, _tf) {}
void ADXWParams(ADXParams &_params, ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) : ADXParams(_params, _tf) {}
void ADXWParams(ADXWParams &_params) { THIS_REF = _params; }
void ADXWParams(ADXParams &_params) { THIS_REF = _params; }
};

/**
Expand All @@ -61,8 +61,10 @@ class Indi_ADXW : public Indicator {
/**
* Class constructor.
*/
Indi_ADXW(ADXWParams &_params) : params(_params.period), Indicator((IndicatorParams)_params) { params = _params; };
Indi_ADXW(ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) : Indicator(INDI_ADXW, _tf) { params.tf = _tf; };
Indi_ADXW(ADXWParams &_params, ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) : Indicator((IndicatorParams)_params, _tf) {
params = _params;
};
Indi_ADXW(ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) : Indicator(INDI_ADXW, _tf){};

/**
* Built-in version of ADX Wilder.
Expand Down
32 changes: 8 additions & 24 deletions Indicators/Indi_AMA.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -36,37 +36,18 @@ struct IndiAMAParams : IndicatorParams {
ENUM_APPLIED_PRICE applied_price;
// Struct constructor.
void IndiAMAParams(int _period = 10, int _fast_period = 2, int _slow_period = 30, int _ama_shift = 0,
ENUM_APPLIED_PRICE _ap = PRICE_TYPICAL, int _shift = 0, ENUM_TIMEFRAMES _tf = PERIOD_CURRENT,
ENUM_IDATA_SOURCE_TYPE _idstype = IDATA_BUILTIN)
ENUM_APPLIED_PRICE _ap = PRICE_TYPICAL, int _shift = 0)
: period(_period),
fast_period(_fast_period),
slow_period(_slow_period),
ama_shift(_ama_shift),
applied_price(_ap) {
itype = itype == INDI_NONE ? INDI_AMA : itype;
SetDataSourceType(_idstype);
itype = INDI_AMA;
SetDataValueType(TYPE_DOUBLE);
SetDataValueRange(IDATA_RANGE_PRICE);
SetMaxModes(1);
SetShift(_shift);
tf = _tf;
switch (idstype) {
case IDATA_ICUSTOM:
if (custom_indi_name == "") {
SetCustomIndicatorName("Examples\\AMA");
}
break;
case IDATA_INDICATOR:
if (GetDataSource() == NULL) {
SetDataSource(Indi_Price::GetCached(_shift, _tf, _ap, _period), false);
SetDataSourceMode(0);
}
break;
}
};
void IndiAMAParams(IndiAMAParams &_params, ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) {
this = _params;
tf = _tf;
SetCustomIndicatorName("Examples\\AMA");
};
};

Expand All @@ -81,8 +62,11 @@ class Indi_AMA : public Indicator {
/**
* Class constructor.
*/
Indi_AMA(IndiAMAParams &_params) : params(_params.period), Indicator((IndicatorParams)_params) { params = _params; };
Indi_AMA(ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) : Indicator(INDI_AMA, _tf) { params.tf = _tf; };
Indi_AMA(IndiAMAParams &_params, ENUM_TIMEFRAMES _tf = PERIOD_CURRENT)
: params(_params.period, _tf), Indicator((IndicatorParams)_params) {
params = _params;
};
Indi_AMA(ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) : Indicator(INDI_AMA, _tf){};

/**
* Built-in version of AMA.
Expand Down
17 changes: 5 additions & 12 deletions Indicators/Indi_AO.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ double iAO(string _symbol, int _tf, int _shift) { return Indi_AO::iAO(_symbol, (
// Structs.
struct AOParams : IndicatorParams {
// Struct constructor.
void AOParams(int _shift = 0, ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) {
void AOParams(int _shift = 0) {
itype = INDI_AO;
#ifdef __MQL4__
max_modes = 1;
Expand All @@ -42,11 +42,6 @@ struct AOParams : IndicatorParams {
SetDataValueRange(IDATA_RANGE_MIXED);
SetCustomIndicatorName("Examples\\Awesome_Oscillator");
shift = _shift;
tf = _tf;
};
void AOParams(AOParams &_params, ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) {
this = _params;
tf = _tf;
};
};

Expand All @@ -61,8 +56,8 @@ class Indi_AO : public Indicator {
/**
* Class constructor.
*/
Indi_AO(AOParams &_p) : Indicator((IndicatorParams)_p) { params = _p; };
Indi_AO(ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) : params(_tf), Indicator(INDI_AO, _tf){};
Indi_AO(AOParams &_p, ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) : Indicator((IndicatorParams)_p, _tf) { params = _p; };
Indi_AO(ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) : Indicator(INDI_AO, _tf){};

/**
* Returns the indicator value.
Expand Down Expand Up @@ -115,12 +110,10 @@ class Indi_AO : public Indicator {
switch (params.idstype) {
case IDATA_BUILTIN:
istate.handle = istate.is_changed ? INVALID_HANDLE : istate.handle;
_value = Indi_AO::iAO(Get<string>(CHART_PARAM_SYMBOL), Get<ENUM_TIMEFRAMES>(CHART_PARAM_TF), _shift, _mode,
GetPointer(this));
_value = Indi_AO::iAO(GetSymbol(), GetTf(), _shift, _mode, THIS_PTR);
break;
case IDATA_ICUSTOM:
_value = iCustom(istate.handle, Get<string>(CHART_PARAM_SYMBOL), Get<ENUM_TIMEFRAMES>(CHART_PARAM_TF),
params.GetCustomIndicatorName(), _mode, _shift);
_value = iCustom(istate.handle, GetSymbol(), GetTf(), params.GetCustomIndicatorName(), _mode, _shift);
break;
default:
SetUserError(ERR_INVALID_PARAMETER);
Expand Down
14 changes: 5 additions & 9 deletions Indicators/Indi_ASI.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,14 @@ struct ASIParams : IndicatorParams {
unsigned int period;
double mpc;
// Struct constructor.
void ASIParams(double _mpc = 300.0, int _shift = 0, ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) {
void ASIParams(double _mpc = 300.0, int _shift = 0) {
itype = INDI_ASI;
max_modes = 1;
SetDataValueType(TYPE_DOUBLE);
SetDataValueRange(IDATA_RANGE_MIXED);
SetCustomIndicatorName("Examples\\ASI");
SetDataSourceType(IDATA_BUILTIN);
mpc = _mpc;
shift = _shift;
tf = _tf;
};
void ASIParams(ASIParams &_params, ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) {
this = _params;
tf = _tf;
};
};

Expand All @@ -58,8 +52,10 @@ class Indi_ASI : public Indicator {
/**
* Class constructor.
*/
Indi_ASI(ASIParams &_params) : params(_params.mpc), Indicator((IndicatorParams)_params) { params = _params; };
Indi_ASI(ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) : Indicator(INDI_ASI, _tf) { params.tf = _tf; };
Indi_ASI(ASIParams &_params, ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) : Indicator((IndicatorParams)_params, _tf) {
params = _params;
};
Indi_ASI(ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) : Indicator(INDI_ASI, _tf){};

/**
* Built-in version of ASI.
Expand Down
14 changes: 4 additions & 10 deletions Indicators/Indi_ATR.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,13 @@ double iATR(string _symbol, int _tf, int _period, int _shift) {
struct ATRParams : IndicatorParams {
unsigned int period;
// Struct constructors.
void ATRParams(unsigned int _period = 14, int _shift = 0, ENUM_TIMEFRAMES _tf = PERIOD_CURRENT, string _symbol = NULL)
: period(_period) {
void ATRParams(unsigned int _period = 14, int _shift = 0) : period(_period) {
itype = INDI_ATR;
max_modes = 1;
shift = _shift;
SetDataValueType(TYPE_DOUBLE);
SetDataValueRange(IDATA_RANGE_MIXED);
SetCustomIndicatorName("Examples\\ATR");
tf = _tf;
};
void ATRParams(ATRParams &_params, ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) {
this = _params;
tf = _tf;
};
};

Expand All @@ -62,8 +56,8 @@ class Indi_ATR : public Indicator {
/**
* Class constructor.
*/
Indi_ATR(ATRParams &_p) : params(_p.period), Indicator((IndicatorParams)_p) { params = _p; }
Indi_ATR(ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) : Indicator(INDI_ATR, _tf) { params.SetTf(_tf); };
Indi_ATR(ATRParams &_p, ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) : Indicator((IndicatorParams)_p, _tf) { params = _p; }
Indi_ATR(ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) : Indicator(INDI_ATR, _tf){};

/**
* Returns the indicator value.
Expand Down Expand Up @@ -115,7 +109,7 @@ class Indi_ATR : public Indicator {
switch (params.idstype) {
case IDATA_BUILTIN:
istate.handle = istate.is_changed ? INVALID_HANDLE : istate.handle;
_value = Indi_ATR::iATR(GetSymbol(), GetTf(), GetPeriod(), _shift, GetPointer(this));
_value = Indi_ATR::iATR(GetSymbol(), GetTf(), GetPeriod(), _shift, THIS_PTR);
break;
case IDATA_ICUSTOM:
_value = iCustom(istate.handle, GetSymbol(), GetTf(), params.GetCustomIndicatorName(), _mode, _shift);
Expand Down
20 changes: 7 additions & 13 deletions Indicators/Indi_Alligator.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,8 @@ struct AlligatorParams : IndicatorParams {
shift = _shift;
SetDataValueType(TYPE_DOUBLE);
SetDataValueRange(IDATA_RANGE_PRICE);
SetDataSourceType(IDATA_BUILTIN);
SetCustomIndicatorName("Examples\\Alligator");
};
void AlligatorParams(AlligatorParams &_params, ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) {
this = _params;
tf = _tf;
};
};

/**
Expand All @@ -104,8 +99,9 @@ class Indi_Alligator : public Indicator {
/**
* Class constructor.
*/
Indi_Alligator(AlligatorParams &_p) : Indicator((IndicatorParams)_p) { params = _p; }
Indi_Alligator(AlligatorParams &_p, ENUM_TIMEFRAMES _tf) : Indicator(INDI_ALLIGATOR, _tf) { params = _p; }
Indi_Alligator(AlligatorParams &_p, ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) : Indicator((IndicatorParams)_p, _tf) {
params = _p;
}
Indi_Alligator(ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) : Indicator(INDI_ADX, _tf){};

/**
Expand Down Expand Up @@ -179,14 +175,12 @@ class Indi_Alligator : public Indicator {
switch (params.idstype) {
case IDATA_BUILTIN:
istate.handle = istate.is_changed ? INVALID_HANDLE : istate.handle;
_value = Indi_Alligator::iAlligator(Get<string>(CHART_PARAM_SYMBOL), Get<ENUM_TIMEFRAMES>(CHART_PARAM_TF),
GetJawPeriod(), GetJawShift(), GetTeethPeriod(), GetTeethShift(),
GetLipsPeriod(), GetLipsShift(), GetMAMethod(), GetAppliedPrice(), _mode,
_shift, GetPointer(this));
_value = Indi_Alligator::iAlligator(GetSymbol(), GetTf(), GetJawPeriod(), GetJawShift(), GetTeethPeriod(),
GetTeethShift(), GetLipsPeriod(), GetLipsShift(), GetMAMethod(),
GetAppliedPrice(), _mode, _shift, THIS_PTR);
break;
case IDATA_ICUSTOM:
_value = iCustom(istate.handle, Get<string>(CHART_PARAM_SYMBOL), Get<ENUM_TIMEFRAMES>(CHART_PARAM_TF),
params.GetCustomIndicatorName(), /*[*/
_value = iCustom(istate.handle, GetSymbol(), GetTf(), params.GetCustomIndicatorName(), /*[*/
GetJawPeriod(), GetJawShift(), GetTeethPeriod(), GetTeethShift(), GetLipsPeriod(),
GetLipsShift(), GetMAMethod(),
GetAppliedPrice()
Expand Down
Loading

0 comments on commit e3cf937

Please sign in to comment.