PureBytes Links
Trading Reference Links
|
Another efficiency improvement vs original quick-and-dirty version;
timetominutes function is now not called needlessly.
Unless you're doing a lot of optimization over large amounts of data, these
improvements will probably be imperceptible.
{Variation of oddball system by Mark Brown.
Indifferent to bar length if <= interval, and to extraneous night session
data.
First and last are start and end times. Interval is time in minutes between
pollings.}
Inputs: bz(3), sz(1), first(1000), interval(60), last(1600);
var: rai(0), action(0), ttm(0), initialized(false);
array: obtime[1000](0), obvalue[1000](0);
if initialized = false then begin
obtime[1] = timetominutes(first);
value1 = 1;
ttm = timetominutes(last);
while obtime[value1] < ttm begin
value1 = value1 + 1;
obtime[value1] = obtime[value1-1] + interval;
end;
initialized = true;
end;
action = 0;
for value2 = 1 to value1 begin
ttm = timetominutes(time);
if ttm = obtime[value2] then begin
if obvalue[value2] > 0 then begin
rai = ((close of data2) / obvalue[value2] - 1) * 100;
If rai > bz then action = 1;
If rai < sz then action = -1;
end;
obvalue[value2] = close of data2;
end;
end;
if action = 1 then buy;
if action = -1 then sell;
|