多品种中,如将持仓计数作为全局变量,不同的品种可能有不同的数值。而工具-数值-全局变量中对应名称的只有一个。如何在各个品种中区分?(监控中debugout查询?)
里面部分内容没能理解确认,求教 input:account(888888,1,999999,1);
runmode:0;
begintime:=currenttime>=091500 and currenttime<=145500;
endtime:=currenttime>=145930;
buycond:=begintime;
sellcond:=begintime;
myaccount:=''+account;
//“+account前的双引号及加号有什么特别意义?mycash:=taccount2(19,myaccount);
myholding:=extgbdata(myaccount+'_'+formulaname+'_'+datatype+'_'+stklabel+'_holding');
// 这句括号里的加号是字符?还是整个都是字符串? slippage:=2*mindiff;
if myholding=0 then begin
if buycond then begin
buyprice:=close+slippage;
lots:=intpart(mycash/(buyprice*multiplier*taccount(41)));
if lots>=1 then begin
tbuy(1,lots,lmt,buyprice,0,myaccount,0);
extgbdataset(myaccount+'_'+formulaname+'_'+datatype+'_'+stklabel+'_holding',lots);
end
end
end
if myholding=0 then begin
if sellcond then begin
sellprice:=close-slippage;
lots:=intpart(mycash/(sellprice*multiplier*taccount(42)));
if lots>=1 then begin
tbuyshort(1,lots,lmt,sellprice,0,myaccount,0);
extgbdataset(myaccount+'_'+formulaname+'_'+datatype+'_'+stklabel+'_holding',-lots);
end
end
end
if myholding>0 then begin
if endtime then begin
tsell(1,myholding,lmt,close-slippage,myaccount,0);
extgbdataset(myaccount+'_'+formulaname+'_'+datatype+'_'+stklabel+'_holding',0);
end
end
if myholding<0 then begin
if endtime then begin
tsellshort(1,myholding,lmt,close+slippage,myaccount,0);
extgbdataset(myaccount+'_'+formulaname+'_'+datatype+'_'+stklabel+'_holding',0);
end
end
myaccount:=''+account; //“+account前的双引号及加号有什么特别意义?
这句引号估计是书写错误或者引号里的东西楼主省略了
myholding:=extgbdata(myaccount+'_'+formulaname+'_'+datatype+'_'+stklabel+'_holding'); // 这句括号里的加号是字符?还是整个都是字符串?
这句加号起的作用是把几个函数组成一个字符串,然后利用这个字符串来取全局变量的值,这么一长串其实就是extgbdata函数中的参数S,最终得到的myholding是数字
那么myholding括号中的部分只能是用来自己区分某一变量,对应某一公式的某一周期的某一品种。
在工具-数据-全局变量 中,似乎还是不能区分出来。
尝试了后台多个品种运行,用全局变量做持仓计数。发现始终处于混乱情况。一直查不明原因。怀疑品种间可能存在串用同一变量导致
继续求教主题帖问题
不知道楼主是想达到什么目的.
(1)想要知道一个策略在一个品种上是否有开仓,在对应该品种开仓后的相应的位置上,把对应的全局变量赋值予以标识就可以了.
(2)想要对一个品种的持仓进行统计,可用TBUYHOLDINGEX和TSELLHOLDINGEX这两个函数.