My indicator started to behave strangely today: one particular bool is being set to True, despite the one of two conditions for changing its state being False.
The prints look as follows:
CB = 2216 | C 2 = 4 | FLSbar[w-1] = 2212 | Flat Found = -1 | Flat End = -1 | FlatLowBar = False | FlatLow = False | Lows[0] = 49.99 | Lows[1] = 50 | Lows[FLSbar[w-1]] = 50.02
CB = 2217 | C 2 = 1 | FLSbar[w-1] = 2216 | Flat Found = 0 | Flat End = 0 | FlatLowBar = True | FlatLow = True | Lows[0] = 49.99 | Lows[1] = 49.99 | Lows[FLSbar[w-1]] = 49.99
CB = 2218 | C 2 = 2 | FLSbar[w-1] = 2216 | Flat Found = 1 | Flat End = 1 | FlatLowBar = False | FlatLow = False | Lows[0] = 50 | Lows[1] = 49.99 | Lows[FLSbar[w-1]] = 49.99
CB = 2219 | C 2 = 3 | FLSbar[w-1] = 2216 | Flat Found = 1 | Flat End = 1 | FlatLowBar = False | FlatLow = False | Lows[0] = 50.04 | Lows[1] = 50 | Lows[FLSbar[w-1]] = 49.99
CB = 2220 | C 2 = 4 | FLSbar[w-1] = 2216 | Flat Found = 1 | Flat End = 1 | FlatLowBar = False | FlatLow = True | Lows[0] = 50.05 | Lows[1] = 50.04 | Lows[FLSbar[w-1]] = 49.99
As you can see, the last Flat Low is correctly found on bar 2217, but for some reason, on bar 2220, FlatLow bool is set to True, despite the ApproxCompare condition being 1, which disables the script for the rest of the session and I am struggling to understand why, so an answer different to 'We can't assist with debugging' would be appreciated.
private void PriceLowFlat() { if (!FlatLow && Lows[0][0].ApproxCompare(Lows[0][1]) == 0) { if (!FlatLowBar) { FLSbar.Add(CurrentBar-1); // w FlatLowPrice.Add(Lows[0][1]); FlatLowBar = true; w++; } FlatLow = true; } else if (FlatLowBar && Lows[0][0].ApproxCompare(Lows[0].GetValueAt(FLSbar[w-1])) != 0) { FLEbar.Add(CurrentBar-1); FlatLowBar = false; FlatLow = false; x++; } } if (x > 0 && w > 0) Print ("CB = " + CurrentBar + " | C 2 = " + (CurrentBar - FLSbar[w-1]) + " | FLSbar[w-1] = " + FLSbar[w-1] + " | Flat Found = " + Lows[0][0].ApproxCompare(Lows[0][1]) + " | Flat End = " + Lows[0][0].ApproxCompare(Lows[0].GetValueAt(FLSbar[w-1])) + " | FlatLowBar = " + FlatLowBar + " | FlatLow = " + FlatLow + " | Lows[0] = " + Lows[0][0] + " | Lows[1] = " + Lows[0][1] + " | Lows[FLSbar[w-1]] = " + Lows[0].GetValueAt(FLSbar[w-1]));
Comment