2015年3月9日 星期一

萬用擺盪指標 Universal Oscillator

EasyTrader ArtNo 251
John Ehlers 在 "Technical Analysis of STOCKS & COMMODITIES " 近期雜誌中發表了的一個萬用擺盪指標 Universal Oscillator ,裡面仍是運用了他所擅長的數學運算來作價格的平滑化處理 (SuperSmoother Filter)

_Ehlers_Universal Oscillator (Indicator)
// Universal Oscillator
// (c) 2014 John F. Ehlers
// TASC January 2015
inputs:BandEdge( 20 ) ;
variables:WhiteNoise( 0 ),a1( 0 ),b1( 0 ),c1( 0 ),c2( 0 ),c3( 0 ),Filt(0),Peak(0),Universal( 0 ) ;

once begin
if BandEdge <= 0 then
RaiseRunTimeError( "BandEdge must be > zero" ) ;
end ;
WhiteNoise = ( Close - Close[2] ) / 2 ;

// SuperSmoother Filter
a1 = ExpValue( -1.414 * 3.14159 / BandEdge ) ;
b1 = 2 * a1 * Cosine( 1.414 * 180 / BandEdge ) ;
c2 = b1 ;
c3 = -a1 * a1 ;
c1 = 1 - c2 - c3 ;
Filt = c1 * ( WhiteNoise + WhiteNoise [1] ) / 2 + c2 * Filt[1] + c3 * Filt[2] ;
If Currentbar = 1 then Filt = 0 ;
If Currentbar = 2 then Filt = c1 * 0 * ( Close + Close[1] ) / 2 + c2 * Filt[1] ;
If Currentbar = 3 then Filt = c1 * 0 * ( Close + Close[1] ) / 2 + c2 * Filt[1] +c3 * Filt[2] ;

// Automatic Gain Control (AGC)
Peak = .991 * Peak[1] ;
If Currentbar = 1 then Peak = .0000001 ;
If AbsValue( Filt ) > Peak then Peak = AbsValue( Filt ) ;
If Peak <> 0 then Universal = Filt / Peak ;
Plot1( Universal ) ;
Plot2( 0 ) ;

策略原始簡單描述為

指標突破零軸作多
if Universal crosses over 0 then Buy next bar at Market ; 

指標跌破零軸作空
if Universal crosses under 0 then SellShort next bar at Market ;

我們的策略想法是
1.指標突破零軸時以當根K棒的高點加上近N根K棒的振幅平均值作為買點
if Universal crosses over 0 then begin BuyPrice = High + Average(Range,N) ;
2.當收盤價在平盤上作多進場

3.指標跌破零軸時以當根K棒的低點減去近N根K棒的振幅平均值作為賣點
if Universal crosses under 0 then begin SellPrice = Low - Average(Range,N) ;
4.當收盤價在平盤下作空進場

5.固定比例停利/停損出場
台指期 60 min K 留倉 交易期間 2004/12/31 ~ 2014/12/31 交易成本 1200
MagicQS159

沒有留言:

張貼留言