新年獻(xiàn)禮:獲取主力合約最簡單的VBA代碼 [金字塔]
- 咨詢內(nèi)容:
'本過程需要兩個(gè)參數(shù)
'1.sMarketCode市場代碼,如中金所是ZJ,上期所SQ,鄭商所ZQ,大連所DQ
'2.sStockPre品種代碼的前綴,如股指IF,螺紋鋼RB等,就是合約代碼的符號,不要月份。
'調(diào)用方法:GetContractCode 'ZJ','IF' '返回股指期貨的主力合約
'調(diào)用上述過程之后,ZhuLiCode就保存了主力合約的代碼
'本方法是通過判斷那個(gè)合約的成交量與連續(xù)合約的成交量相等的方式來判斷主力合約的,跟金字塔內(nèi)部的方式一致。
public ZhuLiCode '主力合約代碼
Sub GetContractCode(sMarketCode,sStockPre) '根據(jù)市場編碼取得主力合約編碼
If sMarketCode="" then
sMarketCode="ZJ"
End if
n = marketdata.GetReportCount(sMarketCode)
For j = 0 To n - 1
Set report1 = marketdata.GetReportDataByIndex(sMarketCode, j)
suffixlabel = Right(report1.Label, 2)
If sStockPre=left(report1.Label,len(sStockPre)) then
If suffixlabel = "00" Then
ZhuLiVol=report1.volume
End If
If cdbl(suffixlabel) >= 1 And cdbl(suffixlabel) <= 12 Then
If report1.volume = ZhuLiVol Then
ZhuLiCode = report1.Label
'application.MsgOut ZhuLiCode
exit for
End If
End If
End if
Next
End Sub - 金字塔客服:
- 用戶回復(fù):
'本過程需要兩個(gè)參數(shù)
'1.sMarketCode市場代碼,如中金所是ZJ,上期所SQ,鄭商所ZQ,大連所DQ
'2.sStockPre品種代碼的前綴,如股指IF,螺紋鋼RB等,就是合約代碼的符號,不要月份。
'調(diào)用方法:GetContractCode 'ZJ','IF' '返回股指期貨的主力合約
'調(diào)用上述過程之后,ZhuLiCode就保存了主力合約的代碼
'本方法是通過判斷那個(gè)合約的成交量與連續(xù)合約的成交量相等的方式來判斷主力合約的,跟金字塔內(nèi)部的方式一致。
public ZhuLiCode '主力合約代碼
Sub GetContractCode(sMarketCode,sStockPre) '根據(jù)市場編碼取得主力合約編碼
If sMarketCode="" then
sMarketCode="ZJ"
End if
n = marketdata.GetReportCount(sMarketCode)
For j = 0 To n - 1
Set report1 = marketdata.GetReportDataByIndex(sMarketCode, j)
suffixlabel = Right(report1.Label, 2)
If sStockPre=left(report1.Label,len(sStockPre)) then
If suffixlabel = "00" Then
ZhuLiVol=report1.volume
End If
If cdbl(suffixlabel) >= 1 And cdbl(suffixlabel) <= 12 Then
If report1.volume = ZhuLiVol Then
ZhuLiCode = report1.Label
'application.MsgOut ZhuLiCode
exit for
End If
End If
End if
Next
End Sub - 網(wǎng)友回復(fù): 不錯(cuò),學(xué)習(xí)了
如果以上指標(biāo)公式不適用于您常用的行情軟件
或者您想改編成選股公式,以便快速選出某種形態(tài)個(gè)股的話,
- 上一篇:插件無法辨認(rèn)??不同電腦,不同問題。求助
- 下一篇:沒有了!
相關(guān)文章
-
指定的模型還沒有相關(guān)內(nèi)容!