Great concept, wrong calculations.
But not easy to see the error looking at the chart.
Unless you scale the data to feed your neural network and everything starts going bad.
You will rewrite the network, double check the transfer function and start having sigmoid dreams for a couple of months.
Finally, since everything else is ok, you realize that if your income is decreased by 10% and then the result is increased by 10% you dont earn the same money. Only politicians say so
Data is not centered around zero and overflow the upper limit.
So, use this approach and remember to check other indicators too:
if (period>first) then
local half=source[period]*percent/200
if source[period]-half>M[period-1] then
M[period]=source[period]-half
elseif source[period]+half<M[period-1] then
M[period]=source[period]+half
else
M[period]=M[period-1];
end
U[period]=M[period]+half
L[period]=M[period]-half
else ......
Best regards,
Takis