您现在的位置:程序化交易>> 期货公式>> 金字塔等>> 金字塔知识>>正文内容

[求助]能把这个老代码改一下吗? [金字塔]

  • 咨询内容:  
    '窗体启动时初始化编辑框内容
    Sub SearchMaincode_Load()
    SearchMaincode_TextBoxType.Text = Document.GetPrivateProfileString("JZT","TextBoxType","概念","C:\JTZSetting.INI")
    SearchMaincode_TextBoxBlock.Text = Document.GetPrivateProfileString("JZT","TextBoxBlock","主力合约","C:\JTZSetting.INI")
    End Sub

    Sub SearchMaincode_CommandButton1_Click()
    SearchStart()
    End Sub

    '该函数查找主力合约
    Sub SearchStart()

    application.MsgOut Date &" " &Time& "检索主力合约"
    Dim marketName
    Set dominantContract=CreateObject("Scripting.Dictionary") '创建一个字典
    marketName=Array("SQ","DQ","ZQ","ZJ","SY")
    prefixStockNameOld=""
    c"
    contractVol=0

    '找到的主力合约代码放这里
    dim labels
    dim markets

    For j=0 To UBound(marketName)
    n=marketData.GetReportCount(marketName(j))
    For i=0 To n-1
    Set reportData=marketdata.GetReportDataByIndex(marketName(j),i)
    prefixStockNameCur=left(reportData.StockName,2)
    suffixStockNameCur=right(reportData.StockName,2)
    If suffixStockNameCur>="00" And suffixStockNameCur<"99" And reportData.Volume>0 Then
    If prefixStockNameCur<>prefixStockNameOld Then
    If contractLabel<>"" Then
    dominantContract.Add contractMarket & contractLabel, 0
    End If
    prefixStockNameOld=prefixStockNameCur
    contractLabel=reportData.Label
    contractMarket=marketName(j)
    contractVol=reportData.Volume
    ElseIf reportData.Volume>contractVol then
    contractLabel=reportData.Label
    contractVol=reportData.Volume
    End If

    End If
    Next
    Next
    dominantContract.Add contractMarket & contractLabel,0

    labels=dominantContract.Keys
    markets=dominantContract.Keys

    FndCount = UBound(dominantContract.Keys)
    Application.MsgOut "共找到"&FndCount&"个合约"

    If FndCount > 0 Then
    '整理一下数据,将市场和代码分开
    For j=0 To FndCount
    markets(j) = left(labels(j),2)
    labels(j) = right(labels(j),len(labels(j))-2)
    Next
    SaveBlockAndOpen labels, markets
    Else
    MsgBox "没有找到主力合约"
    End if

    End Sub

    '将找到的合约存于板块,并打开动态盘
    Sub SaveBlockAndOpen(labels, markets)

    Document.WritePrivateProfileString "JZT","TextBoxType",SearchMaincode_TextBoxType.Text,"C:\JTZSetting.INI"
    Document.WritePrivateProfileString "JZT","TextBoxBlock",SearchMaincode_TextBoxBlock.Text,"C:\JTZSetting.INI"

    '保存到板块
    Set b = CreateObject("Stock.Block")
    For j=0 To UBound(labels)
    call b.AddStock(markets(j),labels(j))
    Next
    call b.toSave(SearchMaincode_TextBoxType.Text,SearchMaincode_TextBoxBlock.Text)

    '打开动态显示牌
    Application.ActivateFrame "Report"
    Set Table = Report.GetGridByName("上海指数").GetTable()
    Table.SwitchBlock SearchMaincode_TextBoxBlock.Text, 1
    End Sub



    SearchMaincode
    用来搜索主力合约的
    但是没有搜索夜盘品种好像
    谁能补充一下?

     

  • 金字塔客服: marketName=Array("SQ","DQ","ZQ","ZJ","SY")
    你这里夜盘市场有了啊,本地这边运行后有夜盘品种的

     

  • 用户回复:

    这个代码可能由于论坛限制,有些不全

     

  • 网友回复:  老大~论坛里以前有搜索主力合约的VBA代码 的~现在出了夜盘了~

    能否更新一下?

     

  • 网友回复:  你们这几个股票指数一放进来~这个vba一运行老是搜出来好多股票指数

 

有思路,想编写各种指标公式,程序化交易模型,选股公式,预警公式的朋友

可联系技术人员 QQ: 1145508240  点击这里给我发消息进行 有偿 编写!不贵!点击查看价格!


【字体: 】【打印文章】【查看评论

相关文章

    没有相关内容