如何指出指定時間內的高低收位置? [MC]
-
MC用戶求助:
您可以看一下帖子http://forums.touchance.cn/forum ... &extra=page%3D1,里面說的比較詳細。
一、由于HighS和LowS函數中使用了關鍵字sessionlastbar來區分交易所時段,不同的交易所對于時間的劃分可能不一樣,同一個交易所不同的商品合約對于交易時段的劃分也可能不一樣,關于某個商品合約的交易所時段您可以在報價管理器中查看。
二、恒指期貨的交易所時段是從9:15到23:45,所以通過highD和HighS函數求得的交易日的最高價是一樣的,對于LowD和LowS、closeD和closeS、OpenD和OpenS求得的值都是一樣的。
三、如果您只是想求得日市,也就是恒指的9:15到16:30時間段內的最高價、最低價、開盤價和收盤價,那么您需要自己寫一個特定的函數(對HighD、LowD、closeD、openD進行修改就可以了),MC中沒有針對特殊時段的求日內最高價、最低價、開盤價和收盤價的函數。?
-
MC回復討論一:
您可以看一下帖子http://forums.touchance.cn/forum ... &extra=page%3D1,里面說的比較詳細。
一、由于HighS和LowS函數中使用了關鍵字sessionlastbar來區分交易所時段,不同的交易所對于時間的劃分可能不一樣,同一個交易所不同的商品合約對于交易時段的劃分也可能不一樣,關于某個商品合約的交易所時段您可以在報價管理器中查看。
二、恒指期貨的交易所時段是從9:15到23:45,所以通過highD和HighS函數求得的交易日的最高價是一樣的,對于LowD和LowS、closeD和closeS、OpenD和OpenS求得的值都是一樣的。
三、如果您只是想求得日市,也就是恒指的9:15到16:30時間段內的最高價、最低價、開盤價和收盤價,那么您需要自己寫一個特定的函數(對HighD、LowD、closeD、openD進行修改就可以了),MC中沒有針對特殊時段的求日內最高價、最低價、開盤價和收盤價的函數。?
-
MC回復討論二:
(對HighD、LowD、closeD、openD進行修改就可以了)<<這個我可以如何入手?
是否先開一個$OHLCPeriodsAgo ,?
修改內容
然後新增名為??$HighD 的函數
inputs: PeriodsAgo( numericsimple ) ;
variables: var1(0), var2(0), var3(0), var4(0) ;
Value1 = $OHLCPeriodsAgo( PeriodsAgo, var1, var2, var3, var4 ) ;
$HighD = var2 ;?
-
MC回復討論三:
inputs:?
? ?? ???PeriodType( numericsimple ),? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?
? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?
? ?? ???PeriodsAgo( numericsimple ),?
? ?? ???oPeriodOpen( numericref ),?
? ?? ???oPeriodHigh( numericref ),?
? ?? ???oPeriodLow( numericref ),?
? ?? ???oPeriodClose( numericref ) ;
variables:
? ?? ???var0( 0 ), sess_last_bar(false) ;
arrays:
? ?? ???arr0[ 4, 50 ]( -1 ) ;
sess_last_bar = sessionlastbar;
condition1 = PeriodsAgo > 50 or BarType > IFF(PeriodType<>0, PeriodType + 1, PeriodType + 2) or BarType > 4 ;
if condition1 then
? ?? ???begin
? ?? ???oPeriodOpen = -1 ;
? ?? ???oPeriodHigh = -1 ;
? ?? ???oPeriodLow = -1 ;
? ?? ???oPeriodClose = -1 ;
? ?? ???test_OHLCPeriodsAgo = -1 ;
? ?? ???end
else
? ?? ???begin
? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ??
? ?? ???if PeriodType = 0 then
? ?? ?? ?? ?? ? Condition1 = sess_last_bar[1] and time[1]<=1600 and time[1]>=1130
? ?? ???else if PeriodType = 1 then
? ?? ?? ?? ?? ? Condition1 = Date <> Date[1]
? ?? ???else if PeriodType = 2 then
? ?? ?? ?? ?? ? Condition1 = DayOfWeek( Date ) < DayOfWeek( Date[1] )
? ?? ???else if PeriodType = 3 then
? ?? ?? ?? ?? ? Condition1 = Month( Date ) <> Month( Date[1] )?
? ?? ???else if PeriodType = 4 then
? ?? ?? ?? ?? ? Condition1 = Year( Date ) <> Year( Date[1] ) ;
? ?? ???condition1 = CurrentBar = 1 or Condition1 ;
? ?? ???if condition1 then? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ???
? ?? ?? ?? ?? ? begin
? ?? ?? ?? ?? ? var0 = var0 - 1 ;? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?
? ?? ?? ?? ?? ? if var0 = -1?
? ?? ?? ?? ?? ?? ?? ?? ?then var0 = 50 ;? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ??
? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?
? ?? ?? ?? ?? ? arr0[ 1, var0 ] = O ;
? ?? ?? ?? ?? ? arr0[ 2, var0 ] = H ;
? ?? ?? ?? ?? ? arr0[ 3, var0 ] = L ;
? ?? ?? ?? ?? ? arr0[ 4, var0 ] = C ;
? ?? ?? ?? ?? ? end?
? ?? ???else if PeriodType = 1 and time<=1630 then? ?? ?? ?? ?? ?? ?? ?? ?? ???
? ?? ?? ?? ?? ? begin
? ?? ?? ?? ?? ? condition1 = H > arr0[ 2, var0 ] ;
? ?? ?? ?? ?? ? if condition1 then arr0[ 2, var0 ] = H ;
? ?? ?? ?? ?? ? condition1 = L < arr0[ 3, var0 ] ;
? ?? ?? ?? ?? ? if condition1 then arr0[ 3, var0 ] = L ;
? ?? ?? ?? ?? ? arr0[ 4, var0 ] = C ;
? ?? ?? ?? ?? ? end?
? ?? ???else if periodtype<>1 then
? ?? ?? ?? ?? ? begin
? ?? ?? ?? ?? ? condition1 = H > arr0[ 2, var0 ] ;
? ?? ?? ?? ?? ? if condition1 then arr0[ 2, var0 ] = H ;
? ?? ?? ?? ?? ? condition1 = L < arr0[ 3, var0 ] ;
? ?? ?? ?? ?? ? if condition1 then arr0[ 3, var0 ] = L ;
? ?? ?? ?? ?? ? arr0[ 4, var0 ] = C ;
? ?? ?? ?? ?? ? end ;
? ?? ?? ?? ?? ??
? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ??
? ?? ?? ?? ?? ?? ?? ?? ???
? ?? ???oPeriodOpen = arr0[ 1, Mod( var0 + PeriodsAgo, 51 ) ] ;
? ?? ???oPeriodHigh = arr0[ 2, Mod( var0 + PeriodsAgo, 51 ) ] ;
? ?? ???oPeriodLow = arr0[ 3, Mod( var0 + PeriodsAgo, 51 ) ] ;
? ?? ???oPeriodClose = arr0[ 4, Mod( var0 + PeriodsAgo, 51 ) ] ;
? ?? ???test_OHLCPeriodsAgo = 1 ;
? ?? ???end ;
? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?
? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ??
if false then
? ?? ???Value1 = test_OHLCPeriodsAgo[1] ;
這個是您需要的代碼,新建一個函數腳本,名稱命名為test_ohlcperiodsago即可,然后再新建test_highd函數,在內部調用test_ohlcperiodsago函數即可。?
-
MC回復討論四:
inputs:?
? ?? ???PeriodType( numericsimple ),? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?
? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?
? ?? ???PeriodsAgo( numericsimple ),?
? ?? ???oPeriodOpen( numericref ),?
? ?? ???oPeriodHigh( numericref ),?
? ?? ???oPeriodLow( numericref ),?
? ?? ???oPeriodClose( numericref ) ;
variables:
? ?? ???var0( 0 ), sess_last_bar(false) ;
arrays:
? ?? ???arr0[ 4, 50 ]( -1 ) ;
sess_last_bar = sessionlastbar;
condition1 = PeriodsAgo > 50 or BarType > IFF(PeriodType<>0, PeriodType + 1, PeriodType + 2) or BarType > 4 ;
if condition1 then
? ?? ???begin
? ?? ???oPeriodOpen = -1 ;
? ?? ???oPeriodHigh = -1 ;
? ?? ???oPeriodLow = -1 ;
? ?? ???oPeriodClose = -1 ;
? ?? ???test_OHLCPeriodsAgo = -1 ;
? ?? ???end
else
? ?? ???begin
? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ??
? ?? ???if PeriodType = 0 then
? ?? ?? ?? ?? ? Condition1 = sess_last_bar[1] and time[1]<=1600 and time[1]>=1130
? ?? ???else if PeriodType = 1 then
? ?? ?? ?? ?? ? Condition1 = Date <> Date[1]
? ?? ???else if PeriodType = 2 then
? ?? ?? ?? ?? ? Condition1 = DayOfWeek( Date ) < DayOfWeek( Date[1] )
? ?? ???else if PeriodType = 3 then
? ?? ?? ?? ?? ? Condition1 = Month( Date ) <> Month( Date[1] )?
? ?? ???else if PeriodType = 4 then
? ?? ?? ?? ?? ? Condition1 = Year( Date ) <> Year( Date[1] ) ;
? ?? ???condition1 = CurrentBar = 1 or Condition1 ;
? ?? ???if condition1 then? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ???
? ?? ?? ?? ?? ? begin
? ?? ?? ?? ?? ? var0 = var0 - 1 ;? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?
? ?? ?? ?? ?? ? if var0 = -1?
? ?? ?? ?? ?? ?? ?? ?? ?then var0 = 50 ;? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ??
? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?
? ?? ?? ?? ?? ? arr0[ 1, var0 ] = O ;
? ?? ?? ?? ?? ? arr0[ 2, var0 ] = H ;
? ?? ?? ?? ?? ? arr0[ 3, var0 ] = L ;
? ?? ?? ?? ?? ? arr0[ 4, var0 ] = C ;
? ?? ?? ?? ?? ? end?
? ?? ???else if PeriodType = 1 and time<=1630 then? ?? ?? ?? ?? ?? ?? ?? ?? ???
? ?? ?? ?? ?? ? begin
? ?? ?? ?? ?? ? condition1 = H > arr0[ 2, var0 ] ;
? ?? ?? ?? ?? ? if condition1 then arr0[ 2, var0 ] = H ;
? ?? ?? ?? ?? ? condition1 = L < arr0[ 3, var0 ] ;
? ?? ?? ?? ?? ? if condition1 then arr0[ 3, var0 ] = L ;
? ?? ?? ?? ?? ? arr0[ 4, var0 ] = C ;
? ?? ?? ?? ?? ? end?
? ?? ???else if periodtype<>1 then
? ?? ?? ?? ?? ? begin
? ?? ?? ?? ?? ? condition1 = H > arr0[ 2, var0 ] ;
? ?? ?? ?? ?? ? if condition1 then arr0[ 2, var0 ] = H ;
? ?? ?? ?? ?? ? condition1 = L < arr0[ 3, var0 ] ;
? ?? ?? ?? ?? ? if condition1 then arr0[ 3, var0 ] = L ;
? ?? ?? ?? ?? ? arr0[ 4, var0 ] = C ;
? ?? ?? ?? ?? ? end ;
? ?? ?? ?? ?? ??
? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ??
? ?? ?? ?? ?? ?? ?? ?? ???
? ?? ???oPeriodOpen = arr0[ 1, Mod( var0 + PeriodsAgo, 51 ) ] ;
? ?? ???oPeriodHigh = arr0[ 2, Mod( var0 + PeriodsAgo, 51 ) ] ;
? ?? ???oPeriodLow = arr0[ 3, Mod( var0 + PeriodsAgo, 51 ) ] ;
? ?? ???oPeriodClose = arr0[ 4, Mod( var0 + PeriodsAgo, 51 ) ] ;
? ?? ???test_OHLCPeriodsAgo = 1 ;
? ?? ???end ;
? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?
? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ??
if false then
? ?? ???Value1 = test_OHLCPeriodsAgo[1] ;
這個是您需要的代碼,新建一個函數腳本,名稱命名為test_ohlcperiodsago即可,然后再新建test_highd函數,在內部調用test_ohlcperiodsago函數即可。
有思路,想編寫各種指標公式,程序化交易模型,選股公式,預警公式的朋友
可聯系技術人員 QQ: 511411198 進行 有償 編寫!(不貴!點擊查看價格!)
相關文章
-
沒有相關內容