著名的海龟交易法则-easylanguge编写

来源:百度文库 编辑:神马文学网 时间:2024/04/28 09:01:32

著名的海龟交易法则-easylanguge编写

(2010-07-23 10:43:52) 

海龟交易法则细则

一、市场----买卖什么

•中国金融交易所-沪深300期指

•上海交易所-铜、橡胶、螺纹钢

•大连交易所-豆油、塑料

 

二、市场规模----买卖多少

•N表示某个特定市场根本的波动率

•N=(19×PDN+TR)/20

 

TR=max(H-L,H-PDC,PDC-L)

H-当日最高价

L-当日最低价

PDC-前个交易日的收盘价

•单位=帐户的1%/市场价值量波动率或单位=帐户的1%/(N×每点价值量)

 

三、进场----何时买

•系统1

突破20日高点买进

跌破20日低点卖出

•系统2

 

突破55日高点买进

跌破55日低点卖出

资金配置:系统1 (50%),系统2(50%)

 

四、停损----何时退出亏损的部位

•停损1-2N停损法

买进部位以最后成交价-2n为停损点

卖出部位以最后成交价+2n为停损点

•停损2-1/2N停损法 

买进部位以最后成交价-1/2n为停损点

卖出部位以最后成交价+1/2n为停损点

 

五、出场----何时退出获利的部位

•系统一出场对于多头部位为10日最低价,对于空头部位为10日最高价。如果价格波动与部位背离至10日突破,部位中的所有单位都会退出。系统二出场对于多头部位为20日最低价,对于空头部位为20日最高价。如果价格波动与部位背离至20日突破,部位中的所有单位都会退出。

 

/// Turtle 20-Day Breakout

Replica //////////////////////////////////////

vars: N(0),StopLoss(1),DV(0),BB(0),AccountBalance(0),DollarRisk(0),LTT(0),

Tracker(0),LastTrade(0),HBP(0),LBP(0); input: InitialBalance(1000000),Length(20);

if marketposition = 0 then begin
BB = 0;
N = xAverage( TrueRange, Length );
DV = N * BigPointValue;
AccountBalance = InitialBalance;
DollarRisk = AccountBalance * .01;
LTT = IntPortion(DollarRisk/DV);
StopLoss = 2 * DV * LTT;

if LastTrade = -1 then begin
buy LTT shares next bar highest(h,20) or higher;
buy LTT shares next bar highest(h,20) + (0.5*N) or higher;
buy LTT shares next bar highest(h,20) + (1.0*N) or higher;
buy LTT shares next bar highest(h,20) + (1.5*N) or higher;
sellshort LTT shares next bar lowest(l,20) or lower;
sellshort LTT shares next bar lowest(l,20) - (0.5*N) or lower;
sellshort LTT shares next bar lowest(l,20) - (1.0*N) or lower;
sellshort LTT shares next bar lowest(l,20) - (1.5*N) or lower;
end;

if LastTrade = 1 then begin
buy LTT shares next bar highest(h,55) or higher;
buy LTT shares next bar highest(h,55) + (0.5*N) or higher;
buy LTT shares next bar highest(h,55) + (1.0*N) or higher;
buy LTT shares next bar highest(h,55) + (1.5*N) or higher;
sellshort LTT shares next bar lowest(l,55) or lower;
sellshort LTT shares next bar lowest(l,55) - (0.5*N) or lower;
sellshort LTT shares next bar lowest(l,55) - (1.0*N) or lower;
sellshort LTT shares next bar lowest(l,55) - (1.5*N) or lower;
end;

end;

// PREVIOUS TRADE TRACKER
if HBP = 0 and h > highest(h,19)[1] then begin
Tracker = 1; HBP = h; LBP = 0;
end;

if LBP = 0 and l < lowest(l,19)[1] then begin
Tracker = -1; LBP = l; HBP = 0;
end;

if Tracker = 1 then begin
if l < HBP - (2*N) then LastTrade = -1;
if h > HBP + (4*N) then LastTrade = 1;
end;

