diff --git a/Indicators/MyIndicators/CutlerRSI_MA.mq5 b/Indicators/MyIndicators/CutlerRSI_MA.mq5 index 93930a8..187ddaf 100644 --- a/Indicators/MyIndicators/CutlerRSI_MA.mq5 +++ b/Indicators/MyIndicators/CutlerRSI_MA.mq5 @@ -164,40 +164,53 @@ int OnCalculate(const int rates_total, } //--- STEP 3: Calculate the signal line (MA of Cutler's RSI) - for(int i = start_pos; i < rates_total; i++) + int ma_start_pos = g_ExtPeriodRSI + g_ExtPeriodMA - 1; + for(int i = ma_start_pos; i < rates_total; i++) { + // --- FIX: Full, robust switch block for all MA types --- switch(InpMethodMA) { case MODE_EMA: case MODE_SMMA: - if(i == start_pos) + if(i == ma_start_pos) { - double sum = 0; - for(int j = 0; j < g_ExtPeriodMA; j++) - sum += BufferCutlerRSI[i - j]; - BufferCutlerRSI_MA[i] = sum / g_ExtPeriodMA; + double sum=0; + for(int j=0; j0) + BufferCutlerRSI_MA[i]=lwma_sum/weight_sum; + } + break; default: // MODE_SMA - // Standard library function is safe here as it's not recursive - BufferCutlerRSI_MA[i] = SimpleMA(i, g_ExtPeriodMA, BufferCutlerRSI); - break; + { + double sum=0; + for(int j=0; j