Open GoogleCodeExporter opened 9 years ago
Original comment by peter.st...@1ab.ltd.uk
on 20 Jan 2010 at 1:08
What I remember from our discussion
o. Keep a running count of the number of days since the %R went below -80 or
above
-20. These will require separate columns in the indicators table.
o. When %R is greater than -80, that is from -79 to 0, the count will be +ve
o. When %R is <= -80 the count will be -ve
Should it work the same way for -20? Or should the sense be reversed? Which
makes
writing queries more straight forward? I suspect keeping it consistent makes
most sense.
o. Variable names? Here I've used wpr_10_os_80 as the number of days since
wpr_10 was
over sold at -80 (os = over sold)
The method might be something like this (for -80)
-- get yesterday's count
SELECT wpr_10_os_80 last_wpr_10_os FROM indicators WHERE DATE < new_date AND
symb =
new_symb AND exch = new_exch ORDER BY DATE DESC limit 1;
if not found -- first record?
if wpr10v > -80 then
wpr_10_os_80 := 1
else
wpr_10_os_80 := -1
end if
-- work out today's count. If it's in the same direction as yesterday's then
increment, if not reset it to +1 or -1
elsif last_wpr_10_os > 0 then -- which means wpr10v > -80 yesterday
if wpr10v > -80 then
-- another day in the same direction
wpr_10_os_80 := wpr_10_os_80 + 1;
else
-- swapped direction
wpr_10_os_80 := -1
end if
else
if wpr10v < -80 then
-- another day in the same direction
wpr_10_os_80 := wpr_10_os_80 1 1;
else
-- swapped direction
wpr_10_os_80 := 1
end if
end if
Original comment by peter.st...@1ab.ltd.uk
on 23 Feb 2010 at 1:05
wpr_10_os_80 := wpr_10_os_80 1 1;
should say
wpr_10_os_80 := wpr_10_os_80 - 1;
Original comment by peter.st...@1ab.ltd.uk
on 23 Feb 2010 at 1:07
I wish you could edit these!
-- get yesterday's count
SELECT wpr_10_os_80 as last_wpr_10_os into yesterday FROM indicators WHERE DATE
<
new_date AND symb = new_symb AND exch = new_exch ORDER BY DATE DESC limit 1;
if not found -- first record?
if wpr10v > -80 then
wpr_10_os_80 := 1
else
wpr_10_os_80 := -1
end if
-- work out today's count. If it's in the same direction as yesterday's then
increment, if not reset it to +1 or -1
elsif yesterday.last_wpr_10_os > 0 then -- which means wpr10v > -80 yesterday
if wpr10v > -80 then
-- another day in the same direction
wpr_10_os_80 := wpr_10_os_80 + 1;
else
-- swapped direction
wpr_10_os_80 := -1
end if
else
if wpr10v < -80 then
-- another day in the same direction
wpr_10_os_80 := wpr_10_os_80 - 1;
else
-- swapped direction
wpr_10_os_80 := 1
end if
end if
Original comment by peter.st...@1ab.ltd.uk
on 23 Feb 2010 at 1:26
will have a shot at this soon.
Original comment by peter.st...@1ab.ltd.uk
on 9 Jan 2011 at 2:01
Original issue reported on code.google.com by
peter.st...@1ab.ltd.uk
on 19 Jan 2010 at 2:27