if Tracker = -1 then begin
if h > LBP + (2*N) then LastTrade = -1;
if l < LBP - (4*N) then LastTrade = 1;
end;

// LONG 20
if LastTrade = -1 and marketposition = 1 then begin
BB = BB + 1;
if currentshares = LTT then begin
buy LTT shares next bar highest(h,20)[BB] + (0.5*N) or higher;
buy LTT shares next bar highest(h,20)[BB] + (1.0*N) or higher;
buy LTT shares next bar highest(h,20)[BB]+ (1.5*N) or higher;
end;

if currentshares = LTT * 2 then begin
buy LTT shares next bar highest(h,20)[BB] + (1.0*N) or higher;
buy LTT shares next bar highest(h,20)[BB] + (1.5*N) or higher;
end;

if currentshares = LTT * 3 then
buy LTT shares next bar highest(h,20)[BB] + (1.5*N) or higher;
end;

// LONG 55
if LastTrade = 1 and marketposition = 1 then begin
BB = BB + 1;
if currentshares = LTT then begin
buy LTT shares next bar highest(h,55)[BB] + (0.5*N) or higher;
buy LTT shares next bar highest(h,55)[BB] + (1.0*N) or higher;
buy LTT shares next bar highest(h,55)[BB]+ (1.5*N) or higher;
end;
if currentshares = LTT * 2 then begin
buy LTT shares next bar highest(h,55)[BB] + (1.0*N) or higher;
buy LTT shares next bar highest(h,55)[BB] + (1.5*N) or higher;
end;
if currentshares = LTT * 3 then
buy LTT shares next bar highest(h,55)[BB] + (1.5*N) or higher;
end;
sell ("out-S") next bar lowest(l,10) or lower;

// SHORT 20
if LastTrade = -1 and marketposition = -1 then begin
BB = BB + 1;
if currentshares = LTT then begin
sellshort LTT shares next bar lowest(l,20)[BB] - (0.5*N) or lower;
sellshort LTT shares next bar lowest(l,20)[BB] - (1.0*N) or lower;
sellshort LTT shares next bar lowest(l,20)[BB] - (1.5*N) or lower;
end;
if currentshares = LTT * 2 then begin
sellshort LTT shares next bar lowest(l,20)[BB] - (1.0*N) or lower;
sellshort LTT shares next bar lowest(l,20)[BB] - (1.5*N) or lower;
end;
if currentshares = LTT * 3 then
sellshort LTT shares next bar lowest(l,20)[BB] - (1.5*N) or lower;
end;

// SHORT 55
if LastTrade = 1 and marketposition = -1 then begin
BB = BB + 1;
if currentshares = LTT then begin
sellshort LTT shares next bar lowest(l,55)[BB] - (0.5*N) or lower;
sellshort LTT shares next bar lowest(l,55)[BB] - (1.0*N) or lower;
sellshort LTT shares next bar lowest(l,55)[BB] - (1.5*N) or lower;
end;
if currentshares = LTT * 2 then begin
sellshort LTT shares next bar lowest(l,55)[BB] - (1.0*N) or lower;
sellshort LTT shares next bar lowest(l,55)[BB] - (1.5*N) or lower;
end;
if currentshares = LTT * 3 then
sellshort LTT shares next bar lowest(l,55)[BB] - (1.5*N) or lower;
end;
buytocover ("out-B") next bar highest(h,10) or higher;

// STOPS
if currentshares = (2 * LTT) then StopLoss = DV * 3.5 * LTT;
if currentshares = (3 * LTT) then StopLoss = DV * 4.5 * LTT;
if currentshares = (4 * LTT) then StopLoss = DV * 5.0 * LTT;
setstoploss (StopLoss);

// COMMENTARY
commentary ("LTT: ",LTT,Newline);
commentary ("CurrentShares: ",CurrentShares,Newline);
commentary ("StopLoss: ",StopLoss,Newline);
commentary ("AccountBalance:",AccountBalance,NewLine);
commentary ("LastTrade: ",LastTrade,NewLine);