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

[原创]等价K线交易之VBA(亏本大甩卖)!哈哈 [金字塔]

  • 咨询内容: 以下内容需要支付 1 个金币方可查看,您需要购买方可看到内容。您还未登录,不能购买。

     

  • 金字塔客服:

    i = 0
    open = 0
    m = 0
    k = 0
    j = 0
    dtyl = 0
    ktyl = 0
    qj = 5   //根据自己需要修改

    mj1close = 0
    mj2close = 0

    Sub dengjiaxian()
        ' 得到框架名称为"Technic",窗格名称为"Main"的窗格对象
        Set Grid = Technic.GetGridByName("Main")
        set minutedata = Grid.GetMinuteData
        Count =  minutedata.Count
        open = minutedata.newprice(0)
        mj1close = minutedata.newprice(0)
        mj2close = minutedata.newprice(0)

        for i = 1 to count-1
            close = minutedata.newprice(i)
            if close > open and close-open > qj then
               open = close
               if m = 0 then dtdbyk = 0 else dtdbyk = mj2close-close
               if m = 0-1 or m = 0 then
                  mj1close = close
                  dtyl = dtyl+dtdbyk
                  application.MsgOut Date &" " &Time&" "& "第"&i+1&"笔"&" "&"多:"&" "&close&" "&"单笔盈利"&" "&" "&dtdbyk&" "& "当日空头累计盈利为:" &dtyl
                  j = j+1
               end if
               m = 1
            elseif   close < open and open-close > qj then
               open = close
               if m = 0 then dtdbyk = 0 else ktdbyk = close - mj1close
               if m = 1 or m = 0 then
                  mj2close = close
                  ktyl = ktyl+ktdbyk
                  application.MsgOut Date &" " &Time&" "& "第"&i+1&"笔"&" "&"空:"&" "&close&" "&"单笔盈利"&" "&" "&ktdbyk&" "&"当日多头累计盈利为:" &ktyl
                  k = k+1
               end if
               m = 0-1
            end if
         next
    End Sub

    Sub APPLICATION_VBAStart()
     call Application.SetTimer(0,100) '创建一个0号定时器,间隔时间1秒
    End Sub

    Sub APPLICATION_Timer(ID)
        '定时器事件处理
         Application.ActivateFrame "Technic" '确保技术分析主框架处于激活状态
        
        ' 得到框架名称为"Technic",窗格名称为"Main"的窗格对象
        Set Grid = Technic.GetGridByName("Main")
        set minutedata = Grid.GetMinuteData
        Count =  minutedata.Count
            close = minutedata.newprice(Count-1)
         if Count-1 > i then  
            if close > open and close-open > qj then
               open = close
               if m = 0 then dtdbyk = 0 else dtdbyk = mj2close-close
               if m = 0-1 or m = 0 then
                  mj1close = close
                  dtyl = dtyl+dtdbyk
                  application.MsgOut Date &" " &Time&" "& "第"&i+1&"笔"&" "&"多:"&" "&close&" "&"单笔盈利"&" "&" "&dtdbyk&" "& "当日空头累计盈利为:" &dtyl
                  application.MsgOut Date &" " &Time&" "& "多头" &j& "次" &" "& "多头盈利" &ktyl& "点"&" "& "空头" &k& "次"&" "& "空头盈利" &dtyl& "点" &" "& "总计" &k+j& "次"&" "& "总盈利" &ktyl+dtyl& "点"
                  j = j+1
               end if
               m = 1
            elseif   close < open and open-close > qj then
               open = close
               if m = 0 then dtdbyk = 0 else ktdbyk = close - mj1close
               if m = 1 or m = 0 then
                  mj2close = close
                  ktyl = ktyl+ktdbyk
                  application.MsgOut Date &" " &Time&" "& "第"&i+1&"笔"&" "&"空:"&" "&close&" "&"单笔盈利"&" "&" "&ktdbyk&" "&"当日多头累计盈利为:" &ktyl
                  application.MsgOut Date &" " &Time&" "& "多头" &j& "次" &" "& "多头盈利" &ktyl& "点"&" "& "空头" &k& "次"&" "& "空头盈利" &dtyl& "点" &" "& "总计" &k+j& "次"&" "& "总盈利" &ktyl+dtyl& "点"
                  k = k+1
               end if
               m = 0-1
            end if      
         end if
    End Sub

    sub rnjy()
        call dengjiaxian()
        call APPLICATION_Timer(ID)
    End Sub  

     

    思路

    第一次运行宏的时候利用历史数据给出一个结果。

    然后根据实际情况给出实时的结果

     

    提示:我这里已经构架了整体的思路,只是没有写交易指令部分。有需要的朋友,直接添加VBA交易指令即可交易!

    这里只提供研究交流思路,模型不保证盈利!

    [此贴子已经被作者于2010-12-22 11:26:14编辑过]

     

  • 用户回复:

    好贵哦 能便宜点吗 啊哈哈

     

  • 网友回复: ADMIN送我金币 我想看看

     

  • 网友回复: 图片点击可在新窗口打开查看没金币啊 送我1个啊

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

相关文章

    没有相关内容