以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  交易策略发布专区  (http://weistock.com/bbs/list.asp?boardid=10)
----  [技术指标]品种选择  (http://weistock.com/bbs/dispbbs.asp?boardid=10&id=9233)

--  作者:z7c9
--  发布时间:2011/12/4 21:38:34
--  [技术指标]品种选择

runmode:0;

length:=20;

bkname:=\'连续合约\';

stks:=stkcount(bkname);

variable:stknames[stks]=0;
variable:stktrades[stks]=0;
variable:stkposes[stks]=0;
variable:mypos=0;
variable:cantrade=0;

if date>ref(date,1) then begin 
 length:=20;
 
 for i=1 to stks do begin
  stkcode:=stkfromblk(bkname,i);
  
  stknames[i]:=strremove(stkcode,0,2);
  
  stktrades[i]:=0;

  for j=1 to length do begin
   myamount:=callstock(stknames[i],vtamount,6,-j);  
   
   if myamount then
    myamount:=myamount;
   else
    myamount:=0;     
     
   stktrades[i]:=stktrades[i]+myamount;
  end
  
  stktrades[i]:=stktrades[i]/length;
  
  stkposes[i]:=i;   
 end
 
 for i=1 to stks do begin
  for j=1 to stks-i do begin
   if stktrades[j]<stktrades[j+1] then begin
    t1:=stktrades[j];
    stktrades[j]:=stktrades[j+1];
    stktrades[j+1]:=t1;
    t2:=stkposes[j];
    stkposes[j]:=stkposes[j+1];
    stkposes[j+1]:=t2;
   end
  end 
 end
 
 for i=1 to stks do begin
   if stricmp(stklabel,stknames[stkposes[i]])=0 then begin
      mypos:=i;
   end
 end 
end

可交易:mypos,linethick0;

 


--  作者:z7c9
--  发布时间:2011/12/5 21:33:00
--  

runmode:0;

formula:=\'Dts1a.收益风险比(1,0)\';
cycle:=2;

bkname:=\'连续合约\';
stks:=stkcount(bkname);

variable:stknames[stks]=\'\';
variable:stktrades[stks]=0;
variable:stkposes[stks]=0;

for i=1 to stks do begin
 stkcode:=stkfromblk(bkname,i);
 stknames[i]:=strremove(stkcode,0,2); 
 stktrades[i]:=stkindi(stknames[i],formula,0,cycle,0);
 stkposes[i]:=i;
end

if islastbar then begin
 for i=1 to stks do begin
  for j=1 to stks-i do begin
   if stktrades[j]<stktrades[j+1] then begin
    t1:=stktrades[j];
    stktrades[j]:=stktrades[j+1];
    stktrades[j+1]:=t1;
    t2:=stkposes[j];
    stkposes[j]:=stkposes[j+1];
    stkposes[j+1]:=t2;
   end
  end 
 end
 
 for i=1 to stks do begin
  mystr:=stknames[stkposes[i]];
  mystkname:=strleft(mystr,strlen(mystr)-2);
  msgout(1,mystkname+\' : \'+numtostr(stktrades[i],2));
 end
end

 


--  作者:伍星亮
--  发布时间:2011/12/16 14:01:02
--  

能不能简要说说怎么用?