What you mean by still having a faulty code?
When you report, then please include your strategy file, it contains the indi with those values, which arise suspicion.
I took a quick glance of the code and I think I know where the problem is.
It is this line:
L0 = (1 - dGamma) * Close[iBar] + dGamma * L0A;
The issue is that it uses the whole data series for value calculation. While in backtesting there can be tens of thousands of bars, in trading there's bare minimum, which in most cases is well below 1000 bars and this explains the discrepancy. The code is not faulty but it behaves differently because it is calculated on different length data sets.