2014年3月10日 星期一

抄底逃頂系統 [程式碼]

EasyTrader ArtNo 119
最近看到 Wen大介紹 底部釣魚系統 , 想到自己有看過的抄底逃頂系統的概念相接近,因此將它轉化為策略程式,並作了幾個商品的測試


inputs: EntryType(1),ExitType(2),BarNo(6),UpRatio(1),DnRatio(1),HB(1),LB(1),TradeProfit(0.05),TradeStopLoss(0.045),NBarL(18),NBarS(18);
input: FastLen(5),SlowLen(15),AvgLen(9),SHB(1),SLB(1),K1(0.7);
input:HighBand(90),LowBand(10),UpBand(80),DnBand(20);
vars: IsBalanceDay(False),MP(0),PF(0),PL(0),UBuy(0),BuyStop(0),USell(0),SellStop(0),movAvg(0);

MP = MarketPosition ;

if DAYofMonth(Date) > 14 and DAYofMonth(Date) < 22 and DAYofWeek(Date)= 3 then isBalanceDay = True else isBalanceDay =False ;

PF = AvgPrice*TradeProfit ;
PL = AvgPrice*TradeStopLoss ;

Condition1 = Lowest(Low,FastLen) <= Lowest(Low,SlowLen);
Condition2 = (High-Low) > AvgPrice * UpRatio/100 ;
Condition3 = Close > Open and (Close-Open) > AvgPrice * DnRatio/100 ;
Condition4 = Highest(High,FastLen) >= Highest(High,SlowLen);
Condition5 = (High-Low) > AvgPrice * UpRatio/100 ;
Condition6 = Close < Open and (Open -Close) > AvgPrice * DnRatio/100 ;

if Condition1[1] and condition2[1] and Condition3[1] then Buy ("B2") this bar on close ;
if Condition4[1] and condition5[1] and Condition6[1] then Sell ("S2") this bar on close ;

if ExitType = 1 then SetStopLoss(PL * BigPointValue) ;

if ExitType = 2 then Begin
   SetStopLoss(PL * BigPointValue) ;
   SetProfitTarget(PF * BigPointValue) ;
end;

if ExitType = 3 then Begin
   if MP > 0 and BarsSinceEntry = NBarL then ExitLong next bar at Market ;
   if MP < 0 and BarsSinceEntry = NBarS then ExitShort next bar at Market ;
end;

if ExitType = 4 then Begin
   SetStopLoss(PL * BigPointValue) ;
   SetProfitTarget(PF * BigPointValue) ;
   if MP > 0 and BarsSinceEntry = NBarL then Sell {ExitLong} next bar at Market ;
   if MP < 0 and BarsSinceEntry = NBarS then Buy {ExitShort} next bar at Market ;
end;

{
if IsBalanceDay then setExitonClose ;
}





台指期



S&P 500



恆生期



黃金(美元)



蠻不錯的核心策略元素
MagicQS017

沒有留言:

張貼留言