CodeRe: Various (Specialist) indicators for MT4

1506
Modified DIDI Index with new multiple coloring changing signal logic

Didi index mod as request, new coloring mode.

EDIT : For corrected code look here, This version working with different MA's.

PS: For the MT5 version by member ZigZag, please see: DIDI Index for MT5.
These users thanked the author kvak for the post (total 8):
Krunal Gajjar, ZigZag, 88FX88, Jimmy, eduarescobar, macd & rsi, global, ChuChu Rocket

Re: Various (Specialist) indicators for MT4

1507
kvak wrote: Sun May 18, 2025 6:42 pm Didi index mod as request, new coloring mode.
In the original code, the calculation and handling of the median value were inadequate for different moving average (MA) methods. When a method other than exponential (EMA) was selected, situations could arise where the M_MA variable received a zero or negative value leaving indicator not drawing oscillatir at all. This caused problems because the value is used as a divisor, leading the indicator to "go dark."

I took rights fior my own hand and made few changes for it:

Added validation for the M_MA value:
Ensures that M_MA is a positive value before using it as a divisor
If M_MA is not positive, values from the previous bar are used instead
Modified handling of the median value:
Set the median value explicitly to 1.0 (previously just 1, which could cause inaccuracies)
Ensured that curta and longa are calculated only when M_MA is valid

Improved error handling:
Added logic to prevent division by zero
Ensured that the first bar has reasonable default values if values cannot be calculated
These changes make the indicator more stable across all MA methods, not just the exponential method.

This could be good candidate as MT5 version tool also.

EDIT : Corrected mtf , redownload new version
These users thanked the author ZigZag for the post (total 5):
kvak, Tsar, 88FX88, Jimmy, global

Re: Various (Specialist) indicators for MT4

1509
ZigZag wrote: Sun May 18, 2025 10:22 pm In the original code, the calculation and handling of the median value were inadequate for different moving average (MA) methods. When a method other than exponential (EMA) was selected, situations could arise where the M_MA variable received a zero or negative value leaving indicator not drawing oscillatir at all. This caused problems because the value is used as a divisor, leading the indicator to "go dark."

I took rights fior my own hand and made few changes for it:

Added validation for the M_MA value:
Ensures that M_MA is a positive value before using it as a divisor
If M_MA is not positive, values from the previous bar are used instead
Modified handling of the median value:
Set the median value explicitly to 1.0 (previously just 1, which could cause inaccuracies)
Ensured that curta and longa are calculated only when M_MA is valid

Improved error handling:
Added logic to prevent division by zero
Ensured that the first bar has reasonable default values if values cannot be calculated
These changes make the indicator more stable across all MA methods, not just the exponential method.

This could be good candidate as MT5 version tool also.
Yes, you are right.
Unfortunately, I haven't tested the code with different ma's. Thank you for correcting code.