改成金字塔的...
Inputs: bollingerLengths(50),trendLiqLength(50),numStdDevs(2),
swingPrcnt1(0.50),swingPrcnt2(0.75),atrLength(10),
swingTrendSwitch(20);
Vars:cmiVal(0),buyEasierDay(0),sellEasierDay(0),trendLokBuy(0),
trendLokSell(0),keyOfDay(0),swingBuyPt(0),swingSellPt(0),
trendBuyPt(0),trendSellPt(0),swingProtStop(0);
cmiVal = ChoppyMarketIndex(30);
buyEasierDay = 0;
sellEasierDay = 0;
trendLokBuy = Average(Low,3);
trendLokSell= Average(High,3);
keyOfDay = (High + Low + Close)/3;
if(Close > keyOfDay) then sellEasierDay = 1;
if(Close <= keyOfDay) then buyEasierDay = 1;
if(buyEasierDay = 1) then
begin
swingBuyPt = Open of tomorrow + swingPrcnt1*AvgTrueRange(atrLength);
swingSellPt = Open of tomorrow - swingPrcnt2*AvgTrueRange(atrLength);
end;
if(sellEasierDay = 1) then
begin
swingBuyPt = Open of tomorrow + swingPrcnt2*AvgTrueRange(atrLength);
swingSellPt = Open of tomorrow - swingPrcnt1*AvgTrueRange(atrLength);
end;
swingBuyPt = MaxList(swingBuyPt,trendLokBuy);
swingSellPt = MinList(swingSellPt,trendLokSell);
trendBuyPt = BollingerBand(Close,bollingerLengths,numStdDevs);
trendSellPt = BollingerBand(Close,bollingerLengths,- numStdDevs);
if(cmiVal < swingTrendSwitch)then
begin
if (MarketPosition <> 1) then Buy("SwingBuy") next bar at swingBuyPt
stop;
if(MarketPosition <> -1) then SellShort("SwingSell") next bar at
swingSellPt stop;
end
else
begin
swingProtStop = 3*AvgTrueRange(atrLength);
Buy("TrendBuy") next bar at trendBuyPt stop;
SellShort("TrendSell") next bar at trendSellPt stop;
Sell from Entry("TrendBuy") next bar at Average(Close,trendLiqLength)
stop;
BuyToCover from Entry("TrendSell") next bar at
Average(Close,trendLiqLength) stop;
Sell from Entry("SwingBuy") next bar at EntryPrice - swingProtStop
stop;
BuyToCover from Entry("SwingSell") next bar at EntryPrice +
swingProtStop stop;
end;
[此贴子已经被作者于2011-9-1 17:00:03编辑过]