EasyTrader TestNo 036
參考文章 三連發交易策略 Three In a Row
// Public Variable
vars:MP(0),PF(0),PL(0),DayLast(1345),NightLast(0500),BuyPrice(0),ShortPrice(0),BasePF(150),BasePL(100),FilterA(0),FilterB(0) ;
vars:BarPass(5),HLRange(0),WinPoint(0),HBarPos(0),LBarPos(0),ExitH(0),ExitL(0),TimeOK(false),EntryExitCond(false),SelectNo(0) ;
//****************** Basic Setup ****************************************
MP = MarketPosition ;
if MP <> 0 then Begin
PF = EntryPrice*TradeProfit ;
PL = EntryPrice*TradeStopLoss ;
end else begin
PF = AvgPrice*TradeProfit ;
PL = AvgPrice*TradeStopLoss ;
end ;
if Close > 10000 then begin
BasePF = BasePF+IntPortion((Close-10000)/1000)*30 ;
BasePF = MinList(BasePF,450) ;
BasePL = BasePL+IntPortion((Close-10000)/1000)*15 ;
BasePL = MinList(BasePL,225) ;
end ;
PF = MinList(PF,BasePF) ;
PL = MinList(PL,BasePL)*iff(CurrentContracts=1,1,0.67) ;
//計算近週高低點
// ************ for week High/Low box *****************
Vars:WeekLong(5),WeekShort(5),WH(0),WL(0),HLWeek(0),WCount(0),WBox33(0),WBox67(0),WBoxHPB(0),WBoxLPB(0) ;
WH = 近週高點 ;
WL = 近週低點 ;
//判斷多空趨勢
//*********** Trend filter setup
vars:UpTrendNo(1),DnTrendNo(1),UpTrend_High(false),UpTrend_Low(false),DnTrend_High(false),DnTrend_Low(false) ;
vars:Trend4Long(false),Trend4Short(false) ;
UpTrendNo = Mod(LenA1,5)+1 ;
DnTrendNo = Mod(LenB1,5)+1 ;
UpTrend_Low = 多方趨勢 ;
if UpTrendNo = 2 then Trend4Long = UpTrend_Low ;
if BarNumber = 1 then begin
Buy this bar on Close ;
Sell this bar on Close ;
end ;
if DataCompression > 1 then begin
Condition1 = Close > Open and Open > Close[1] ;
Condition2 = Close < Open and Open < Close[1] ;
end else begin
Condition1 = Close > OpenD(0) and OpenD(0) > CloseD(1) ;
Condition2 = Close < OpenD(0) and OpenD(0) < CloseD(1) ;
end;
// ************* Time Set Up *************
TimeOK = ((time >= 0900 and time <= 1200) or (time >= 2130)) ;
// ************* Entry/Exit Condition Set Up *************
EntryExitCond = (EntriesToday(Date)=0 and ExitsToday(Date)=0) ;
//***************** BuyPrice & ShortPrice Setup *****************
BuyPrice = Highest(High,Hbar);
ShortPrice = WL+Range ;
// ********** Main Strategy *********
// ********** Entry Method 只做多
vars:TempLenA(1),TempLenB(1),ThreeLineL(false),ThreeLineS(false) ;
TempLenA = IntPortion(LenA1/2.5) ;
TempLenB = IntPortion(LenB1/2.5) ;
//做多條件
ThreeLineL = Close > Close[TempLenA] and Close[TempLenA] > Close[TempLenA*2] and Close[TempLenA*2] > Close[TempLenA*3] ;
if TimeOK then begin
//做多條件成立 收盤價突破設定價位做多
if MP <> 1 and ThreeLineL and Close < BuyPrice then
Buy ("LE_3Line1T") next bar at BuyPrice stop;
end ;
if EntryExitCond then begin
//做多條件成立 且多方趨勢 且在平盤上 收盤價突破設定價位做多
if MP <> 1 and ThreeLineL and Trend4Long and Condition1 and Close < BuyPrice then
Buy ("LE_3Line9") next bar at BuyPrice stop;
end ;
end ;
//基本停利+移動停損出場
// ************* Base Exit *************
if MP > 0 then Sell ("PL1_"+NumtoStr(PL,0)) next bar at HighSinceEntry-PL stop ;
if MP > 0 then Sell ("PF1_"+NumtoStr(PF,0)) next bar at EntryPrice+PF limit ;
//結算日出場
if _IsSettlementDay and time >= CalcTime(1300,-1*BarInterVal) and Time <= 1330 then begin
if MP > 0 then Sell ("LX_Bal") next bar at market ;
if MP < 0 then BuyToCover ("SX_Bal") next bar at market ;
end;
台指期 留倉 交易週期 2018/1/1 ~ 2022/12/31 交易成本 1200
請問回測有開細部回測嗎?
回覆刪除部落格文章的分享策略邏輯 皆不需要做細部回測 此策略目前也實單上線
回覆刪除