1.需要监控到实际持仓的品种
2.如果中间暂停,那么中间暂停时候 数据是无法更新到的
3.可以在数据关联-全局变量中查看记录的数值
[PEL] 复制代码
as:extgbdata(taccount( 1));//记录资产的全局变量
dt:extgbdata(taccount( 1)+'_date');//记录数据更新日期的全局变量
isclear:extgbdata(taccount( 1)+'_isclear');//标记是否应该清仓的全局变量
if tholdcount('')=0 then //如果没有持仓了,清空掉之前的数据
begin
extgbdataset(taccount( 1),0);
extgbdataset(taccount( 1)+'_date',date);//记录数据更新的日期
extgbdataset(taccount( 1)+'_isclear',0); //隔日后清仓标记也重置掉
end
//更新到最新日期的数据,用来处理隔日的问题
if date>dt and tholdcount('')>0 then
begin
extgbdataset(taccount( 1),taccount( 6));
extgbdataset(taccount( 1)+'_date',date);//记录数据更新的日期
extgbdataset(taccount( 1)+'_isclear',0); //隔日后清仓标记也重置掉
end
//始终记录最大的动态权益
if tholdcount('')>0 and taccount( 6)>as and isclear=0 then
begin
extgbdataset(taccount( 1),taccount( 6));
extgbdataset(taccount( 1)+'_date',date);//记录数据更新的日期
end
as:=extgbdata(taccount( 1));
if as/taccount( 6)>=1.01 and tholdcount('')>0 and isclear=0 then
begin
extgbdataset(taccount( 1)+'_isclear',1);
end
isclear:=extgbdata(taccount( 1)+'_isclear');//标记是否应该清仓的全局变量
if isclear and tbuyholdingex('','',1)>0 then tsell(1,0,mkt);//每次只能平当前品种,所以必须监控账户栏实际持仓才能全平 |