SI
SI
discoversearch

We've detected that you're using an ad content blocking browser plug-in or feature. Ads provide a critical source of revenue to the continued operation of Silicon Investor.  We ask that you disable ad blocking while on Silicon Investor in the best interests of our community.  If you are not using an ad blocker but are still receiving this message, make sure your browser's tracking protection is set to the 'standard' level.
Strategies & Market Trends : TA-Quotes Plus -- Ignore unavailable to you. Want to Upgrade?


To: Bob Jagow who wrote (6841)9/27/1998 10:04:00 AM
From: Sean W. Smith  Read Replies (1) | Respond to of 11149
 
Bob,

I'm confused. How can you exit the loop early when you are looking for a max high across all time. Just because it hit all all time high 100 days ago doesn't mean it hasn't made three more since then.

BTW: There is a bug in my previous scan. MaxHi and MinLo should be floats not Integers which will yield some incorrect results...

Here's correct version. Now you could use the built in max function to determine the value then exit the loop once that condition had been satisfied.

Sean

// Hi Lo by Sean Smith
exchange = nyse, amex, nasdaq;
output = "hilo.lst";

// input="vol250.lst";
// ProcessMS = "f:\invest\metadata\hilo\",VMS;

daystoload = 2200;
daysrequired =1;

Integer numdays,i,minDate, maxDate;
float maxHi, minLo;

numdays:=((DaysLoaded-1)*-1);
minLo := 99999999.0;
maxHi := 0.0;
maxDate := 0;
minDate := 0;

for i=numdays to 0 step 1 do
if close(i) >= maxHi then
maxHi := close(i);
maxDate := i;endif;

if close(i) <= minLo then
minLo := close(i);
minDate := i;
endif;

next i;

Print Symbol:-5,",","cl:0",",",close(0):6:2,",","Max",",",close(maxDate),",MaxDate,",Date(maxDate);
PrintLn "Min",",",close(MinDate),",MinDate,",Date(MinDate);



To: Bob Jagow who wrote (6841)9/29/1998 9:13:00 AM
From: Sean W. Smith  Read Replies (2) | Respond to of 11149
 
for i=numdays to 0 step 1 do
if close(i) >= maxHi then
maxHi := close(i);
maxDate := i;
i := 0;
endif;
next i;
for i=numdays to 0 step 1 do
if close(i) <= minLo then
minLo := close(i);
minDate := i;
i := 0;
endif;
next i;


Bob,

the above code will give erroneous results in the context of the scan I provided. Since MaxHi is set to 0 initially and MaxLo to 9999999 then your code will always exit on the first iteration. If one were to preset maxHi and maxLo to the actual values using the builtin in QP functions you could successfully exit the loop when these conditions were met. The way I wrote it it doesn't. I try using Min/Max to predetermine the hi/lo and kick out of the loop when its done and compare speed.

Sean