I am trying to backtest an idea I recently had. I dont have a proper programming background so I am having a though time finding a way to program the logic.
Basically I want to draw a line. The lines recent value always relies on the value before. Its basically
x = IIf(Ma20 > x[1], MA20, x[1])
But it gives me an Error29 - Variable 'x' used without having been initialized.
So added a line of code above the IIf statement.
x = 0.0;
But as I understand it, in this case with every new candle x equals 0 again. How do I fix this properly? Is there a FirstCandle-Function so I can write an if-clause for that?
But if you think about your formula yourself then it simply tries to look for highest MA20.
So if you would look up at AFL function reference guide then you would find it within seconds.