| 

 等级: 新手上路 
注册: 2021-9-6曾用名:  | 
| //可交易最大手数,总资金3.6%- -100W TN :=MAX (1, MIN(TN1, TN2) ) ;
 unit:(50000*0.01)/(MULTIPLIER*atr);
 ma30:ma(c,30);
 ma450:ma(c,450);
 t1:=ma(c,30);
 t2:=hhv(h,30);
 t3:=llv(l,30);
 t4:=(t2-t1)/t1;
 t5:=(t1-t3)/t1;
 t6:=ref(t4,1)>0.03;
 t7:=ref(t5,1)>0.03;
 gl:=t6 and t7;
 CYC:=ENTERBARS+1,NOAXIS;//开仓至今的周期数
 出场MA:MA(CLOSE,IF(HOLDING<>0,IF(CYC>=40,10,41-CYC),30));
 
 //记录建仓的atr
 variable:entry=0;
 
 //入场条件:
 开多条件:=c>ma30 and c>ma450 ;
 开空条件:=c<ma30 and c<ma450 ;
 平多条件:=C<MA30 or c<出场MA ;
 平空条件:=c>MA30 or c>出场MA;
 //建立头寸
 if 开多条件 and holding=0 then
 begin
 buy(1,1,marketr);
 entry:=atr;
 end
 
 if 开空条件 and holding=0 then
 begin
 buyshort(1,1,marketr);
 entry:=atr;
 end
 
 if 平多条件 and holding>0 then
 begin
 SELL(1, holding,marketr);
 
 end
 
 if 平空条件 and holding<0 then
 begin
 SELLSHORT(1, holding,marketr);
 
 end
 
 
 
 
 
 
 
 当前持仓:HOLDING,COLORGRAY,LINETHICK0;
 当前资产:ASSET,NOAXIS,COLORGRAY;//输出当前资产,但不影响坐标最高最低值
 | 
 |