Skip to content

Commit

Permalink
Indicator: Renames GetMixedValue to GetEntryValue
Browse files Browse the repository at this point in the history
  • Loading branch information
kenorb committed Nov 8, 2021
1 parent 17fac68 commit 47e353f
Show file tree
Hide file tree
Showing 73 changed files with 304 additions and 239 deletions.
6 changes: 4 additions & 2 deletions Indicator.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -1002,8 +1002,9 @@ class Indicator : public IndicatorBase {
* @return
* Returns DataParamEntry struct filled with a single value.
*/
virtual DataParamEntry GetEntryValue(int _shift = -1, int _mode = 0) {
IndicatorDataEntry _entry = GetEntry(_shift >= 0 ? _shift : iparams.GetShift());
/*
virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = -1) {
IndicatorDataEntry _entry = GetEntry(fmax(_shift, _shift >= 0 ? _shift : iparams.GetShift()));
DataParamEntry _value_entry;
switch (iparams.GetDataValueType()) {
case TYPE_BOOL:
Expand Down Expand Up @@ -1034,6 +1035,7 @@ class Indicator : public IndicatorBase {
}
return _value_entry;
}
*/

/**
* Returns the indicator's value.
Expand Down
6 changes: 2 additions & 4 deletions IndicatorBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -873,12 +873,10 @@ class IndicatorBase : public Chart {
template <typename T>
T GetValue(int _shift = 0, int _mode = 0) {
T _out;
GetMixedValue(_shift, _mode).Get(_out);
GetEntryValue(_shift, _mode).Get(_out);
return _out;
}

virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) = NULL;

/**
* Returns price corresponding to indicator value for a given shift and mode.
*
Expand Down Expand Up @@ -967,7 +965,7 @@ class IndicatorBase : public Chart {
/**
* Returns the indicator's entry value.
*/
virtual DataParamEntry GetEntryValue(int _shift = -1, int _mode = 0) = NULL;
virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = -1) = NULL;

/**
* Returns indicator value for a given shift and mode.
Expand Down
13 changes: 7 additions & 6 deletions Indicators/Bitwise/Indi_Candle.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,15 @@ class Indi_Candle : public Indicator<CandleParams> {
/**
* Returns the indicator's value.
*/
virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) {
virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = -1) {
double _value = EMPTY_VALUE;
int _ishift = _shift >= 0 ? _shift : iparams.GetShift();
BarOHLC _ohlcs[1];

switch (iparams.idstype) {
case IDATA_BUILTIN:
// In this mode, price is fetched from chart.
_ohlcs[0] = Chart::GetOHLC(_shift);
_ohlcs[0] = Chart::GetOHLC(_ishift);
break;
case IDATA_INDICATOR:
// In this mode, price is fetched from given indicator. Such indicator
Expand All @@ -92,10 +93,10 @@ class Indi_Candle : public Indicator<CandleParams> {
break;
}

_ohlcs[0].open = GetDataSource().GetValue<float>(_shift, PRICE_OPEN);
_ohlcs[0].high = GetDataSource().GetValue<float>(_shift, PRICE_HIGH);
_ohlcs[0].low = GetDataSource().GetValue<float>(_shift, PRICE_LOW);
_ohlcs[0].close = GetDataSource().GetValue<float>(_shift, PRICE_CLOSE);
_ohlcs[0].open = GetDataSource().GetValue<float>(_ishift, PRICE_OPEN);
_ohlcs[0].high = GetDataSource().GetValue<float>(_ishift, PRICE_HIGH);
_ohlcs[0].low = GetDataSource().GetValue<float>(_ishift, PRICE_LOW);
_ohlcs[0].close = GetDataSource().GetValue<float>(_ishift, PRICE_CLOSE);
break;
default:
SetUserError(ERR_INVALID_PARAMETER);
Expand Down
13 changes: 7 additions & 6 deletions Indicators/Bitwise/Indi_Pattern.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,16 @@ class Indi_Pattern : public Indicator<IndiPatternParams> {
/**
* Returns the indicator's value.
*/
virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) {
virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = -1) {
int i;
int _ishift = _shift >= 0 ? _shift : iparams.GetShift();
BarOHLC _ohlcs[8];

switch (iparams.idstype) {
case IDATA_BUILTIN:
// In this mode, price is fetched from chart.
for (i = 0; i < iparams.GetMaxModes(); ++i) {
_ohlcs[i] = Chart::GetOHLC(_shift + i);
_ohlcs[i] = Chart::GetOHLC(_ishift + i);
if (!_ohlcs[i].IsValid()) {
// Return empty entry on invalid candles.
return WRONG_VALUE;
Expand All @@ -90,10 +91,10 @@ class Indi_Pattern : public Indicator<IndiPatternParams> {
}

for (i = 0; i < iparams.GetMaxModes(); ++i) {
_ohlcs[i].open = GetDataSource().GetValue<float>(_shift + i, PRICE_OPEN);
_ohlcs[i].high = GetDataSource().GetValue<float>(_shift + i, PRICE_HIGH);
_ohlcs[i].low = GetDataSource().GetValue<float>(_shift + i, PRICE_LOW);
_ohlcs[i].close = GetDataSource().GetValue<float>(_shift + i, PRICE_CLOSE);
_ohlcs[i].open = GetDataSource().GetValue<float>(_ishift + i, PRICE_OPEN);
_ohlcs[i].high = GetDataSource().GetValue<float>(_ishift + i, PRICE_HIGH);
_ohlcs[i].low = GetDataSource().GetValue<float>(_ishift + i, PRICE_LOW);
_ohlcs[i].close = GetDataSource().GetValue<float>(_ishift + i, PRICE_CLOSE);
if (!_ohlcs[i].IsValid()) {
// Return empty entry on invalid candles.
return WRONG_VALUE;
Expand Down
7 changes: 4 additions & 3 deletions Indicators/Indi_AC.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,16 @@ class Indi_AC : public Indicator<IndiACParams> {
/**
* Returns the indicator's value.
*/
virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) {
virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = -1) {
IndicatorDataEntryValue _value = EMPTY_VALUE;
int _ishift = _shift >= 0 ? _shift : iparams.GetShift();
switch (iparams.idstype) {
case IDATA_BUILTIN:
istate.handle = istate.is_changed ? INVALID_HANDLE : istate.handle;
_value = Indi_AC::iAC(GetSymbol(), GetTf(), _shift, THIS_PTR);
_value = Indi_AC::iAC(GetSymbol(), GetTf(), _ishift, THIS_PTR);
break;
case IDATA_ICUSTOM:
_value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), _mode, _shift);
_value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), _mode, _ishift);
break;
default:
SetUserError(ERR_INVALID_PARAMETER);
Expand Down
7 changes: 4 additions & 3 deletions Indicators/Indi_AD.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,16 @@ class Indi_AD : public Indicator<IndiADParams> {
/**
* Returns the indicator's value.
*/
virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) {
virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = -1) {
double _value = EMPTY_VALUE;
int _ishift = _shift >= 0 ? _shift : iparams.GetShift();
switch (iparams.idstype) {
case IDATA_BUILTIN:
istate.handle = istate.is_changed ? INVALID_HANDLE : istate.handle;
_value = Indi_AD::iAD(GetSymbol(), GetTf(), _shift, THIS_PTR);
_value = Indi_AD::iAD(GetSymbol(), GetTf(), _ishift, THIS_PTR);
break;
case IDATA_ICUSTOM:
_value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), _mode, _shift);
_value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), _mode, _ishift);
break;
default:
SetUserError(ERR_INVALID_PARAMETER);
Expand Down
8 changes: 5 additions & 3 deletions Indicators/Indi_ADX.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -115,19 +115,21 @@ class Indi_ADX : public Indicator<IndiADXParams> {
/**
* Returns the indicator's value.
*/
virtual IndicatorDataEntryValue GetMixedValue(int _mode = LINE_MAIN_ADX, int _shift = 0) {
virtual IndicatorDataEntryValue GetEntryValue(int _mode = LINE_MAIN_ADX, int _shift = -1) {
double _value = EMPTY_VALUE;
int _ishift = _shift >= 0 ? _shift : iparams.GetShift();
switch (iparams.idstype) {
case IDATA_BUILTIN:
istate.handle = istate.is_changed ? INVALID_HANDLE : istate.handle;
_value = Indi_ADX::iADX(GetSymbol(), GetTf(), GetPeriod(), GetAppliedPrice(), _mode, _shift, THIS_PTR);
_value = Indi_ADX::iADX(GetSymbol(), GetTf(), GetPeriod(), GetAppliedPrice(), _mode, _ishift, THIS_PTR);
break;
case IDATA_ICUSTOM:
_value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), /*[*/ GetPeriod() /*]*/,
_mode, _shift);
_mode, _ishift);
break;
default:
SetUserError(ERR_INVALID_PARAMETER);
break;
}
return _value;
}
Expand Down
7 changes: 4 additions & 3 deletions Indicators/Indi_ADXW.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -215,16 +215,17 @@ class Indi_ADXW : public Indicator<IndiADXWParams> {
/**
* Returns the indicator's value.
*/
virtual IndicatorDataEntryValue GetMixedValue(int _mode = LINE_MAIN_ADX, int _shift = 0) {
virtual IndicatorDataEntryValue GetEntryValue(int _mode = LINE_MAIN_ADX, int _shift = -1) {
double _value = EMPTY_VALUE;
int _ishift = _shift >= 0 ? _shift : iparams.GetShift();
switch (iparams.idstype) {
case IDATA_BUILTIN:
istate.handle = istate.is_changed ? INVALID_HANDLE : istate.handle;
_value = Indi_ADXW::iADXWilder(GetSymbol(), GetTf(), GetPeriod(), _mode, _shift, THIS_PTR);
_value = Indi_ADXW::iADXWilder(GetSymbol(), GetTf(), GetPeriod(), _mode, _ishift, THIS_PTR);
break;
case IDATA_ICUSTOM:
_value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), /*[*/ GetPeriod() /*]*/,
_mode, _shift);
_mode, _ishift);
break;
default:
SetUserError(ERR_INVALID_PARAMETER);
Expand Down
7 changes: 4 additions & 3 deletions Indicators/Indi_AMA.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -199,16 +199,17 @@ class Indi_AMA : public Indicator<IndiAMAParams> {
/**
* Returns the indicator's value.
*/
virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) {
virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = -1) {
double _value = EMPTY_VALUE;
int _ishift = _shift >= 0 ? _shift : iparams.GetShift();
switch (iparams.idstype) {
case IDATA_BUILTIN:
_value = Indi_AMA::iAMA(GetSymbol(), GetTf(), /*[*/ GetPeriod(), GetFastPeriod(), GetSlowPeriod(),
GetAMAShift(), GetAppliedPrice() /*]*/, _mode, _shift, THIS_PTR);
GetAMAShift(), GetAppliedPrice() /*]*/, _mode, _ishift, THIS_PTR);
break;
case IDATA_ICUSTOM:
_value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), /*[*/ GetPeriod(),
GetFastPeriod(), GetSlowPeriod(), GetAMAShift() /*]*/, _mode, _shift);
GetFastPeriod(), GetSlowPeriod(), GetAMAShift() /*]*/, _mode, _ishift);

break;
case IDATA_INDICATOR:
Expand Down
7 changes: 4 additions & 3 deletions Indicators/Indi_AO.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,16 @@ class Indi_AO : public Indicator<IndiAOParams> {
/**
* Returns the indicator's value.
*/
virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) {
virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = -1) {
double _value = EMPTY_VALUE;
int _ishift = _shift >= 0 ? _shift : iparams.GetShift();
switch (iparams.idstype) {
case IDATA_BUILTIN:
istate.handle = istate.is_changed ? INVALID_HANDLE : istate.handle;
_value = Indi_AO::iAO(GetSymbol(), GetTf(), _shift, _mode, THIS_PTR);
_value = Indi_AO::iAO(GetSymbol(), GetTf(), _ishift, _mode, THIS_PTR);
break;
case IDATA_ICUSTOM:
_value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), _mode, _shift);
_value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), _mode, _ishift);
break;
default:
SetUserError(ERR_INVALID_PARAMETER);
Expand Down
7 changes: 4 additions & 3 deletions Indicators/Indi_ASI.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -155,18 +155,19 @@ class Indi_ASI : public Indicator<IndiASIParams> {
/**
* Returns the indicator's value.
*/
virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) {
virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = -1) {
double _value = EMPTY_VALUE;
int _ishift = _shift >= 0 ? _shift : iparams.GetShift();
switch (iparams.idstype) {
case IDATA_ICUSTOM:
_value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(),
/*[*/ GetMaximumPriceChanging() /*]*/, 0, _shift);
/*[*/ GetMaximumPriceChanging() /*]*/, 0, _ishift);
break;
case IDATA_ONCALCULATE: {
INDICATOR_CALCULATE_POPULATE_PARAMS_AND_CACHE_LONG(GetSymbol(), GetTf(),
Util::MakeKey("Indi_ASI", GetMaximumPriceChanging()));
_value =
iASIOnArray(INDICATOR_CALCULATE_POPULATED_PARAMS_LONG, GetMaximumPriceChanging(), _mode, _shift, _cache);
iASIOnArray(INDICATOR_CALCULATE_POPULATED_PARAMS_LONG, GetMaximumPriceChanging(), _mode, _ishift, _cache);
break;
}
default:
Expand Down
7 changes: 4 additions & 3 deletions Indicators/Indi_ATR.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,16 @@ class Indi_ATR : public Indicator<IndiATRParams> {
/**
* Returns the indicator's value.
*/
virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) {
virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = -1) {
double _value = EMPTY_VALUE;
int _ishift = _shift >= 0 ? _shift : iparams.GetShift();
switch (iparams.idstype) {
case IDATA_BUILTIN:
istate.handle = istate.is_changed ? INVALID_HANDLE : istate.handle;
_value = Indi_ATR::iATR(GetSymbol(), GetTf(), GetPeriod(), _shift, THIS_PTR);
_value = Indi_ATR::iATR(GetSymbol(), GetTf(), GetPeriod(), _ishift, THIS_PTR);
break;
case IDATA_ICUSTOM:
_value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), _mode, _shift);
_value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), _mode, _ishift);
break;
default:
SetUserError(ERR_INVALID_PARAMETER);
Expand Down
11 changes: 6 additions & 5 deletions Indicators/Indi_Alligator.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -162,28 +162,29 @@ class Indi_Alligator : public Indicator<IndiAlligatorParams> {
/**
* Returns the indicator's value.
*/
virtual IndicatorDataEntryValue GetMixedValue(int _mode, int _shift = 0) {
virtual IndicatorDataEntryValue GetEntryValue(int _mode, int _shift = -1) {
double _value = EMPTY_VALUE;
int _ishift = _shift >= 0 ? _shift : iparams.GetShift();
#ifdef __MQL4__
if (_mode == 0) {
// In MQL4 mode 0 should be treated as mode 1 as Alligator buffers starts from index 1.
return GetMixedValue((ENUM_ALLIGATOR_LINE)1, _shift);
return GetEntryValue((ENUM_ALLIGATOR_LINE)1, _ishift);
}
#endif
double _value = EMPTY_VALUE;
switch (iparams.idstype) {
case IDATA_BUILTIN:
istate.handle = istate.is_changed ? INVALID_HANDLE : istate.handle;
_value = Indi_Alligator::iAlligator(GetSymbol(), GetTf(), GetJawPeriod(), GetJawShift(), GetTeethPeriod(),
GetTeethShift(), GetLipsPeriod(), GetLipsShift(), GetMAMethod(),
GetAppliedPrice(), (ENUM_ALLIGATOR_LINE)_mode, _shift, THIS_PTR);
GetAppliedPrice(), (ENUM_ALLIGATOR_LINE)_mode, _ishift, THIS_PTR);
break;
case IDATA_ICUSTOM:
_value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), /*[*/
GetJawPeriod(), GetJawShift(), GetTeethPeriod(), GetTeethShift(), GetLipsPeriod(),
GetLipsShift(), GetMAMethod(),
GetAppliedPrice()
/*]*/,
_mode, _shift);
_mode, _ishift);
break;
default:
SetUserError(ERR_INVALID_PARAMETER);
Expand Down
5 changes: 3 additions & 2 deletions Indicators/Indi_AppliedPrice.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,16 @@ class Indi_AppliedPrice : public Indicator<IndiAppliedPriceParams> {
/**
* Returns the indicator's value.
*/
virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) {
virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = -1) {
double _value = EMPTY_VALUE;
int _ishift = _shift >= 0 ? _shift : iparams.GetShift();
switch (iparams.idstype) {
case IDATA_INDICATOR:
if (HasDataSource()) {
// Future validation of indi_src will check if we set mode for source indicator
// (e.g. for applied price of Indi_Price).
iparams.SetDataSourceMode(GetAppliedPrice());
_value = Indi_AppliedPrice::iAppliedPriceOnIndicator(GetDataSource(), GetAppliedPrice(), _shift);
_value = Indi_AppliedPrice::iAppliedPriceOnIndicator(GetDataSource(), GetAppliedPrice(), _ishift);
}
break;
default:
Expand Down
7 changes: 4 additions & 3 deletions Indicators/Indi_BWMFI.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,17 @@ class Indi_BWMFI : public Indicator<IndiBWIndiMFIParams> {
/**
* Returns the indicator's value.
*/
virtual IndicatorDataEntryValue GetMixedValue(int _mode = BWMFI_BUFFER, int _shift = 0) {
virtual IndicatorDataEntryValue GetEntryValue(int _mode = BWMFI_BUFFER, int _shift = -1) {
double _value = EMPTY_VALUE;
int _ishift = _shift >= 0 ? _shift : iparams.GetShift();
switch (iparams.idstype) {
case IDATA_BUILTIN:
istate.handle = istate.is_changed ? INVALID_HANDLE : istate.handle;
_value = Indi_BWMFI::iBWMFI(GetSymbol(), GetTf(), _shift, (ENUM_BWMFI_BUFFER)_mode, THIS_PTR);
_value = Indi_BWMFI::iBWMFI(GetSymbol(), GetTf(), _ishift, (ENUM_BWMFI_BUFFER)_mode, THIS_PTR);
break;
case IDATA_ICUSTOM:
_value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), /*[*/ VOLUME_TICK /*]*/,
_mode, _shift);
_mode, _ishift);
break;
default:
SetUserError(ERR_INVALID_PARAMETER);
Expand Down
7 changes: 4 additions & 3 deletions Indicators/Indi_BWZT.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,15 @@ class Indi_BWZT : public Indicator<IndiBWZTParams> {
/**
* Returns the indicator's value.
*/
virtual IndicatorDataEntryValue GetMixedValue(int _mode = 0, int _shift = 0) {
virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _shift = -1) {
double _value = EMPTY_VALUE;
int _ishift = _shift >= 0 ? _shift : iparams.GetShift();
switch (iparams.idstype) {
case IDATA_BUILTIN:
_value = Indi_BWZT::iBWZT(GetSymbol(), GetTf(), _mode, _shift, THIS_PTR);
_value = Indi_BWZT::iBWZT(GetSymbol(), GetTf(), _mode, _ishift, THIS_PTR);
break;
case IDATA_ICUSTOM:
_value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), _mode, _shift);
_value = iCustom(istate.handle, GetSymbol(), GetTf(), iparams.GetCustomIndicatorName(), _mode, _ishift);
break;
default:
SetUserError(ERR_INVALID_PARAMETER);
Expand Down
Loading

0 comments on commit 47e353f

Please sign in to comment.