Again I have some difficulties to translate some easylanguage code into afl.
First I calculate, for exemple in a 5 min chart, the VWAP (Volume-Weighted Average Price)
which generates a dynamical line like a moving average.
Now I want to conserve when the date changes the previous last value in a way that I get the
4 last static values for the past 4 days.
In easylanguage this is simple as I can roll 4 variables until they are filled
If date > date[1] then begin
D4 = D3;
D3 = D2;
D2 = D1;
D1 = vwapp;
vwapp = 0;
end;
So the last VWAP is conserved in D1 and the new VWAP is reset to 0
to start the new day. At the end I have conserved this way the final
VWAP values for the 4 last days.
But I just can't find the way to do this with afl. Neither with 'Lastvalue'
nor with something like
Thank you very much. This indeed resolves basically the problem. I just added the D1
which was paradoxically lacking to get all the 4 days added.
There is just a little problem remaining. In smaller timeframes the lines simply disappear.
In the hourly all the 5 lines are visible, in 15 min only 4 lines remain, in 5 min only the
VWAP line is visible and in 1 min chart all lines have disappeared. It seems that
the price where the lines are anchored must be in the visible window, so lines tend also
to disappear when one scrolls through the chart.