Quote from flyingdutchmen:
for 1 minute bars
avg = highest value minus lowest value within the chosen time
inputs: StartTime ( 0900 ), EndTime ( 1100 );
variables: ll(0), hh(0), avg(0), counter(0);
if time >= StartTime and time < EndTime then counter = counter + 1;
if time = EndTime then begin
ll = lowest( low, counter );
hh = highest( high, counter );
avg = ( hh - ll );
counter = 0;
end;