2014年11月10日 星期一

新三價線交易策略 [程式碼]

EasyTrader ArtNo 217
新三價線的定義:
新三價線指標,英文全名為Three Line Break(TLB)。史蒂夫·尼森(Steven Nison)在其《非K線判市法》一書中,將新三值線的概念引入到美國。原理是任意三根持續上漲或下跌K線,所創出短期新高或新低時,會形成紅色或綠色的柱狀體,分別表示買入或賣出信號。由於新三價線在平時盤整時不輕易出現信號,當多空趨勢明顯時,買賣訊號才會產生。但由於反應較慢,容易造成追漲或助跌的效果,所以適合做波段投資指標使用。
它的畫法是這樣子的 : 首先要找出四天來的收盤價, 假設現在趨勢向下, 我們要看今天的收盤價是否比四天前還要高,如果是 ,就在紙上劃上一根陽棒 ,表示趨勢已經翻多了 ,可以建立多單 ,空單也要立即停損出場 。明天如果收紅 ,繼續劃下去 ,如果中間有收黑的日子 ,要看收盤有沒有跌破四天前的開盤價位,如果答案是否定的,一律不管它 ,一路劃下去 , 直到趨勢改變 , 反向劃黑棒為止。

可以看得出 ,這是一種判別中長期多空趨勢的指標 ,屬於中長線投資人使用的技術指標,很適合無暇天天盯著盤勢的上班族來使用 。這個指標的優點是當趨勢很清楚走多或走空時 , 它可以完整的抓到百分之七十以上的波段 , 不怕遺漏。 直到趨勢改變將你帶出場為止。可稱得上是真正的 「懶人操作法」。 但是這個指標有一個缺點, 整理盤時忽多忽空很容易 造成追高殺低的窘態,這也是所有技術指標所面臨的困境。

低檔出現紅三兵,通常是正式起漲的前兆;高檔出現黑三卒,則需留意趨勢的轉變,隨時可能做頭下殺,這是一般K線的理論,但套在簡單的技術指標新三價線上,運用起來則更為貼切。

新三價線公式:
當日收盤價較前日的最高價都還高時→買進訊號
當日收盤價較前日的最低價都還低時→賣出訊號


新三價線指標的優缺點
1、新三價線指標的優點
新三值線的優點是在判斷轉勢時,去除了主觀武斷的感情因素。通過發生的價格的真實狀態,得出了反轉的信號。
2、新三價線指標的缺點
在產生轉值時,新趨勢已經延續了一段時期。不過,許多交易者樂意接受遲緩的信號,以求
跟蹤主要趨勢。

指標程式碼
input:CountL(3),CountS(3) ;
Vars:RevHigh(0),RevLow(0),TrendL(false),TrendS(false) ;

{ 收盤價 > 近三根K棒最高價 且前一根K棒低點為近三根最低點  且前三根K棒收黑}
TrendL = Close > Highest(High,CountL)[1] and Low[1] = Lowest(Low,CountL)[1]
and Countif(Close[1] < Open[1],CountL) = CountL;
if TrendL then RevHigh = Highest(High,CountL)[1] ;

{ 收盤價 < 近三根K棒最低價 且前一根K棒高點為近三根最高點 且前三根K棒收紅}
TrendS = Close < Lowest(Low,CountS)[1] and High[1] = Highest(High,CountS)[1]
and Countif(Close[1] > Open[1],CountS) = CountS;
if TrendS then RevLow = Lowest(Low,CountS)[1] ;

Plot1(RevHigh,"RevHigh") ;
Plot2(RevLow,"RevLow") ;

測試程式碼
input:ExitType(0) ;
input:NBarL(28),NBarS(3),TradeProfit(0.045),TradeStopLoss(0.025),ATRs_L(5.4),ATRs_S(10.9);
vars: IsBalanceDay(False),MP(0),PF(0),PL(0),HLRange(100);

input:CountL(2),CountS(5),EntL(6),EntS(3) ;
Vars:RevHigh(0),RevLow(0),TrendL(false),TrendS(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 ;

TrendL = Close > Highest(High,CountL)[1] and Low[1] = Lowest(Low,CountL)[1]
and Countif(Close[1] < Open[1],CountL) = CountL;
TrendS = Close < Lowest(Low,CountS)[1] and High[1] = Highest(High,CountS)[1]
and Countif(Close[1] > Open[1],CountS) = CountS;

if TrendL then RevHigh = Highest(High,CountL)[1] ;
if TrendS then RevLow = Lowest(Low,CountS)[1] ;

if Close[1] < RevHigh[1] and Close > RevHigh then Buy next bar at Highest(High,EntL) stop ;
if Close[1] > RevLow[1] and Close < RevLow then Sell next bar at Lowest(Low,EntS) stop ;

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 ;
台指期 15 min K 多空留倉 交易週期 2004/8/31~ 2014/8/29 交易成本 1200
台指期 30 min K 多空留倉 交易週期 2004/8/31~ 2014/8/29 交易成本 1200
MagicQS126

沒有留言:

張貼留言