討論區列表
元大MultiCharts
一般模式
討論串模式
標題:
[發表] TS 轉 MC語言(太複雜,幫幫忙)
by 2011-10-06 23:43:35
0
暱稱:
肥貓
信箱:不顯示
成就:發文(0) / 回文(0) / 推薦(0)
parameter:rangeofday(66),停損(100),rangeofday加碼(66)
Variables:OPN(0),區間高點(0),區間低點(0),移動高點(0),移動低點(0),觸高(0),觸低(0),多單停損價1(0),空單停損價1(0),交易次數(0)
Variables:區間高點加碼(0),區間低點加碼(0),移動高點加碼(0),移動低點加碼(0),觸高加碼(0),觸低加碼(0),多單停損價2(0),空單停損價2(0)
Array:CoD1[84](-1),CoD2[84](-1),CoD3[84](-1),CoD4[84](-1),CoD5[84](-1),CoD6[84](-1),CoD7[84](-1)
Array:ooD1[84](-1),ooD2[84](-1),ooD3[84](-1),ooD4[84](-1),ooD5[84](-1),ooD6[84](-1),ooD7[84](-1)
vars:closeD1(0),closeD2(0),closeD3(0),closeD4(0),closeD5(0),closeD6(0),closeD7(0)
vars:openD1(0),openD2(0),openD3(0),openD4(0),openD5(0),openD6(0),openD7(0)
vars:HighD0(0),HighD1(0),HighD2(0),HighD3(0),HighD4(0),HighD5(0),HighD6(0),HighD7(0)
vars:LowD0(20000),LowD1(0),LowD2(0),LowD3(0),LowD4(0),LowD5(0),LowD6(0),LowD7(0)
vars:dayrange1(0),dayrange2(0),dayrange3(0),dayrange4(0),dayrange5(0),dayrange6(0),dayrange7(0)
Variables:Maxdayrange(0),波動性過大(0),最近20分低點(0),最近20分高點(0)
IF date[0] <> date[1]
then
OPN = OPEN
區間高點 = (opn*(1+rangeofday/10000))
區間低點 = (opn*(1-rangeofday/10000))
移動高點 = 0
移動低點 = 0
觸高 = 0
觸低 = 0
觸高加碼 = 0
觸低加碼 = 0
多單停損價1 = 0
空單停損價1 = 0
交易次數 = 0
//.以下是抓每日的開盤、最高、最低、收盤值的公式並計算每日波動值並判斷是否波動過大
closeD1 = CloseOfD(1, CoD1)
closeD2 = CloseOfD(2, CoD2)
closeD3 = CloseOfD(3, CoD3)
closeD4 = CloseOfD(4, CoD4)
closeD5 = CloseOfD(5, CoD5)
closeD6 = CloseOfD(6, CoD6)
closeD7 = CloseOfD(7, CoD7)
openD1 = openOfD(1, ooD1)
openD2 = openOfD(2, ooD2)
openD3 = openOfD(3, ooD3)
openD4 = openOfD(4, ooD4)
openD5 = openOfD(5, ooD5)
openD6 = openOfD(6, ooD6)
openD7 = openOfD(7, ooD7)
HighD7=HighD6
HighD6=HighD5
HighD5=HighD4
HighD4=HighD3
HighD3=HighD2
HighD2=HighD1
HighD1=HighD0
HighD0=0
LowD7=LowD6
LowD6=LowD5
LowD5=LowD4
LowD4=LowD3
LowD3=LowD2
LowD2=LowD1
LowD1=LowD0
LowD0=20000
dayrange1=HighD1-LowD1
dayrange2=HighD2-LowD2
dayrange3=HighD3-LowD3
dayrange4=HighD4-LowD4
dayrange5=HighD5-LowD5
dayrange6=HighD6-LowD6
dayrange7=HighD7-LowD7
maxdayrange=maxlist(dayrange2,dayrange3,dayrange4,dayrange5,dayrange6,dayrange7)
IF dayrange1>=maxdayrange then
波動性過大=1
else
波動性過大=0
End IF
End IF
//.以下是計算每日的最高最低值------------------------------------------------------------------------
if time > 084501 then
IF high>HighD0 then
HighD0=high
End IF
IF Low<LowD0 THEN
LowD0=Low
END IF
END IF
if time > 085000 and time<131000 and 波動性過大=0 then
//.以下是多單----------------------------------------------------------------------------------------------------
IF marketposition = 0 and 交易次數 = 0 then
IF High[1] > 區間高點 and 觸高 = 0 then
IF close>區間高點 and close>open then
Buy("多單1") next bar at market
else
移動高點 = maxlist(High[1],High)
觸高 = 1
End IF
End IF
IF 觸高 = 1 and High > 移動高點 then
Buy("多單2") this bar at 移動高點 stop
End IF
End IF
IF marketposition = 0 and 交易次數 = 0 then
IF 觸高 = 1 and high > 移動高點 then
Buy("多單3") this bar at 移動高點 or lower
End IF
End IF
End IF
//.======================進單時間區隔=============================================================================
//.以下是多單停損1,全天----------------------------------------------------------------------------------------------------
IF marketposition = 1 AND 交易次數=0 then
交易次數 = 1
多單停損價1 =entryprice(0)-opn*停損/10000
End IF
IF Low < 多單停損價1 AND marketposition = 1 then
exitlong this Bar at 多單停損價1 stop
End IF
IF marketposition = 1 and 觸高加碼 = 0 then
區間高點加碼 = (Entryprice(0)+opn*(rangeofday加碼/10000))
移動高點加碼 = 0
觸高加碼 = 0
多單停損價2 = 0
END IF
//.======================進單時間區隔=============================================================================
if time > 085000 and time<131000 then
//.以下是多單----------------------------------------------------------------------------------------------------
IF marketposition = 1 and 交易次數 = 1 then
IF High[1] > 區間高點加碼 and 觸高加碼 = 0 then
IF close>區間高點加碼 and close>open then
Buy("多單4") next bar at market
else
移動高點加碼 = maxlist(High[1],High)
觸高加碼 = 1
End IF
End IF
IF 觸高加碼 = 1 and High > 移動高點加碼 then
Buy("多單5") this bar at 移動高點加碼 stop
End IF
End IF
IF marketposition = 1 and 交易次數 = 1 then
IF 觸高加碼 = 1 and high > 移動高點加碼 then
Buy("多單6") this bar at 移動高點加碼 or lower
End IF
End IF
End IF
//.以下是多單停損2,全天----------------------------------------------------------------------------------------------------
IF marketposition = 2 AND 交易次數=1 then
交易次數 = 2
多單停損價2 =entryprice(0)-opn*停損/10000
End IF
IF Low < 多單停損價2 AND marketposition = 2 then
exitlong 1 contract total this Bar at 多單停損價2 stop
End IF
//.以下是空單----------------------------------------------------------------------------------------------------
if time > 085000 and time<131000 and 波動性過大=0 then
IF marketposition = 0 and 交易次數 = 0 then
IF Low[1]<區間低點 and 觸低 = 0 then
IF close<區間低點 and close<open then
sell("空單1") next bar at market
else
移動低點 = minlist(low[1],low)
觸低 = 1
End IF
End IF
IF 觸低 = 1 and Low < 移動低點 then
Sell("空單2") this bar at 移動低點 limit
End IF
End IF
IF marketposition = 0 and 交易次數 = 0 then
IF 觸低 = 1 and Low < 移動低點 then
Sell("空單3") this bar at 移動低點 or lower
End IF
End IF
End IF
//.======================進單時間區隔=============================================================================
//.以下是空單停損1,全天----------------------------------------------------------------------------------------------------
IF marketposition = -1 AND 交易次數=0 then
交易次數 = 1
空單停損價1 =entryprice(0)+opn*停損/10000
End IF
IF high > 空單停損價1 AND marketposition = -1 then
exitshort this Bar at 空單停損價1 stop
End IF
IF marketposition = -1 and 觸低加碼 = 0 then
區間低點加碼 = (Entryprice(0)-opn*(rangeofday加碼/10000))
移動低點加碼 = 0
觸低加碼 = 0
空單停損價2 = 0
END IF
//.以下是空單----------------------------------------------------------------------------------------------------
if time > 085000 and time<131000 then
IF marketposition = -1 and 交易次數 = 1 then
IF Low[1]<區間低點加碼 and 觸低加碼 = 0 then
IF close<區間低點加碼 and close<open then
sell("空單4") next bar at market
else
移動低點加碼 = minlist(low[1],low)
觸低加碼 = 1
End IF
End IF
IF 觸低加碼 = 1 and Low < 移動低點加碼 then
Sell("空單5") this bar at 移動低點加碼 limit
End IF
End IF
IF marketposition = -1 and 交易次數 = 1 then
IF 觸低加碼 = 1 and Low < 移動低點加碼 then
Sell("空單6") this bar at 移動低點加碼 or lower
End IF
End IF
End IF
//.======================進單時間區隔=============================================================================
//.以下是空單停損2,全天----------------------------------------------------------------------------------------------------
IF marketposition = -2 AND 交易次數=1 then
交易次數 = 2
空單停損價2 =entryprice(0)+opn*停損/10000
End IF
IF high > 空單停損價2 AND marketposition = -2 then
exitshort 1 contract total this Bar at 空單停損價2 stop
End IF
//.以下是1點40分平倉----------------------------------------------------------------------------------------------------
if time>=133955 and marketposition > 0 then
exitlong next bar at market
end if
if time>=133955 and marketposition < 0 then
exitshort next bar at market
end if
//.以下是1點20分後追蹤出場-----------------------------------------------------------
if time>132000 and marketposition > 0 then
最近20分低點=minlist(low[1],low[2],low[3],low[4])
if low < 最近20分低點 and marketposition > 0 then
exitlong this bar at 最近20分低點 or higher
exitlong this bar at 最近20分低點 stop
exitlong this bar at 最近20分低點 limit
End IF
end if
if time>132000 and marketposition < 0 then
最近20分高點=maxlist(high[1],high[2],high[3],high[4])
if high > 最近20分高點 and marketposition < 0 then
exitshort this bar at 最近20分高點 or lower
exitshort this bar at 最近20分高點 limit
exitshort this bar at 最近20分高點 stop
End IF
end if
//.以下是換月日期提早到1點25分平倉----------------------------------------------------------------------------------------------------
//.if date=1100120 or date=1090916 or date=1090819 or date=1091118 or date=1091216 then
if dayofweek(date) = 3 and (dayofmonth(date) >= 15 and dayofmonth(date) <= 21) then
if time>=132455 and marketposition <> 0 then
exitlong next bar at market
exitshort next bar at market
end if
end if
//--------------------------------------------------------------------------
if date = lastcalcdate and time = lastcalctime then
FileDelete("R:Current.txt")
FileAppend("R:Current.txt",cdate(date) +" "+ ctime(time)+","+ NumToStr(CurrentContracts,0)+","+NumToStr(Close,0))
end if
第1篇:
[發表] TS 轉 MC語言(太複雜,幫幫忙)
by 2011-10-07 09:36:56
1
暱稱:
客服一號
信箱:folkchen.sp2@gmail.com
成就:發文(0) / 回文(0) / 推薦(96)
Input:rangeofday(66),pStopLoss(100),rangeofdayPlus(66);
Variables:OPN(0),RangeHigh(0),vRangeLow(0),vMoveH(0),vMoveL(0),vTouchH(0),vTouchL(0),vBStopLossP1(0),vSStopLossP1(0),vTradeCount(0);
Variables:vRangeHighPlus(0),vRangeLowPlus(0),vMoveHPlus(0),vMoveLPlus(0),vTouchHPlus(0),vTouchLPlus(0),vBStopLossP2(0),vSStopLossP2(0);
vars:closeD1(0),closeD2(0),closeD3(0),closeD4(0),closeD5(0),closeD6(0),closeD7(0);
vars:openD1(0),openD2(0),openD3(0),openD4(0),openD5(0),openD6(0),openD7(0);
vars:HighD0(0),HighD1(0),HighD2(0),HighD3(0),HighD4(0),HighD5(0),HighD6(0),HighD7(0);
vars:LowD0(20000),LowD1(0),LowD2(0),LowD3(0),LowD4(0),LowD5(0),LowD6(0),LowD7(0);
vars:dayrange1(0),dayrange2(0),dayrange3(0),dayrange4(0),dayrange5(0),dayrange6(0),dayrange7(0);
Variables:Maxdayrange(0),vWaveBig(0),v20ML(0),v20MH(0);
If date[0] <> date[1] Then Begin
OPN = OPEN;
RangeHigh = (opn*(1+rangeofday/10000));
vRangeLow = (opn*(1-rangeofday/10000));
vMoveH = 0;
vMoveL = 0;
vTouchH = 0;
vTouchL = 0;
vTouchHPlus = 0;
vTouchLPlus = 0;
vBStopLossP1 = 0;
vSStopLossP1 = 0;
vTradeCount = 0;
closeD1 = closeD(1);
closeD2 = closeD(2);
closeD3 = closeD(3);
closeD4 = closeD(4);
closeD5 = closeD(5);
closeD6 = closeD(6);
closeD7 = closeD(7);
openD1 = openD(1);
openD2 = openD(2);
openD3 = openD(3);
openD4 = openD(4);
openD5 = openD(5);
openD6 = openD(6);
openD7 = openD(7);
HighD7=HighD6;
HighD6=HighD5;
HighD5=HighD4;
HighD4=HighD3;
HighD3=HighD2;
HighD2=HighD1;
HighD1=HighD0;
HighD0=0;
LowD7=LowD6;
LowD6=LowD5;
LowD5=LowD4;
LowD4=LowD3;
LowD3=LowD2;
LowD2=LowD1;
LowD1=LowD0;
LowD0=20000;
dayrange1=HighD1-LowD1;
dayrange2=HighD2-LowD2;
dayrange3=HighD3-LowD3;
dayrange4=HighD4-LowD4;
dayrange5=HighD5-LowD5;
dayrange6=HighD6-LowD6;
dayrange7=HighD7-LowD7;
maxdayrange=maxlist(dayrange2,dayrange3,dayrange4,dayrange5,dayrange6,dayrange7);
If dayrange1>=maxdayrange Then Begin
vWaveBig=1;
End Else Begin
vWaveBig=0;
End;
End;
If time_s > 084501 Then Begin
If high > HighD0 Then Begin
HighD0=high;
End;
If Low<LowD0 Then Begin
LowD0=Low;
End;
End;
If time_s > 085000 and time_s<131000 and vWaveBig=0 Then Begin
If marketposition = 0 and vTradeCount = 0 Then Begin
If High[1] > RangeHigh and vTouchH = 0 Then Begin
If close>RangeHigh and close>open Then Begin
Buy("B-1") next bar at market;
End Else Begin
vMoveH = maxlist(High[1],High);
vTouchH = 1;
End;
End;
If vTouchH = 1 and High > vMoveH Then Begin
Buy("B-2") next Bar at vMoveH stop;
End;
End;
If marketposition = 0 and vTradeCount = 0 Then Begin
If vTouchH = 1 and high > vMoveH Then Begin
Buy("B-3") next Bar at vMoveH or lower;
End;
End;
End;
If marketposition = 1 AND vTradeCount=0 Then Begin
vTradeCount = 1;
vBStopLossP1 =entryprice(0)-opn*pStopLoss/10000;
End;
If Low < vBStopLossP1 AND marketposition = 1 Then Begin
Sell next Bar at vBStopLossP1 stop;
End;
If marketposition = 1 and vTouchHPlus = 0 Then Begin
vRangeHighPlus = (Entryprice(0)+opn*(rangeofdayPlus/10000));
vMoveHPlus = 0;
vTouchHPlus = 0;
vBStopLossP2 = 0;
End;
If time_s > 085000 and time_s<131000 Then Begin
If marketposition = 1 and vTradeCount = 1 Then Begin
If High[1] > vRangeHighPlus and vTouchHPlus = 0 Then Begin
If close>vRangeHighPlus and close>open Then Begin
Buy("B-4") next bar at market;
End Else Begin
vMoveHPlus = maxlist(High[1],High);
vTouchHPlus = 1;
End;
End;
If vTouchHPlus = 1 and High > vMoveHPlus Then Begin
Buy("B-5") next Bar at vMoveHPlus stop;
End;
End;
If marketposition = 1 and vTradeCount = 1 Then Begin
If vTouchHPlus = 1 and high > vMoveHPlus Then Begin
Buy("B-6") next Bar at vMoveHPlus or lower;
End;
End;
End;
If marketposition = 2 AND vTradeCount=1 Then Begin
vTradeCount = 2;
vBStopLossP2 =entryprice(0)-opn*pStopLoss/10000;
End;
If Low < vBStopLossP2 AND marketposition = 2 Then Begin
Sell 1 contract total next Bar at vBStopLossP2 stop;
End;
If time_s > 085000 and time_s<131000 and vWaveBig=0 Then Begin
If marketposition = 0 and vTradeCount = 0 Then Begin
If Low[1]<vRangeLow and vTouchL = 0 Then Begin
If close<vRangeLow and close<open Then Begin
Sellshort("S-1") next bar at market;
End Else Begin
vMoveL = minlist(low[1],low);
vTouchL = 1;
End;
End;
If vTouchL = 1 and Low < vMoveL Then Begin
Sellshort("S-2") next Bar at vMoveL limit;
End;
End;
If marketposition = 0 and vTradeCount = 0 Then Begin
If vTouchL = 1 and Low < vMoveL Then Begin
Sellshort("S-3") next Bar at vMoveL or lower;
End;
End;
End;
If marketposition = -1 AND vTradeCount=0 Then Begin
vTradeCount = 1;
vSStopLossP1 =entryprice(0)+opn*pStopLoss/10000;
End;
If high > vSStopLossP1 AND marketposition = -1 Then Begin
BuyToCover next Bar at vSStopLossP1 stop;
End;
If marketposition = -1 and vTouchLPlus = 0 Then Begin
vRangeLowPlus = (Entryprice(0)-opn*(rangeofdayPlus/10000));
vMoveLPlus = 0;
vTouchLPlus = 0;
vSStopLossP2 = 0;
End;
If time_s > 085000 and time_s<131000 Then Begin
If marketposition = -1 and vTradeCount = 1 Then Begin
If Low[1]<vRangeLowPlus and vTouchLPlus = 0 Then Begin
If close<vRangeLowPlus and close<open Then Begin
Sellshort("S-4") next bar at market;
End Else Begin
vMoveLPlus = minlist(low[1],low);
vTouchLPlus = 1;
End;
End;
If vTouchLPlus = 1 and Low < vMoveLPlus Then Begin
Sellshort("S-5") next Bar at vMoveLPlus limit;
End;
End;
If marketposition = -1 and vTradeCount = 1 Then Begin
If vTouchLPlus = 1 and Low < vMoveLPlus Then Begin
Sellshort("S-6") next Bar at vMoveLPlus or lower;
End;
End;
End;
If marketposition = -2 AND vTradeCount=1 Then Begin
vTradeCount = 2;
vSStopLossP2 =entryprice(0)+opn*pStopLoss/10000;
End;
If high > vSStopLossP2 AND marketposition = -2 Then Begin
BuyToCover 1 contract total next Bar at vSStopLossP2 stop;
End;
If time_s>=133955 and marketposition > 0 Then Begin
Sell next bar at market ;
End;
If time_s>=133955 and marketposition < 0 Then Begin
BuyToCover next bar at market ;
End;
If time_s>132000 and marketposition > 0 Then Begin
v20ML=minlist(low[1],low[2],low[3],low[4]);
If low < v20ML and marketposition > 0 Then Begin
Sell next Bar at v20ML or higher;
Sell next Bar at v20ML stop;
Sell next Bar at v20ML limit;
End;
End;
If time_s>132000 and marketposition < 0 Then Begin
v20MH=maxlist(high[1],high[2],high[3],high[4]);
If high > v20MH and marketposition < 0 Then Begin
BuyToCover next Bar at v20MH or lower;
BuyToCover next Bar at v20MH limit;
BuyToCover next Bar at v20MH stop;
End;
End;
If dayofweek(date) = 3 and (dayofmonth(date) >= 15 and dayofmonth(date) <= 21) Then Begin
If time_s>=132455 and marketposition <> 0 Then Begin ;
Sell next bar at market ;
BuyToCover next bar at market ;
End;
End;
//--------------------------------------------------------------------------;
//If date = lastcalcdate and time = lastcalctime Then Begin
// FileDelete("R:Current.txt");
// FileAppend("R:Current.txt",cdate(date) +" "+ ctime(time)+","+ NumToStr(CurrentContracts,0)+","+NumToStr(Close,0));
//End;
第一頁
上一頁
1
下一頁
最後頁
討論區列表
元大MultiCharts
MultiCharts
│
討論區
│
會員專區
│
教學講座
│
支援與服務
│
產品購買
│
申請試用
All rights for MultiCharts Trading Software are reserved by MultiCharts, LLC
凱衛資訊股份有限公司 營利事業統一編號(21261212) 著作權所有 本網站最佳瀏覽解析度為 1024 x 768
隱私權政策
│
網站安全政策
│
著作權說明
若不清楚點選圖片更新驗證碼
註冊帳號
忘記密碼
解除鎖定