This scan grew out of the search for an RSI formula. It counts the numbers of days up in a variable period, and gives the average gap up and gap down. The RSI at the end is QP's function.
output = "rsi.lst";
daystoload=500;
issuetype=common; exchange nyse,nasdaq,amex;
float daysup, daysdown, updays, dndays, u, d;
integer i;
daysup := 0; daysdown := 0; updays:=0; dndays:=0;
for i = 0 to -13 step -1 do if close(i) > close(i-1) then updays := updays + (close(i) - close(i-1)); daysup := daysup +1; endif;
if close(i) < close(i-1) then dndays := dndays + (close(i) - close(i-1)); daysdown:= daysdown + 1; endif;
next i;
u:=updays/(daysup+.00000001); d:=dndays/abs(daysdown+.0000001);
println Symbol:-6,",", "Days up: ", daysup:2:0, " Days down: ", daysdown:2:0, " Avg upgap: ", u:3:3,",", " Avg downgap: ",d:3:3, " RSI: ",rsi(0):3:3; |