等价K线交易之VBA源码[其他期货软件]
思路
第一次运行宏的时候利用历史数据给出一个结果。
然后根据实际情况给出实时的结果
提示:我这里已经构架了整体的思路,只是没有写交易指令部分。有需要的朋友,直接添加VBA交易指令即可交易!
这里只提供研究交流思路,模型不保证盈利!
- 源码内容:
i = 0
open = 0
m = 0
k = 0
j = 0
dtyl = 0
ktyl = 0
qj = 5 //根据自己需要修改mj1close = 0
mj2close = 0Sub 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 SubSub APPLICATION_VBAStart()
call Application.SetTimer(0,100) '创建一个0号定时器,间隔时间1秒
End SubSub 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 Subsub rnjy()
call dengjiaxian()
call APPLICATION_Timer(ID)
End Sub
有思路,想编写各种指标公式,程序化交易模型,选股公式,预警公式的朋友
可联系技术人员 QQ: 262069696 进行 有偿 编写!(不贵!点击查看价格!)
相关文章
-
没有相关内容