EasyTrader ArtNo 201
在 [ QUANTITATIVE TRADING STRATEGIES]書內有一個這樣的策略是 Michael Cooper (Purdue University )金融學教授所做的論文研究。庫珀從 1962 年到 1993 年的股票收益率進行了研究。他發現單周報酬率走勢如果伴隨著萎縮成交量,通常會在隔周反轉。我在網路上找到了這份原始資料Real Estate Securities and a Filter-based,Short-term Trading Strategy進場策略的基本想法
- 五天期的價格變動絕對值大於100天期價格變動的標準差
- 五天期的平均成交量低於十天前的五天期平均成交量的 75%
- 當近五天期價格變動是負值時多單進場
- 當近五天期價格變動是正值時空單進場
- 所有部位進場後第五天離場
These conditions identify significant price movement accompanied with a decrease in trading volume. We enter long if the most recent five-day price change is negative while we enter short if the five-day price change is positive. All entries are exited on the fifth day of the trade.
首先當然是作成指標來觀察
指標 1 (價格變動比)
input:FastLen(5),SlowLen(100),HB(2),LB(2) ;
Vars:PriceChange(0), SlowDev(0),PriceRatio(0) ;
PriceChange = Absvalue(Close-Close[FastLen]) ; { 五日變動量 }
SlowDev = StdDev(Close-Close[1],SlowLen) ; { 100 日價格變動標準差 }
if SlowDev <> 0 then PriceRatio = PriceChange/SlowDev ; { 變動量比值 }
PriceRatio = Sign(Close-Close[FastLen])*PriceRatio ; { 取正負號判斷方向 }
*** Sign(N) 是一個內建函數 ,取正負值使用 ***
Plot1(PriceRatio,"PR",iff(PriceRatio>=0,Red,Green),Black,2) ;
Plot2(HB,"HB") ;
Plot3(-LB,"LB") ;
指標 2 (成交量比)
input:Length(5),Ratio(75),N(2) ;
Vars:NearVol(0),FarVol(0),RatioVol(0) ;
NearVol = Average(Volume,Length)[1] ;
FarVol = Average(Volume,Length)[Length*N+1] ;
if FarVol <> 0 then RatioVol = NearVol/FarVol ;
Plot1(RatioVol,"RV") ;
Plot2(Ratio/100,"Level") ;
if FarVolA <> 0 then RatioVolA = NearVolA/FarVolA ;Plot1(PriceRatio,"PR",iff(PriceRatio>=0,Red,Green),Black,2) ;
Plot2(HB,"HB") ;
Plot3(-LB,"LB") ;
input:Length(5),Ratio(75),N(2) ;
Vars:NearVol(0),FarVol(0),RatioVol(0) ;
NearVol = Average(Volume,Length)[1] ;
FarVol = Average(Volume,Length)[Length*N+1] ;
if FarVol <> 0 then RatioVol = NearVol/FarVol ;
Plot1(RatioVol,"RV") ;
Plot2(Ratio/100,"Level") ;
Vars:PriceChangeL(0),SlowDevL(0),PriceRatioL(0),NearVolA(0),FarVolA (0),RatioVolA(0),MP(0);
PriceChangeL = Absvalue(Close-Close[5]) ;
SlowDevL = StdDev(Close-Close[1],100) ;
if SlowDevL <> 0 then PriceRatioL = PriceChangeL/SlowDevL ;
PriceRatioL = Sign(Close-Close[5])*PriceRatioL ;
NearVolA = Average(iff(DataComPression > 1,Volume,ticks),5)[1] ;
FarVolA = Average(iff(DataComPression > 1,Volume,ticks),5)[10+1] ;
PriceChangeL = Absvalue(Close-Close[5]) ;
SlowDevL = StdDev(Close-Close[1],100) ;
if SlowDevL <> 0 then PriceRatioL = PriceChangeL/SlowDevL ;
PriceRatioL = Sign(Close-Close[5])*PriceRatioL ;
NearVolA = Average(iff(DataComPression > 1,Volume,ticks),5)[1] ;
FarVolA = Average(iff(DataComPression > 1,Volume,ticks),5)[10+1] ;
if PriceRatioL < -LB and RatioVolA < RatioL/100 then buy next bar at market ;
if PriceRatioL > HB and RatioVolA < RatioL/100 then sell next bar at market ;
if MP > 0 and BarsSinceEntry = NBarL then ExitLong next bar at Market ;
if MP < 0 and BarsSinceEntry = NBarS then ExitShort next bar at Market ;
input:FastLenL(5),SlowLenL(100),RatioL(75),FastLenS(5),SlowLenS(100),RatioS(75),HB(2),LB(2),N(2) ,NBarL(5),NBarS(5);
Vars:PriceChangeL(0), SlowDevL(0),PriceRatioL(0),NearVolA(0),FarVolA(0),RatioVolA(0);Vars:PriceChangeS(0), SlowDevS(0),PriceRatioS(0),NearVolB(0),FarVolB(0),RatioVolB(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 ;
{ 計算多方進場條件 }
PriceChangeL = Absvalue(Close-Close[FastLenL]) ;
SlowDevL = StdDev(Close-Close[1],SlowLenL) ;
if SlowDevL <> 0 then PriceRatioL = PriceChangeL/SlowDevL ;
PriceRatioL = Sign(Close-Close[FastLenL])*PriceRatioL ;
{ 成交量變化 }
NearVolA = Average(Volume,FastLenL)[1] ;
FarVolA = Average(Volume,FastLenL)[FastLenL*N+1] ;
if FarVolA <> 0 then RatioVolA = NearVolA/FarVolA ;
{ 計算空方進場條件 }
PriceChangeS = Absvalue(Close-Close[FastLenS]) ;
SlowDevS = StdDev(Close-Close[1],SlowLenS) ;
if SlowDevS <> 0 then PriceRatioS = PriceChangeS/SlowDevS ;
PriceRatioS = Sign(Close-Close[FastLenS])*PriceRatioS ;
{ 成交量變化 }
NearVolB = Average(Volume,FastLenS)[1] ;
FarVolB = Average(Volume,FastLenS)[FastLenS*N+1] ;
if FarVolB <> 0 then RatioVolB = NearVolB/FarVolB ;
{ 當價格變動比例 < -LB 且 成交量比 < RatioL 時 ,多單進場 }
if PriceRatioL < -LB and RatioVolA < RatioL/100 then buy next bar at market ;
if PriceRatioL < -LB and RatioVolA < RatioL/100 then buy next bar at market ;
{ 當價格變動比例 > HB 且 成交量比 < RatioS 時 ,空單進場 }
if PriceRatioS > HB and RatioVolB < RatioS/100 then sell next bar at market ;
if PriceRatioS > HB and RatioVolB < RatioS/100 then sell next bar at market ;
{ 固定持有 K棒數出場 }
if MP > 0 and BarsSinceEntry = NBarL then ExitLong next bar at Market ;
if MP < 0 and BarsSinceEntry = NBarS then ExitShort next bar at Market ;
if MP > 0 and BarsSinceEntry = NBarL then ExitLong next bar at Market ;
if MP < 0 and BarsSinceEntry = NBarS then ExitShort next bar at Market ;
if IsBalanceDay then setExitonClose ;
台指期 日K 留倉 回測週期 2004/8/2~2014/7/31 交易成本 1200
同樣也是以多單為主 ~ 蠻合適作股票多單的判斷喔!
MagicQS111
沒有留言:
張貼留言