diff --git a/Indicators/Indi_ADXW.mqh b/Indicators/Indi_ADXW.mqh index 2263d11cc..0d1613344 100644 --- a/Indicators/Indi_ADXW.mqh +++ b/Indicators/Indi_ADXW.mqh @@ -39,7 +39,7 @@ struct IndiADXWParams : IndiADXParams { IndiADXWParams(int _period = 14, ENUM_APPLIED_PRICE _ap = PRICE_TYPICAL, int _shift = 0) : IndiADXParams(_period, _ap, _shift) { itype = itype == INDI_NONE || itype == INDI_ADX ? INDI_ADXW : itype; - if (custom_indi_name == "") { + if (custom_indi_name == "" || custom_indi_name == "Examples\\ADX") { SetCustomIndicatorName("Examples\\ADXW"); } }; @@ -158,33 +158,32 @@ class Indi_ADXW : public Indicator { /** * OnCalculate() method for ADXW indicator. */ - static int Calculate(INDICATOR_CALCULATE_METHOD_PARAMS_LONG, ValueStorage &ExtADXWBuffer, - ValueStorage &ExtPDIBuffer, ValueStorage &ExtNDIBuffer, - ValueStorage &ExtPDSBuffer, ValueStorage &ExtNDSBuffer, - ValueStorage &ExtPDBuffer, ValueStorage &ExtNDBuffer, - ValueStorage &ExtTRBuffer, ValueStorage &ExtATRBuffer, - ValueStorage &ExtDXBuffer, int ExtADXWPeriod) { + static int Calculate(INDICATOR_CALCULATE_METHOD_PARAMS_LONG, ValueStorage &_adxw_buff, + ValueStorage &_pdi_buff, ValueStorage &_ndi_buff, + ValueStorage &_pds_buff, ValueStorage &_nds_buff, + ValueStorage &_pdb_buff, ValueStorage &_nd_buff, ValueStorage &_tr_buff, + ValueStorage &_atr_buff, ValueStorage &_dx_buff, int _adxw_period) { int i; // Checking for bars count. - if (rates_total < ExtADXWPeriod) return (0); + if (rates_total < _adxw_period) return (0); // Detect start position. int start; if (prev_calculated > 1) start = prev_calculated - 1; else { start = 1; - for (i = 0; i < ExtADXWPeriod; i++) { - ExtADXWBuffer[i] = 0; - ExtPDIBuffer[i] = 0; - ExtNDIBuffer[i] = 0; - ExtPDSBuffer[i] = 0; - ExtNDSBuffer[i] = 0; - ExtPDBuffer[i] = 0; - ExtNDBuffer[i] = 0; - ExtTRBuffer[i] = 0; - ExtATRBuffer[i] = 0; - ExtDXBuffer[i] = 0; + for (i = 0; i < _adxw_period; i++) { + _adxw_buff[i] = 0; + _pdi_buff[i] = 0; + _ndi_buff[i] = 0; + _pds_buff[i] = 0; + _nds_buff[i] = 0; + _pdb_buff[i] = 0; + _nd_buff[i] = 0; + _tr_buff[i] = 0; + _atr_buff[i] = 0; + _dx_buff[i] = 0; } } for (i = start; i < rates_total && !IsStopped(); i++) { @@ -208,40 +207,40 @@ class Indi_ADXW : public Indicator { else tmp_neg = 0.0; } - ExtPDBuffer[i] = tmp_pos; - ExtNDBuffer[i] = tmp_neg; + _pdb_buff[i] = tmp_pos; + _nd_buff[i] = tmp_neg; // Define TR. double tr = MathMax(MathMax(MathAbs(high_price - low_price), MathAbs(high_price - prev_close)), MathAbs(low_price - prev_close)); // Write down TR to TR buffer. - ExtTRBuffer[i] = tr; + _tr_buff[i] = tr; // Fill smoothed positive and negative buffers and TR buffer. - if (i < ExtADXWPeriod) { - ExtATRBuffer[i] = 0.0; - ExtPDIBuffer[i] = 0.0; - ExtNDIBuffer[i] = 0.0; + if (i < _adxw_period) { + _atr_buff[i] = 0.0; + _pdi_buff[i] = 0.0; + _ndi_buff[i] = 0.0; } else { - ExtATRBuffer[i] = SmoothedMA(i, ExtADXWPeriod, ExtATRBuffer[i - 1].Get(), ExtTRBuffer); - ExtPDSBuffer[i] = SmoothedMA(i, ExtADXWPeriod, ExtPDSBuffer[i - 1].Get(), ExtPDBuffer); - ExtNDSBuffer[i] = SmoothedMA(i, ExtADXWPeriod, ExtNDSBuffer[i - 1].Get(), ExtNDBuffer); + _atr_buff[i] = SmoothedMA(i, _adxw_period, _atr_buff[i - 1].Get(), _tr_buff); + _pds_buff[i] = SmoothedMA(i, _adxw_period, _pds_buff[i - 1].Get(), _pdb_buff); + _nds_buff[i] = SmoothedMA(i, _adxw_period, _nds_buff[i - 1].Get(), _nd_buff); } // Calculate PDI and NDI buffers. - if (ExtATRBuffer[i] != 0.0) { - ExtPDIBuffer[i] = 100.0 * ExtPDSBuffer[i].Get() / ExtATRBuffer[i].Get(); - ExtNDIBuffer[i] = 100.0 * ExtNDSBuffer[i].Get() / ExtATRBuffer[i].Get(); + if (_atr_buff[i] != 0.0) { + _pdi_buff[i] = 100.0 * _pds_buff[i].Get() / _atr_buff[i].Get(); + _ndi_buff[i] = 100.0 * _nds_buff[i].Get() / _atr_buff[i].Get(); } else { - ExtPDIBuffer[i] = 0.0; - ExtNDIBuffer[i] = 0.0; + _pdi_buff[i] = 0.0; + _ndi_buff[i] = 0.0; } // Calculate DX buffer. - double dTmp = ExtPDIBuffer[i] + ExtNDIBuffer[i]; + double dTmp = _pdi_buff[i] + _ndi_buff[i]; if (dTmp != 0.0) - dTmp = 100.0 * MathAbs((ExtPDIBuffer[i] - ExtNDIBuffer[i]) / dTmp); + dTmp = 100.0 * MathAbs((_pdi_buff[i] - _ndi_buff[i]) / dTmp); else dTmp = 0.0; - ExtDXBuffer[i] = dTmp; + _dx_buff[i] = dTmp; // Fill ADXW buffer as smoothed DX buffer. - ExtADXWBuffer[i] = SmoothedMA(i, ExtADXWPeriod, ExtADXWBuffer[i - 1].Get(), ExtDXBuffer); + _adxw_buff[i] = SmoothedMA(i, _adxw_period, _adxw_buff[i - 1].Get(), _dx_buff); } // OnCalculate done. Return new prev_calculated. return (rates_total); diff --git a/Indicators/Indi_AMA.mqh b/Indicators/Indi_AMA.mqh index 76daa7318..a50e2fff6 100644 --- a/Indicators/Indi_AMA.mqh +++ b/Indicators/Indi_AMA.mqh @@ -145,7 +145,7 @@ class Indi_AMA : public Indicator { /** * OnInit() method for AMA indicator. */ - static void CalculateInit(int InpPeriodAMA, int InpFastPeriodEMA, int InpSlowPeriodEMA, int InpShiftAMA, + static void CalculateInit(int InpPeriodAMA, int _period_fast_ema, int _period_slow_ema, int _ishift_ama, double &ExtFastSC, double &ExtSlowSC, int &ExtPeriodAMA, int &ExtSlowPeriodEMA, int &ExtFastPeriodEMA) { // Check for input values. @@ -156,20 +156,20 @@ class Indi_AMA : public Indicator { InpPeriodAMA, ExtPeriodAMA); } else ExtPeriodAMA = InpPeriodAMA; - if (InpSlowPeriodEMA <= 0) { + if (_period_slow_ema <= 0) { ExtSlowPeriodEMA = 30; PrintFormat( - "Input parameter InpSlowPeriodEMA has incorrect value (%d). Indicator will use value %d for calculations.", - InpSlowPeriodEMA, ExtSlowPeriodEMA); + "Input parameter _period_slow_ema has incorrect value (%d). Indicator will use value %d for calculations.", + _period_slow_ema, ExtSlowPeriodEMA); } else - ExtSlowPeriodEMA = InpSlowPeriodEMA; - if (InpFastPeriodEMA <= 0) { + ExtSlowPeriodEMA = _period_slow_ema; + if (_period_fast_ema <= 0) { ExtFastPeriodEMA = 2; PrintFormat( - "Input parameter InpFastPeriodEMA has incorrect value (%d). Indicator will use value %d for calculations.", - InpFastPeriodEMA, ExtFastPeriodEMA); + "Input parameter _period_fast_ema has incorrect value (%d). Indicator will use value %d for calculations.", + _period_fast_ema, ExtFastPeriodEMA); } else - ExtFastPeriodEMA = InpFastPeriodEMA; + ExtFastPeriodEMA = _period_fast_ema; // Calculate ExtFastSC & ExtSlowSC. ExtFastSC = 2.0 / (ExtFastPeriodEMA + 1.0); @@ -180,14 +180,14 @@ class Indi_AMA : public Indicator { * OnCalculate() method for AMA indicator. */ static int Calculate(INDICATOR_CALCULATE_METHOD_PARAMS_SHORT, ValueStorage &ExtAMABuffer, int InpPeriodAMA, - int InpFastPeriodEMA, int InpSlowPeriodEMA, int InpShiftAMA) { + int _period_fast_ema, int _period_slow_ema, int _ishift_ama) { double ExtFastSC; double ExtSlowSC; int ExtPeriodAMA; int ExtSlowPeriodEMA; int ExtFastPeriodEMA; - CalculateInit(InpPeriodAMA, InpFastPeriodEMA, InpSlowPeriodEMA, InpShiftAMA, ExtFastSC, ExtSlowSC, ExtPeriodAMA, + CalculateInit(InpPeriodAMA, _period_fast_ema, _period_slow_ema, _ishift_ama, ExtFastSC, ExtSlowSC, ExtPeriodAMA, ExtSlowPeriodEMA, ExtFastPeriodEMA); int i; // Check for rates count. diff --git a/Indicators/Indi_FractalAdaptiveMA.mqh b/Indicators/Indi_FractalAdaptiveMA.mqh index 5ddbed457..d7d783a08 100644 --- a/Indicators/Indi_FractalAdaptiveMA.mqh +++ b/Indicators/Indi_FractalAdaptiveMA.mqh @@ -144,7 +144,7 @@ class Indi_FrAMA : public Indicator { } static int Calculate(INDICATOR_CALCULATE_METHOD_PARAMS_LONG, ValueStorage &FrAmaBuffer, int InpPeriodFrAMA, - int InpShift, ENUM_APPLIED_PRICE InpAppliedPrice) { + int _ishift, ENUM_APPLIED_PRICE _applied_price) { if (rates_total < 2 * InpPeriodFrAMA) return (0); int start, i; @@ -152,7 +152,7 @@ class Indi_FrAMA : public Indicator { if (prev_calculated == 0) { start = 2 * InpPeriodFrAMA - 1; for (i = 0; i <= start; i++) - FrAmaBuffer[i] = AppliedPriceValueStorage::GetApplied(open, high, low, close, i, InpAppliedPrice); + FrAmaBuffer[i] = AppliedPriceValueStorage::GetApplied(open, high, low, close, i, _applied_price); } else start = prev_calculated - 1; @@ -170,7 +170,7 @@ class Indi_FrAMA : public Indicator { double n3 = (hi3 - lo3) / (2 * InpPeriodFrAMA); double d = (MathLog(n1 + n2) - MathLog(n3)) / math_log_2; double alfa = MathExp(-4.6 * (d - 1.0)); - double _iprice = AppliedPriceValueStorage::GetApplied(open, high, low, close, i, InpAppliedPrice); + double _iprice = AppliedPriceValueStorage::GetApplied(open, high, low, close, i, _applied_price); FrAmaBuffer[i] = alfa * _iprice + (1 - alfa) * FrAmaBuffer[i - 1].Get(); } diff --git a/Indicators/Indi_MA.mqh b/Indicators/Indi_MA.mqh index 2fe09b214..ad100db1b 100644 --- a/Indicators/Indi_MA.mqh +++ b/Indicators/Indi_MA.mqh @@ -268,23 +268,23 @@ class Indi_MA : public Indicator { * Calculates Simple Moving Average (SMA). The same as in "Example Moving Average" indicator. */ static void CalculateSimpleMA(int rates_total, int prev_calculated, int begin, ValueStorage &price, - ValueStorage &ExtLineBuffer, int _ma_period) { + ValueStorage &_line_buff, int _ma_period) { int i, start; // First calculation or number of bars was changed. if (prev_calculated == 0) { start = _ma_period + begin; // Set empty value for first start bars. - for (i = 0; i < start - 1; i++) ExtLineBuffer[i] = 0.0; + for (i = 0; i < start - 1; i++) _line_buff[i] = 0.0; // Calculate first visible value. double first_value = 0; for (i = begin; i < start; i++) first_value += price[i].Get(); first_value /= _ma_period; - ExtLineBuffer[start - 1] = first_value; + _line_buff[start - 1] = first_value; } else start = prev_calculated - 1; // Main loop. for (i = start; i < rates_total && !IsStopped(); i++) { - ExtLineBuffer[i] = ExtLineBuffer[i - 1] + (price[i] - price[i - _ma_period]) / _ma_period; + _line_buff[i] = _line_buff[i - 1] + (price[i] - price[i - _ma_period]) / _ma_period; } } @@ -292,21 +292,21 @@ class Indi_MA : public Indicator { * Calculates Exponential Moving Average (EMA). The same as in "Example Moving Average" indicator. */ static void CalculateEMA(int rates_total, int prev_calculated, int begin, ValueStorage &price, - ValueStorage &ExtLineBuffer, int _ma_period) { + ValueStorage &_line_buff, int _ma_period) { int i, limit; double SmoothFactor = 2.0 / (1.0 + _ma_period); // First calculation or number of bars was changed. if (prev_calculated == 0) { limit = _ma_period + begin; - ExtLineBuffer[begin] = price[begin]; + _line_buff[begin] = price[begin]; for (i = begin + 1; i < limit; i++) { - ExtLineBuffer[i] = price[i] * SmoothFactor + ExtLineBuffer[i - 1] * (1.0 - SmoothFactor); + _line_buff[i] = price[i] * SmoothFactor + _line_buff[i - 1] * (1.0 - SmoothFactor); } } else limit = prev_calculated - 1; // Main loop. for (i = limit; i < rates_total && !IsStopped(); i++) { - ExtLineBuffer[i] = price[i] * SmoothFactor + ExtLineBuffer[i - 1] * (1.0 - SmoothFactor); + _line_buff[i] = price[i] * SmoothFactor + _line_buff[i - 1] * (1.0 - SmoothFactor); } } @@ -314,7 +314,7 @@ class Indi_MA : public Indicator { * Calculates Linearly Weighted Moving Average (LWMA). The same as in "Example Moving Average" indicator. */ static void CalculateLWMA(int rates_total, int prev_calculated, int begin, ValueStorage &price, - ValueStorage &ExtLineBuffer, int _ma_period) { + ValueStorage &_line_buff, int _ma_period) { int i, limit; static int weightsum; double sum; @@ -323,7 +323,7 @@ class Indi_MA : public Indicator { weightsum = 0; limit = _ma_period + begin; // Set empty value for first limit bars. - for (i = 0; i < limit; i++) ExtLineBuffer[i] = 0.0; + for (i = 0; i < limit; i++) _line_buff[i] = 0.0; // Calculate first visible value. double firstValue = 0; for (i = begin; i < limit; i++) { @@ -332,14 +332,14 @@ class Indi_MA : public Indicator { firstValue += k * price[i].Get(); } firstValue /= (double)weightsum; - ExtLineBuffer[limit - 1] = firstValue; + _line_buff[limit - 1] = firstValue; } else limit = prev_calculated - 1; // Main loop. for (i = limit; i < rates_total && !IsStopped(); i++) { sum = 0; for (int j = 0; j < _ma_period; j++) sum += (_ma_period - j) * price[i - j].Get(); - ExtLineBuffer[i] = sum / weightsum; + _line_buff[i] = sum / weightsum; } //--- } @@ -348,23 +348,23 @@ class Indi_MA : public Indicator { * Calculates Smoothed Moving Average (SMMA). The same as in "Example Moving Average" indicator. */ static void CalculateSmoothedMA(int rates_total, int prev_calculated, int begin, ValueStorage &price, - ValueStorage &ExtLineBuffer, int _ma_period) { + ValueStorage &_line_buff, int _ma_period) { int i, limit; // First calculation or number of bars was changed. if (prev_calculated == 0) { limit = _ma_period + begin; // Set empty value for first limit bars. - for (i = 0; i < limit - 1; i++) ExtLineBuffer[i] = 0.0; + for (i = 0; i < limit - 1; i++) _line_buff[i] = 0.0; // Calculate first visible value. double firstValue = 0; for (i = begin; i < limit; i++) firstValue += price[i].Get(); firstValue /= _ma_period; - ExtLineBuffer[limit - 1] = firstValue; + _line_buff[limit - 1] = firstValue; } else limit = prev_calculated - 1; // Main loop. for (i = limit; i < rates_total && !IsStopped(); i++) - ExtLineBuffer[i] = (ExtLineBuffer[i - 1] * (_ma_period - 1) + price[i].Get()) / _ma_period; + _line_buff[i] = (_line_buff[i - 1] * (_ma_period - 1) + price[i].Get()) / _ma_period; //--- } @@ -583,7 +583,7 @@ class Indi_MA : public Indicator { * Calculates Moving Average. The same as in "Example Moving Average" indicator. */ static int Calculate(const int rates_total, const int prev_calculated, const int begin, ValueStorage &price, - ValueStorage &ExtLineBuffer, int _ma_method, int _ma_period) { + ValueStorage &_line_buff, int _ma_method, int _ma_period) { // Check for bars count. if (rates_total < _ma_period - 1 + begin) { // Not enough bars for calculation. @@ -591,22 +591,22 @@ class Indi_MA : public Indicator { } if (prev_calculated == 0) { // First calculation or number of bars was changed. - ArrayInitialize(ExtLineBuffer, (double)0); + ArrayInitialize(_line_buff, (double)0); } // Calculation. switch (_ma_method) { case MODE_EMA: - CalculateEMA(rates_total, prev_calculated, begin, price, ExtLineBuffer, _ma_period); + CalculateEMA(rates_total, prev_calculated, begin, price, _line_buff, _ma_period); break; case MODE_LWMA: - CalculateLWMA(rates_total, prev_calculated, begin, price, ExtLineBuffer, _ma_period); + CalculateLWMA(rates_total, prev_calculated, begin, price, _line_buff, _ma_period); break; case MODE_SMMA: - CalculateSmoothedMA(rates_total, prev_calculated, begin, price, ExtLineBuffer, _ma_period); + CalculateSmoothedMA(rates_total, prev_calculated, begin, price, _line_buff, _ma_period); break; case MODE_SMA: - CalculateSimpleMA(rates_total, prev_calculated, begin, price, ExtLineBuffer, _ma_period); + CalculateSimpleMA(rates_total, prev_calculated, begin, price, _line_buff, _ma_period); break; } // Return value of prev_calculated for next call. diff --git a/Indicators/Indi_TEMA.mqh b/Indicators/Indi_TEMA.mqh index cd380ea24..8c1be3f40 100644 --- a/Indicators/Indi_TEMA.mqh +++ b/Indicators/Indi_TEMA.mqh @@ -127,11 +127,11 @@ class Indi_TEMA : public Indicator { /** * OnCalculate() method for TEMA indicator. * - * Note that InpShift is used for drawing only and thus is unused. + * Note that _ishift is used for drawing only and thus is unused. */ static int Calculate(INDICATOR_CALCULATE_METHOD_PARAMS_SHORT, ValueStorage &TemaBuffer, ValueStorage &Ema, ValueStorage &EmaOfEma, ValueStorage &EmaOfEmaOfEma, - int InpPeriodEMA, int InpShift) { + int InpPeriodEMA, int _ishift) { if (rates_total < 3 * InpPeriodEMA - 3) return (0); //--- int start; diff --git a/Indicators/Indi_VIDYA.mqh b/Indicators/Indi_VIDYA.mqh index 8e13b4c27..aff6a87f1 100644 --- a/Indicators/Indi_VIDYA.mqh +++ b/Indicators/Indi_VIDYA.mqh @@ -132,10 +132,10 @@ class Indi_VIDYA : public Indicator { /** * OnCalculate() method for VIDyA indicator. * - * Note that InpShift is used for drawing only and thus is unused. + * Note that _ishift is used for drawing only and thus is unused. */ static int Calculate(INDICATOR_CALCULATE_METHOD_PARAMS_SHORT, ValueStorage &VIDYA_Buffer, int InpPeriodCMO, - int InpPeriodEMA, int InpShift) { + int InpPeriodEMA, int _ishift) { double ExtF = 2.0 / (1.0 + InpPeriodEMA); if (rates_total < InpPeriodEMA + InpPeriodCMO - 1) return (0);