[PEL]  复制代码 
//请单独作为一个后台程序化运行;监控一个品种即可,可以直接监控上证指数;运行模式是固定轮训
if  THOLDCOUNT('')=0 then 
begin 
EXTGBDATASET('maxProfit',-10000000);//账户栏没有持仓的时候,重置全局变量
EXTGBDATASET('isClear',0);//重置清仓的标记
end 
maxProfit:=EXTGBDATA('maxProfit');
if (TACCOUNT( 4)>maxProfit)  and EXTGBDATA('isClear')=0 then EXTGBDATASET('maxProfit',TACCOUNT( 4));//更新最大浮动盈亏
IF (maxProfit-TACCOUNT( 4))/maxProfit>=0.4 THEN EXTGBDATASET('isClear',1);
if ISLASTBAR and EXTGBDATA('isClear')=1 then 
begin 
for i=1 to THOLDCOUNT('') do  //遍历账户持仓品种,进行平仓
begin 
code:=THOLDINDEXLABEL(i,'');//品种代码
tsell(1,0,mkt,0,0,'',code);
tsellshort(1,0,mkt,0,0,'',code);
end 
end  
 
建议理解代码的具体逻辑思路;注意看写的注释说明 |