EasyTrader ES_Test 01
動量指標(英語:Momentum,簡稱MTM),是一種測量漲跌速率的技術指標,也稱為動能。出現於蓋特雷(H. M. Gartley)1935年的著作《股票市場的獲利》(Porfits in the Stock Market)。
在分析運用上,除MTM本身,也輔以MTM的移動平均線,一般採10日MTM以及該資料的10日移動平均線(有時也用20日移動平均線或25日移動平均線)。
vars:MP(0),PF(0),PL(0),BuyPrice(0),ShortPrice(0),BasePF(600),BasePL(300) ;
vars:BarPass(5),HLRange(0),WinPoint(0),HBarPos(0),LBarPos(0),ExitH(0),ExitL(0),TimeOK(false),EntryExitCond(false),SelectNo(0) ;
vars:jumpPoint(0) ;
jumpPoint = MinMove/PriceScale ;
Condition98 = 多方交易濾網 ;
Condition99 = 空方交易濾網 ;
//****************** Basic Setup ****************************************
MP = MarketPosition ;
PF = 6000/BigPointValue ;
PL = 1500/BigPointValue ;
//計算多空盈利點數
// ******** Long/Short win/loss point *********
WinPoint_LE = HighSinceEntry_N - EntryPrice ;
WinPoint_SE = EntryPrice - LowSinceEntry_N ;
//計算 Macd 值
// ************ Macd *****************
vars:uDif(0),uMacd(0),uOsc(0),MacdLen(0) ;
MacdLen = MaxList(LenA1,LenB1) ;
if MacdLen > 15 then MacdLen = 15 ;
uDif = Macd((High+Low+Close*2)/4,IntPortion(MacdLen*1.3),IntPortion(MacdLen*2.5)) ;
uMacd = Xaverage(uDif,MacdLen) ;
uOsc = uDif-uMacd ;
//計算 近三週高低區間價
// ************3 Week High or Low *****************
vars:WeekH(High),WeekL(Low),WeekHL(0),WeekHPB(0),WeekLPB(0),Week33(0),Week67(0) ;
WeekH = MaxList(HighW(0),HighW(1),HighW(2)) ;
WeekL = MinList(LowW(0),LowW(1),LowW(2)) ;
WeekHL = WeekH - WeekL ;
Week33 = WeekL+WeekHL*0.33 ;
Week67 = WeekL+WeekHL*0.67 ;
WeekHPB = _BarsLast(High = WeekH) ;
WeekLPB = _BarsLast(Low = WeekL) ;
// ************ for Day High/Low box *****************
Vars:DayLong(5),DayShort(5),DH(0),DL(0),HLDay(0),DCount(0),DayBox33(0),DayBox67(0) ;
DH = 近日高點 ;
DL = 近日低點 ;
//計算 動量值
// MTM
Vars:MomValue(0),MomAvg(0);
MomValue = Momentum(AvgPrice,MaxList(LenA1,LenB1));
MomAvg = XAverage(MomValue,MinList(LenA2,LenB2));
//計算 ADX值
//*********** DMI ADX setup
vars:DMIupA(0),DMIdnA(0),ADX_A(0),DMIupB(0),DMIdnB(0),ADX_B(0) ;
DMIupA = DMIPlus(LenA1) ;
DMIdnA = DMIMinus(LenA1) ;
ADX_A = ADX(LenA1) ;
//計算 彈性指數動態平均線 Vidya
//* Vidya Setup
vars:Vidya1(1),Vidya2(1) ;
Vidya1 = _SS_Vidya(LenA1,FracA) ;
Vidya2 = _SS_Vidya(LenB1,FracB) ;
//計算 5日平均振幅
vars:Day5Range(0) ;
Day5Range = ((HighD(1)-LowD(1))+(HighD(2)-LowD(2))+(HighD(3)-LowD(3))+(HighD(4)-LowD(4))+(HighD(5)-LowD(5)))/5 ;
// ************* Time Set Up *************
TimeOK = (time >= 1900 or time <= 1100) ;
//***************** BuyPrice & ShortPrice Setup *****************
BuyPrice = HighD(0)-OpenD(0)*RatioL/10000 ;
ShortPrice = (DH+DL)*0.5 ;
// ********** Main Strategy *********
// ********** Entry Method
if TimeOK then begin
// 近三根Vidya值上升 且收盤價 自近週高點拉回一段時間 且在週區間價2/3之上
則突破設定價位 做多
if Condition98 and MP <> 1 and Countif(Vidya1 > Vidya1[1],3) = 3 and Close > Week67 and WeekHPB > LenB1 and Close < BuyPrice then Buy ("LE_Vidya7T") next bar at BuyPrice stop;
// ADX值小於設定值 且 Macd 上穿零軸 且 動量均值大於 0 則突破設定價位 做多
if Condition98 and MP <> 1 and ADX_A < NBarL and uMacd Cross over 0 and MomAvg > 0 and Close < BuyPrice then Buy ("LE_Mom02T") next bar at BuyPrice Stop ;
if Condition98 and MP <> 1 and Countif(Vidya1 > Vidya1[1],3) = 3 and Close > Week67 and WeekHPB > LenB1 and Close < BuyPrice then Buy ("LE_Vidya7T") next bar at BuyPrice stop;
// 近三根Vidya值下降 且收盤價 自近週低點反彈一段時間 且在週區間價1/3之下
則跌破設定價位 做空
if Condition99 and MP <> -1 and Countif(Vidya2 < Vidya2[1],3) = 3 and Close < Week33 and WeekLPB > LenB1 and Close > ShortPrice then SellShort ("SE_Vidya7T") next bar at ShortPrice stop;// ADX值小於設定值 且 Macd 上穿零軸 且 動量均值大於 0 則突破設定價位 做多
if Condition98 and MP <> 1 and ADX_A < NBarL and uMacd Cross over 0 and MomAvg > 0 and Close < BuyPrice then Buy ("LE_Mom02T") next bar at BuyPrice Stop ;
// ADX值小於設定值 且 Macd 下穿零軸 且 動量均值小於 0 則跌破設定價位 做空
if Condition99 and MP <> -1 and ADX_A < NBarS and uMacd Cross under 0 and MomAvg < 0 and Close > ShortPrice then sellshort ("SE_Mom02T") next bar at ShortPrice Stop ;
if Condition99 and MP <> -1 and ADX_A < NBarS and uMacd Cross under 0 and MomAvg < 0 and Close > ShortPrice then sellshort ("SE_Mom02T") next bar at ShortPrice Stop ;
end;
//停損及停利
// ************* Base Exit *************
if MP > 0 then begin
Sell ("LX_PF5D_"+NumtoStr(PF+Day5RAnge,0)) next bar at EntryPrice+PF+Day5RAnge limit ;
if WinPoint_LE <= PL*1.5 then Sell ("LX_EPL"+NumtoStr(PL,0)) next bar at EntryPrice-PL stop
else if WinPoint_LE <= PF then Sell ("LX_H2PL_"+NumtoStr(PL*2,0)) next bar at HighSinceEntry_N-PL*2 stop
else if WinPoint_LE > PF then Sell ("LX_PF_"+NumtoStr(WinPoint_LE*0.5,0))
next bar at HighSinceEntry_N-WinPoint_LE*0.5 stop ;
end ;
if MP < 0 then begin
BuytoCover ("SX_PF5D_"+NumtoStr(PF+Day5RAnge,0)) next bar at EntryPrice-PF-Day5RAnge limit ;
if WinPoint_SE <= PL*1.5 then BuytoCover ("SX_EPL_"+NumtoStr(PL,0)) next bar at EntryPrice+PL stop
else if WinPoint_SE <= PF then BuytoCover ("SX_L2PL_"+NumtoStr(PL*2,0)) next bar at LowSinceEntry_N+PL*2 stop
else if WinPoint_SE > PF then BuytoCover ("SX_PF_"+NumtoStr(WinPoint_SE*0.5,0))
next bar at LowSinceEntry_N+WinPoint_SE*0.5 stop ;
end ;
小S&P500 留倉 交易週期 2018/1/1 ~ 2024/6/30 交易成本 USD 70
//停損及停利
// ************* Base Exit *************
if MP > 0 then begin
Sell ("LX_PF5D_"+NumtoStr(PF+Day5RAnge,0)) next bar at EntryPrice+PF+Day5RAnge limit ;
if WinPoint_LE <= PL*1.5 then Sell ("LX_EPL"+NumtoStr(PL,0)) next bar at EntryPrice-PL stop
else if WinPoint_LE <= PF then Sell ("LX_H2PL_"+NumtoStr(PL*2,0)) next bar at HighSinceEntry_N-PL*2 stop
else if WinPoint_LE > PF then Sell ("LX_PF_"+NumtoStr(WinPoint_LE*0.5,0))
next bar at HighSinceEntry_N-WinPoint_LE*0.5 stop ;
end ;
if MP < 0 then begin
BuytoCover ("SX_PF5D_"+NumtoStr(PF+Day5RAnge,0)) next bar at EntryPrice-PF-Day5RAnge limit ;
if WinPoint_SE <= PL*1.5 then BuytoCover ("SX_EPL_"+NumtoStr(PL,0)) next bar at EntryPrice+PL stop
else if WinPoint_SE <= PF then BuytoCover ("SX_L2PL_"+NumtoStr(PL*2,0)) next bar at LowSinceEntry_N+PL*2 stop
else if WinPoint_SE > PF then BuytoCover ("SX_PF_"+NumtoStr(WinPoint_SE*0.5,0))
next bar at LowSinceEntry_N+WinPoint_SE*0.5 stop ;
end ;
小S&P500 留倉 交易週期 2018/1/1 ~ 2024/6/30 交易成本 USD 70
請問大大,Condition98 = 多方交易濾網 ;Condition99 = 空方交易濾網 ;
回覆刪除多方交易濾網 和空方交易濾網可以提供讓我參考嗎?
感謝關注 可以來參加研討會了解濾網
刪除