input: length(25,10,60,1);
input: stdDevUp(2,0.1,4,0.2);
input: stdDevDn(2,0.1,4,0.2);
variable: stdValue=0;
variable: Lots=1;
VARIABLE: isThisBarTrade=0;
isThisBarTrade:=0;
AveMa:=ma(ref(close,1),length);
stdValue:=std(ref(close,1),length);
UpperBand:=Avema + stdDevUp * stdValue;
LowerBand:=AveMa - stdDevDn * stdValue;
buy_cond:=cross(ref(close,1),ref(UpperBand,1));
buyshort_cond:=cross(ref(lowerBand,1),ref(close,1));
sell_cond:=ref(close,1)<ref(AveMa,1);
sellshort_cond:=ref(close,1)>ref(AveMa,1);
Long_EntryPrice:=open+2*MINDIFF;
Short_EntryPrice:=open-2*MINDIFF;
if holding<>1 and buy_cond and not(isThisBarTrade) then begin
buy(1,lots,limitr,Long_EntryPrice);
isThisBarTrade:=1;
end;
else if holding<>-1 and buyshort_cond and not(isThisBarTrade) then begin
buyshort(1,lots,limitr,Short_EntryPrice);
isThisBarTrade:=1;
end;
else if holding=1 and sell_cond and not(isThisBarTrade) then begin
sell(1,lots,limitr,Short_EntryPrice);
end;
else if holding=-1 and sellshort_cond and not(isThisBarTrade) then begin
sellshort(1,lots,limitr,Long_EntryPrice);
end;
资产:ASSET,NOAXIS;
可用现金:CASH(0),LINETHICK0;
持仓:HOLDING,LINETHICK0;