PureBytes Links
Trading Reference Links
|
Initialization is now done only once.
By the way, you can set bar lookback to 1 with this code.
{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), initialized(false);
array: obtime[1000](0), obvalue[1000](0);
if initialized = false then begin
obtime[1] = timetominutes(first);
value1 = 1;
while obtime[value1] < timetominutes(last) begin
value1 = value1 + 1;
obtime[value1] = obtime[value1-1] + interval;
end;
initialized = true;
end;
action = 0;
for value2 = 1 to value1 begin
if timetominutes(time) = 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;
|