T
tianhf
Unregistered / Unconfirmed
GUEST, unregistred user!
type
dayRec=record
da:integer;
begin
0,high0,low0,now0:integer;
//*100
upDown:integer;
num:integer;
//*100
by1,by2,by3:integer;//备用.
end;
MACDRec=record
EMA12,EMA26:double;
DIF,DEM:double;
BARouble;
end;
-------------
var
recayRec;
MACD:MACDRec;
begin
file0:=TFileStream.Create(edit1.Text,fmOpenRead);
count:=1;
while file0.Read(rec,sizeOf(rec))>0 do
begin
if count=1 then
begin
MACD.EMA12:=rec.now0;
MACD.EMA26:=rec.now0;
MACD.DIF:=0;
MACD.DEM:=0;
end else
begin
MACD.EMA12:=MACD.EMA12*11/13+rec.now0*2/13;
MACD.EMA26:=MACD.EMA26*25/27+rec.now0*2/27;
MACD.DIF :=MACD.EMA12-MACD.EMA26;
MACD.DEM :=MACD.DEM*0.8+MACD.DIF*0.2;
MACD.BAR :=2*(MACD.DIF-MACD.DEM);
with MACD do
memo1.Lines.Add(format('%d EMA12=%6.0f EMA26=%6.0f DIF=%5.2f DEM=%5.2f, BAR=%5.2f',[rec.da,EMA12,EMA26,DIF/1000,DEM/1000,BAR/1000]));
end;
inc(count);
end;
end;
dayRec=record
da:integer;
begin
0,high0,low0,now0:integer;
//*100
upDown:integer;
num:integer;
//*100
by1,by2,by3:integer;//备用.
end;
MACDRec=record
EMA12,EMA26:double;
DIF,DEM:double;
BARouble;
end;
-------------
var
recayRec;
MACD:MACDRec;
begin
file0:=TFileStream.Create(edit1.Text,fmOpenRead);
count:=1;
while file0.Read(rec,sizeOf(rec))>0 do
begin
if count=1 then
begin
MACD.EMA12:=rec.now0;
MACD.EMA26:=rec.now0;
MACD.DIF:=0;
MACD.DEM:=0;
end else
begin
MACD.EMA12:=MACD.EMA12*11/13+rec.now0*2/13;
MACD.EMA26:=MACD.EMA26*25/27+rec.now0*2/27;
MACD.DIF :=MACD.EMA12-MACD.EMA26;
MACD.DEM :=MACD.DEM*0.8+MACD.DIF*0.2;
MACD.BAR :=2*(MACD.DIF-MACD.DEM);
with MACD do
memo1.Lines.Add(format('%d EMA12=%6.0f EMA26=%6.0f DIF=%5.2f DEM=%5.2f, BAR=%5.2f',[rec.da,EMA12,EMA26,DIF/1000,DEM/1000,BAR/1000]));
end;
inc(count);
end;
end;