[PEL] 复制代码 AVGLENGTH:=10;
ATRLENGTH:=20;
MOVAVGVAL:MA((HIGH+LOW+CLOSE)/3,AVGLENGTH);//三价均线
TRUEHIGH1:=IF(HIGH>REF(C,1),HIGH,REF(C,1));
TRUELOW1:=IF(LOW<=REF(C,1),LOW,REF(C,1));
TRUERANGE1:=IF(ISLASTBAR,H-L,TRUEHIGH1-TRUELOW1);
UPBAND:MOVAVGVAL+MA(TRUERANGE1,ATRLENGTH);
DNBAND:MOVAVGVAL-MA(TRUERANGE1,ATRLENGTH);//通道上下轨
LIQUIDPOINT:=MOVAVGVAL;//出场条件
//C<LIQUIDPOINT,SP;//持有多单时,价格下破三价均线,平多单
if C<LIQUIDPOINT and HOLDING>0 then BEGIN
sell(1,1,MARKET);
end
//C>LIQUIDPOINT,BP;//持有空单时,价格上破三价均线,平空单
if C>LIQUIDPOINT and HOLDING<0 then BEGIN
sellshort(1,1,MARKET);
end
//MOVAVGVAL>REF(MOVAVGVAL,1)&&C>UPBAND,BK;//三价均线向上,并且价格上破通道上轨,开多单
if MOVAVGVAL>REF(MOVAVGVAL,1)&&C>UPBAND and HOLDING=0 then BEGIN
buy(1,1,MARKET);
end
//MOVAVGVAL<REF(MOVAVGVAL,1)&&C<DNBAND,SK;//三价均线向下,并且价格下破通道下轨,开空单
if MOVAVGVAL<REF(MOVAVGVAL,1)&&C<DNBAND and HOLDING=0 then BEGIN
buyshort(1,1,MARKET);
end
|