- UID
- 2
- 积分
- 2874664
- 威望
- 1387361 布
- 龙e币
- 1487303 刀
- 在线时间
- 13156 小时
- 注册时间
- 2009-12-3
- 最后登录
- 2024-11-24
|
做空代码及结果如下:
- Params
- Numeric swingTrendSwitch(20);
- Numeric swingPrcnt1(0.50);
- Numeric swingPrcnt2(0.75);
- Numeric atrLength(10);
- Numeric bollingerLengths(50);
- Numeric numStdDevs(2);
- Numeric trendLiqLength(50);
- Numeric Lots(0);
- Vars
- NumericSeries cmiVal(0);
- BoolSeries buyEasierDay(False);
- BoolSeries sellEasierDay(False);
- NumericSeries myATR(0);
- NumericSeries MidLine(0);
- Numeric Band(0);
- NumericSeries upBand(0);
- NumericSeries dnBand(0);
- NumericSeries trendLokBuy(0);
- NumericSeries trendLokSell(0);
- NumericSeries keyOfDay(0);
- NumericSeries swingBuyPt(0);
- NumericSeries swingSellPt(0);
- NumericSeries trendBuyPt(0);
- NumericSeries trendSellPt(0);
- NumericSeries swingProtStop(0);
- NumericSeries trendProtStop(0);
- BoolSeries swingEntry(False);
- Begin
- If(!CallAuctionFilter()) Return;
- cmiVal = Abs(Close - Close[29])/(Highest(High,30) - Lowest(Low,30))*100;
- trendLokBuy = Average(Low,3);
- trendLokSell= Average(High,3);
- keyOfDay = (High + Low + Close)/3;
- buyEasierDay = False;
- sellEasierDay = False;
- If(Close[1] > keyOfDay[1]) sellEasierDay = True;
- If(Close[1] <= keyOfDay[1]) buyEasierDay = True;
- myATR = AvgTrueRange(atrLength);
- If(buyEasierDay == True)
- {
- swingBuyPt = Open + swingPrcnt1*myATR[1];
- swingSellPt = Open - swingPrcnt2*myATR[1];
- }
- If(sellEasierDay == True)
- {
- swingBuyPt = Open + swingPrcnt2*myATR[1];
- swingSellPt = Open - swingPrcnt1*myATR[1];
- }
- swingBuyPt = Max(swingBuyPt,trendLokBuy[1]);
- swingSellPt = Min(swingSellPt,trendLokSell[1]);
- MidLine = AverageFC(Close,bollingerLengths);
- Band = StandardDev(Close,bollingerLengths,2);
- upBand = MidLine + numStdDevs*Band;
- dnBand = MidLine - numStdDevs*Band;
- trendBuyPt = upBand;
- trendSellPt = dnBand;
- If(cmiVal[1] < swingTrendSwitch)
- {
- If(MarketPosition != -1 And Low <= swingSellPt)
- {
- SellShort(Lots,Min(Open,swingSellPt));
- swingEntry = True;
- }
- If(MarketPosition == -1 And BarsSinceEntry >= 1 And High >= swingBuyPt)
- {
- BuyToCover(0,Max(Open,swingBuyPt));
- swingEntry = False;
- }
- }
- swingProtStop = 3*myATR;
- trendProtStop = Average(Close,trendLiqLength);
- If(cmiVal[1] >= swingTrendSwitch)
- {
- If(swingEntry == True)
- {
- If(MarketPosition == -1 And BarsSinceEntry >= 1 And High >= (EntryPrice + swingProtStop[1]))
- {
- BuyToCover(0,Max(Open,EntryPrice + swingProtStop[1]));
- swingEntry = False;
- }
- }
- If(swingEntry == False)
- {
- If(MarketPosition != -1 And BarsSinceExit >= 1 And Low <= trendSellPt[1])
- {
- SellShort(Lots,Min(Open,trendSellPt[1]));
- }
- If(MarketPosition == -1 And BarsSinceEntry >= 1 And High >= Min(trendBuyPt[1],trendProtStop[1]))
- {
- BuyToCover(0,Max(Open,Min(trendBuyPt[1],trendProtStop[1])));
- }
- }
- }
- End
复制代码
|
|