EasyTrader ArtNo 273
很多研究系統交易的書籍作者們都提及簡單的通道突破策略表現,相較於利用其它的技術指標進場要來的優異,其原因在於股票或商品的牛市莫過於不斷創區間新高,不斷的新低產生代表熊市的來臨。在突破區間高低點當下進場讓交易者,可以參與到每一次市場的趨勢,不過就實務上的經驗來看,並不是每一次的通道新高或新低都能準確的帶來期望中的牛市或熊市的趨勢,本篇介紹一個 [ No Hurry System ]的想法,它的概念是創新高或創新低時不進場,會等候過了幾根K棒後再進場,利用此方式來避免盤整期過度頻繁的進出 交易策略的原始想法是
1. 當 15根K棒前出現 近20根K棒新高時進場作多
2. 當 15根K棒前出現 近20根K棒新低時進場作空
根據這樣的邏輯我們先作一個指標圖方便進出點位的觀察
{系統參數與變數}
input:EntryType(1),ExitType(2);
inputs:NBarL(25),NBarS(45),TradeProfit(0.05),TradeStopLoss(0.035),ATRs_L(0.75),ATRs_S(3.5),ADXLen(25);
vars: IsBalanceDay(False),MP(0),PF(0),PL(0);
inputs: ChanLenA(8),DelayA(21),ChanLenB(41), DelayB(3),AvgL(3),AvgS(5),HighBar(5),LowBar(5);
Vars: UPChanA(0), DnChanA(0),UPChanB(0), DnChanB(0), PositionFlag(0);
Vars: FilterA(false),FilterB(false),FilterC(false),FilterD(false) ;
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 ;
{建立多空不同的通道}
UPChanA = Highest(High, ChanLenA)[DelayA];
DnChanA = Lowest(Low, ChanLenA)[DelayA];
UPChanB = Highest(High, ChanLenB)[DelayB];
DnChanB = Lowest(Low, ChanLenB)[DelayB];
{確認倉位維持狀況}
If MP = 1 Then PositionFlag = 1;
If MP = -1 Then PositionFlag = -1;
{建立 ADX濾網 與 價格濾網作比較 }
FilterA = ADX(ChanLenA) > ADX(ChanLenA)[1] and ADX(ChanLenA) > ADXLen ;
FilterB = ADX(ChanLenB) > ADX(ChanLenB)[1] and ADX(ChanLenB) < ADXLen ;
FilterC = Close < UPChanA ;
FilterD = Close > DnChanB ;
{進場方式 1 ,通道界限突破/跌破 進場 }
if EntryType = 1 then Begin
If PositionFlag <> 1 AND MP <> 1 Then Buy Next Bar at UPChanA + 1 Point Stop;
If PositionFlag <> -1 AND MP <> -1 Then Sell Next Bar at DnChanB - 1 Point Stop;
end;
{ 透過回測的進出點位觀察,我加入以下兩個濾網來協助降低交易次數與提高勝率}
{進場方式 2 ,通道界限突破/跌破 + ADX 濾網 + 價格濾網 進場 }
{價格濾網主要是限制進場前的價格必需在通道內 }
if EntryType = 2 then Begin
If FilterA and PositionFlag <> 1 AND MP <> 1 and FilterC Then Buy Next Bar at UPChanA + 1 Point Stop;
If FilterB and PositionFlag <> -1 AND MP <> -1 and FilterD Then Sell Next Bar at DnChanB - 1 Point Stop;
end;
{ 出場選擇 }
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 or date = 1150224 then setExitonClose ;
if EntryType = 2 then Begin
If FilterA and PositionFlag <> 1 AND MP <> 1 and FilterC Then Buy Next Bar at UPChanA + 1 Point Stop;
If FilterB and PositionFlag <> -1 AND MP <> -1 and FilterD Then Sell Next Bar at DnChanB - 1 Point Stop;
end;
{ 出場選擇 }
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 or date = 1150224 then setExitonClose ;
沒有留言:
張貼留言