以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  请高手改一个策略  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=7825)

--  作者:闪灵
--  发布时间:2011/9/1 16:57:15
--  请高手改一个策略
改成金字塔的... 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编辑过]

--  作者:闪灵
--  发布时间:2011/9/1 17:00:20
--  
晕啊怎么不能换行啊..
--  作者:26327756l
--  发布时间:2011/9/1 17:17:40
--  

我来帮你换行,请使用IE浏览器。

 

 

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:18:16编辑过]

--  作者:fly
--  发布时间:2011/9/2 9:08:55
--  

看不懂.

还不如说出这段代码的思路,看能否实现呢