EasyTrader ArtNo 112
黃金分割率經常被分析師做為分析和預測的工具,只要充分理解了黃金分割理論的含義,探索出一套巧妙的運用方法,你總可以先人一 步走在前面。黃金分割法能為投資者預先估計強勢股的調整過程中的支撐位,以及弱勢股在反彈過程中的壓力位。黃金分割有三條線:0.382、0.5、0.618。黃金分割運用的要點:
一、分割計算以一波行情的底到頂做為區間。不同區間反映的結果表達不同級別的行情。
二、一波上升行情,如果回檔到強勢區間調整並站穩,就會繼續上升,目標是再出新高,但高點將受趨勢線壓制。 強勢區的站穩是指走出一個整理形態,在這個整理形態完成時不破位為準。
三、一波上升行情,如果下跌到強勢區間以下整理,則繼續下跌的機會較大,因為,在強勢區位下方整理時,已經轉向並壓制著價格了。此時下跌目標看下面的弱勢位。通常弱勢位已接近上升軌的底邊,是保持上升的極限。如果在這個位置都站不住繼續下探的話,則行情就會轉向了。弱勢位的站穩通常是圓底或平臺,一般是無量盤過壓力位。有量而不能站在弱勢區上則顯示走勢更弱。
四、回檔的中位在短線行情中多數為探針觸及,很少停留,操作意義不大。而在大週期的形態中可以做為強勢調整位的參考位。
讀者所熟悉的都是在K線圖上透過軟體去畫黃金分割線,觀察商品價格運動中的支撐與壓力所在,或是對趨勢的頂/底滿足點作一個預測,不過這一篇我們要來個腦筋急轉彎-是對技術指標中常見的RSI 作黃金分割,看看能否有不同的發現
主要核心邏輯為將RSI值在過去一段期間內的最大值與最小值區間作黃金比例分割,再找出合適的進場參考線
測試程式碼
inputs: EntryType(1),ExitType(1),RSILength(14),LookbackLength(40),HB(70),LB(30),TradeProfit(0.05),TradeStopLoss(0.03),NBarL(2),NBarS(2);
input: BarNo(3),UpRatio(10),DnRatio(10),FastLen(5),SlowLen(21),AvgLen(9),SHB(1),SLB(1),K1(0.7);
input:HighBand(90),LowBand(10),UpBand(80),DnBand(20);
vars:RawRSI(0),RangeHigh(0),RangeLow(0),ChartRange(0),FibUp(0),FibDn(0);
vars: IsBalanceDay(False),MP(0),PF(0),PL(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 ;
RawRSI= RSI( Close, RSILength ) ;
if BarNumber > LookbackLength then begin
RangeHigh = Highest( RawRSI,LookbackLength ) ;
RangeLow = Lowest( RawRSI, LookbackLength ) ;
ChartRange = RangeHigh - RangeLow ;
FibUp = HB / 100 * ChartRange + RangeLow ;
FibDn = LB / 100 * ChartRange + RangeLow ;
end ;
if EntryType = 1 then Begin
if RawRSI < FibUp then Buy next bar at Highest(High,BarNo) stop ;
if RawRSI > FibDn then Sell next bar at Lowest(Low,BarNo) stop ;
end;
if EntryType = 2 then Begin
if RawRSI > FibUp then Buy next bar at Highest(High,BarNo) stop ;
if RawRSI < FibDn then Sell next bar at Lowest(Low,BarNo) stop ;
end;
if EntryType = 3 then Begin
if RawRSI Cross over FibUp then Buy next bar at Market ;
if RawRSI Cross under FibDn then Sell next bar at Market ;
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 then setExitonClose ;
基本設定 台指期 留倉策略 回測週期 2004/1~2013/12/31 交易成本 1200
A.基本策略(上下限區間內,突破 N根 Bar 進場)
績效表現看起來還是不錯的,
B.基本策略+如意多空網 (上下限區間內,突破 N根 Bar 進場)
測試程式碼
inputs: EntryType(1),ExitType(1),RSILength(14),LookbackLength(40),HB(70),LB(30),TradeProfit(0.05),TradeStopLoss(0.03),NBarL(2),NBarS(2);
input: BarNo(3),UpRatio(10),DnRatio(10),FastLen(5),SlowLen(21),AvgLen(9),SHB(1),SLB(1),K1(0.7);
input:HighBand(90),LowBand(10),UpBand(80),DnBand(20);
vars:RawRSI(0),RangeHigh(0),RangeLow(0),ChartRange(0),FibUp(0),FibDn(0);
vars: IsBalanceDay(False),MP(0),PF(0),PL(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 ;
RawRSI= RSI( Close, RSILength ) ;
if BarNumber > LookbackLength then begin
RangeHigh = Highest( RawRSI,LookbackLength ) ;
RangeLow = Lowest( RawRSI, LookbackLength ) ;
ChartRange = RangeHigh - RangeLow ;
FibUp = HB / 100 * ChartRange + RangeLow ;
FibDn = LB / 100 * ChartRange + RangeLow ;
end ;
if EntryType = 1 then Begin
if RawRSI < FibUp then Buy next bar at Highest(High,BarNo) stop ;
if RawRSI > FibDn then Sell next bar at Lowest(Low,BarNo) stop ;
end;
if EntryType = 2 then Begin
if RawRSI > FibUp then Buy next bar at Highest(High,BarNo) stop ;
if RawRSI < FibDn then Sell next bar at Lowest(Low,BarNo) stop ;
end;
if EntryType = 3 then Begin
if RawRSI Cross over FibUp then Buy next bar at Market ;
if RawRSI Cross under FibDn then Sell next bar at Market ;
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 then setExitonClose ;
基本設定 台指期 留倉策略 回測週期 2004/1~2013/12/31 交易成本 1200
A.基本策略(上下限區間內,突破 N根 Bar 進場)
績效表現看起來還是不錯的,
B.基本策略+如意多空網 (上下限區間內,突破 N根 Bar 進場)
MagicQS041
沒有留言:
張貼留言