EasyTrader ArtNo 256
動量指標是由美國形態技術分析的先驅-蓋特雷(H. M. Gartley)在1935 年所提出的一種測量漲跌速率的技術指標,所謂動量指標- MTM (Momentum)是以今天的收盤價直接減去n日前收盤價所計算出來的趨勢線,其所隱含的是n日之間股價漲跌幅之速度,可以在漲升下挫的過程中觀察持續漲跌之力道。使用方法 :一般MTM較常與10日動量值移動平均線配合使用。
- 當MTM位於橫軸上方,由上往下穿過平均線則為賣出訊號;
- 當MTM位於橫軸下方,且其由下往上穿過平均線則為買進訊號。
- 股價在上漲過程中創新高,但MTM並未配合上升,此即表示股價上漲動量減弱,應慎防行情反轉下挫;
- 若股價在下跌過程中創新低,但MTM並未配合下降,此即表示股價下跌動量減弱,短期之內可能有反彈行情。
- 當K線與MTM同步自低檔上揚,表明短期將出現反彈;
- 當K線與MTM同步自高檔下挫,則表明短期將出現回檔。
{ 系統參數與變數}
input:EntryType(1),ExitType(6);
inputs:NBarL(30),NBarS(27),TradeProfit(0.046),TradeStopLoss(0.033),ATRs_L(10.78),ATRs_S(6.4);
vars: IsBalanceDay(False),MP(0),PF(0),PL(0),HLRange(100);
inputs:MomLen(10),AvgLen(10),HighBar(3),LowBar(3);
Vars: MTMorig(0),MTMAvg(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 ;
{計算動量與平均動量}
MTMorig = Momentum(Close, MomLen) ;
MTMAvg = Average(MTMorig,AvgLen) ;
{ 策略一 動量穿越零軸進場 }
if EntryType = 1 then begin
if MP <> 1 and MTMorig Cross over 0 then Buy next bar at Highest(High,Highbar) stop ;
if MP <> -1 and MTMorig Cross under 0 then Sell next bar at Lowest(low,LowBar) stop ;
end ;
{ 策略二 平均動量穿越零軸進場 }
if EntryType = 2 then begin
if MP <> 1 and MTMAvg Cross over 0 then Buy next bar at Highest(High,Highbar) stop ;
if MP <> -1 and MTMAvg Cross under 0 then Sell next bar at Lowest(low,LowBar) stop ;
end ;
if EntryType = 2 then begin
if MP <> 1 and MTMAvg Cross over 0 then Buy next bar at Highest(High,Highbar) stop ;
if MP <> -1 and MTMAvg Cross under 0 then Sell next bar at Lowest(low,LowBar) stop ;
end ;
{ 策略三 動量交叉平均動量進場 }
if EntryType = 3 then begin
if MP <> 1 and MTMorig Cross over MTMAvg then Buy next bar at Highest(High,Highbar) stop ;
if MP <> -1 and MTMorig Cross under MTMAvg then Sell next bar at Lowest(low,LowBar) stop ;
end ;
{Exits}
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 ExitType = 5 then Begin
{*******************************************************************
Description : ATR Trailing Stop Long Exit
Provided By : Omega Research, Inc. (c) Copyright 1999
********************************************************************}
{Inputs: ATRs_L(3);}
Variables: PosHigh(0), ATRVal_L(0);
ATRVal_L = AvgTrueRange(10) * ATRs_L;
If BarsSinceEntry = 0 Then PosHigh = High;
If MarketPosition = 1 Then Begin
If High > PosHigh Then PosHigh = High;
ExitLong ("ATR") Next Bar at PosHigh - ATRVal_L Stop;
End else ExitLong ("ATR eb") Next bar at High - ATRVal_L Stop;
{*******************************************************************
Description : ATR Trailing Stop Short Exit
Provided By : Omega Research, Inc. (c) Copyright 1999
********************************************************************}
{Inputs: ATRs_S(3);}
Variables: PosLow(0), ATRVal_S(0);
ATRVal_S = AvgTrueRange(10) * ATRs_S;
If BarsSinceEntry = 0 Then PosLow = Low;
If MarketPosition = -1 Then Begin
If Low < PosLow Then PosLow = Low;
ExitShort ("ATR_1") Next Bar at PosLow + ATRVal_S Stop;
End else ExitShort ("ATR_1 eb") Next bar at Low + ATRVal_S Stop;
end;
if ExitType = 6 then SetStopLoss(PF * BigPointValue) ;
if IsBalanceDay or date = 1150224 then setExitonClose ;
策略一台指期 30 min K 多空留倉 交易週期 2004/12/31~ 2014/12/31 交易成本 1200
if MP <> 1 and MTMorig Cross over MTMAvg then Buy next bar at Highest(High,Highbar) stop ;
if MP <> -1 and MTMorig Cross under MTMAvg then Sell next bar at Lowest(low,LowBar) stop ;
end ;
{Exits}
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 ExitType = 5 then Begin
{*******************************************************************
Description : ATR Trailing Stop Long Exit
Provided By : Omega Research, Inc. (c) Copyright 1999
********************************************************************}
{Inputs: ATRs_L(3);}
Variables: PosHigh(0), ATRVal_L(0);
ATRVal_L = AvgTrueRange(10) * ATRs_L;
If BarsSinceEntry = 0 Then PosHigh = High;
If MarketPosition = 1 Then Begin
If High > PosHigh Then PosHigh = High;
ExitLong ("ATR") Next Bar at PosHigh - ATRVal_L Stop;
End else ExitLong ("ATR eb") Next bar at High - ATRVal_L Stop;
{*******************************************************************
Description : ATR Trailing Stop Short Exit
Provided By : Omega Research, Inc. (c) Copyright 1999
********************************************************************}
{Inputs: ATRs_S(3);}
Variables: PosLow(0), ATRVal_S(0);
ATRVal_S = AvgTrueRange(10) * ATRs_S;
If BarsSinceEntry = 0 Then PosLow = Low;
If MarketPosition = -1 Then Begin
If Low < PosLow Then PosLow = Low;
ExitShort ("ATR_1") Next Bar at PosLow + ATRVal_S Stop;
End else ExitShort ("ATR_1 eb") Next bar at Low + ATRVal_S Stop;
end;
if ExitType = 6 then SetStopLoss(PF * BigPointValue) ;
if IsBalanceDay or date = 1150224 then setExitonClose ;
策略一台指期 30 min K 多空留倉 交易週期 2004/12/31~ 2014/12/31 交易成本 1200
策略二台指期 30 min K 多空留倉 交易週期 2004/12/31~ 2014/12/31 交易成本 1200
策略三台指期 30 min K 多空留倉 交易週期 2004/12/31~ 2014/12/31 交易成本 1200
結論:本篇將常見的一般技術指標 -動量指標,透過圖表的觀察作不同的進場邏輯,可以看到,以台指期商品來看,當動量與平均動量的交叉,其績效表現是比其它兩種穿越零軸的元素來得好,另外讀者也可以將成交量加入,變成量價合一的變數也會有不錯的表現
MagicQS164
沒有留言:
張貼留言