I am trying to create my first for loop, because I want to plot the max daily ranges of the last x days above/below todays open. Works perfect when just writing it all out like:

MaxR = maxlist( highd(1) - lowd(1), highd(2) - lowd(2), highd(3) - lowd(3), highd(4) - lowd(4), highd(5) - lowd(5));

..and then plotting that, but I wanna go much further back in time and add the flexibility tweaking the lookback.

This is what I came up, with (doesn't work, simply plots the range from lookkback days ago):

Any help very appreciated

Code: Select all

`vars: x(0), HistRange(0), Lookback(3);`

HistRange = 0;

For x = 0 to Lookback begin

HistRange = maxlist(dailyrange(x)); //dailyrange: highd(numeric) - lowd(numeric)

end;

plot1(OpenD(0) + HistRange,"Top Intradday MAX range");

plot2(OpenD(0) - HistRange,"Bottom Intradday MAX range");