写过证券交易的K线图的DFW快来(100分)

  • 主题发起人 主题发起人 suns
  • 开始时间 开始时间
S

suns

Unregistered / Unconfirmed
GUEST, unregistred user!
在国企上班的好处是没有项目就快活似神仙,可一到有项目作时
就雾里看花拉呀,这不上面要一个自动控制和监视系统,让我欢喜
让我忧,喜在好久没练手拉,忧时遇到些问题,我想将监视系统用
图形方式显示出来,就想证券交易的K线图一样,可我不太了解这个
K线图是如何实现出来的,我以前听一个网友说主要根据成交量算出
来得一些数据,然后定位坐标然后lineto(x,y)就可以,现在我找不
到他人,我也没写过,所以求教于各位DFW,你们写过这方面的东东吗?
贴贴你们手头的资料,或谈谈你们的想法或看法好吗?总之有代码
的贴代码,有想法的贴想法,让我早些完成回家好过年呀
 
http://delphi.mychangshu.com
有个。
 
我一看到过,但数据咋办,我不想用CHAT 我要在桌面的画布上实现,有招吗?
 
可以,自己画,有点烦。我作过的一个,但是只是用美国线,不是用K线。

datarec=record
openp,highp,lowp,closep:integer;
date:string;
openinterest,volum:integer;
end;

dataarray=array of datarec;//数据记录动态数组

datafile=text;
var
Form1: TForm1;
data:dataarray;
dataf:datafile;
hvolum:integer;
wmf,wmfvolum:tmetafile;
wmfcanvas,wmfvolumcanvas:tmetafilecanvas;
i: integer;
hightest,lowest:integer;

。。。。

procedure TForm1.FormCreate(Sender: TObject);
var
j,intdate,l:integer;
begin
hightest:=0;
lowest:=9999;
hvolum:=0;
if opendialog1.execute then
begin
assignfile(dataf,opendialog1.FileName);
reset(dataf);
l:=150;
setlength(data,l);
try
while not eof(dataf) do
begin
readln(dataf,intdate,data.openp,data.highp,data.lowp,
data.closep,data.volum);
data.date:=inttostr(intdate);
if data.highp>hightest then hightest:=data.highp;
if data.lowp<lowest then lowest:=data.lowp;
if data.volum>hvolum then hvolum:=data.volum;
inc(i);
if i=l then begin l:=l+50; setlength(data,l);end;
end;
finally
closefile(dataf);
end;//end of try...finally
end;// end of if .... then

wmf:=tmetafile.Create;
wmf.Enhanced:=true;
wmf.height:=hightest-lowest+20;
wmf.Width:=4*i+20;
wmfvolum:=tmetafile.Create;
wmfvolum.Enhanced:=true;
wmfvolum.Height:=round(hvolum/1000)+10;
wmfvolum.width:=wmf.Width;
wmfcanvas:=tmetafilecanvas.create(wmf,0);
wmfcanvas.pen.style:=pssolid;
wmfvolumcanvas:=tmetafilecanvas.create(wmfvolum,0);
wmfvolumcanvas.pen.Color:=clred;
try
for j:=0 to i do
begin
if data[j].openp>data[j].closeP then wmfcanvas.pen.Color:=clblue;
if data[j].openp<data[j].closeP then wmfcanvas.pen.Color:=clred;
if data[j].openp=data[j].closeP then wmfcanvas.pen.Color:=clblack;
wmfcanvas.moveto(2+4*j,hightest-data[j].openp+10);
wmfcanvas.lineto(2+4*j+2,hightest-data[j].openp+10);
wmfcanvas.moveto(2+4*j+1,hightest-data[j].lowp+10);
wmfcanvas.lineto(2+4*j+1,hightest-data[j].highp+10);
wmfcanvas.moveto(2+4*j+1,hightest-data[j].closep+10);
wmfcanvas.lineto(2+4*j+3,hightest-data[j].closep+10);//draw kline
//*****
wmfvolumcanvas.moveto(2+4*j+1,round(hvolum/1000)+10);
wmfvolumcanvas.LineTo(2+4*j+1,round(hvolum/1000)+10-round(data[j].volum/1000));//draw volum
end
finally
wmfcanvas.free;
wmfvolumcanvas.free;
end;//end of try..finally
if wmf.Width<paintbox1.Width then
paintbox1.canvas.stretchdraw(rect(1,1,4*i+20,paintbox1.Height),wmf)
else
paintbox1.canvas.stretchdraw(rect(1,1,paintbox1.width,paintbox1.Height),wmf);
if wmfvolum.Width<paintbox2.Width then
paintbox2.canvas.StretchDraw(rect(1,1,wmfvolum.width,paintbox2.height),wmfvolum)
else
paintbox2.canvas.stretchdraw(rect(1,1,paintbox2.width,paintbox2.height),wmfvolum);
end;//end of procedure
 
后退
顶部