NT8 uses ApproxCompare in default Stochastics indicator to ensure a series is not divided by zero. However, the ApproxCompare dose not seem to be supported in NT8 since it will genrate an error if used for a custom script in a similar manner.
The closest supported feature I have found is "CompareTo." However it is not clear if it functions the same as ApproxCompare. So, I am trying to find the equivalent supported NT8 code for the following line from default Stochastics.
protected override void OnBarUpdate()
{
double min0 = min[0];
nom[0] = Close[0] - min0;
den[0] = max[0] - min0;
[COLOR="Magenta"] if (den[0].ApproxCompare(0) == 0)[/COLOR]
fastK[0] = CurrentBar == 0 ? 50 : fastK[1];
else
fastK[0] = Math.Min(100, Math.Max(0, 100 * nom[0] / den[0]));
// Slow %K == Fast %D
K[0] = smaFastK[0];
D[0] = smaK[0];
}
The "if (den[0].CompareTo(0) == 0)" does not work.
Many Thanks.

Comment