根据版主的代码,做了一个跟单的小插件,其中包含了正向和反向追单;还有相关的设置手数框。每次设置完之后,按下确定按钮,跟单账户就会乖乖的跟着被跟单账号下单了,结束程序代码只需按下shift+break即可。
'建议窗体对象内的代码只编写与本窗体事件有关的代码,不要使用作用于整个工程的变量及过程函数。
'''''''''''''''''''FX初始状态为-1 正向0 反向1
dim FX
dim ss
dim iCode
dim iMarket
dim SL
SL = 0
'在vba运行之时,对控件进行赋值
sub application_vbastart()
CoVer_combobox1.clear
CoVer_combobox1.style=frmstyledropdownlist
CoVer_ComboBox1.BoundColumn = 0
CoVer_ComboBox1.AddItem "正向"
CoVer_ComboBox1.AddItem "反向"
CoVer_ComboBox1.ListIndex=0
FX = -1
CoVer_Label2.Caption = " "
ss = 0
end sub
'单击确认按钮之后确认跟单方向
Sub CoVer_CommandButton1_Click()
if CoVer_ComboBox1.value = 0 then
FX = 0
ss = CoVer_textbox1.text
CoVer_Label2.caption = "正向跟单已确认 可点击最小化 " & " 跟踪手数为: " & ss
end if
if CoVer_ComboBox1.value = 1 then
FX = 1
ss = CoVer_textbox1.text
CoVer_Label2.caption = "反向跟单已确认 可点击最小化" & " 跟踪手数为: " & ss
end if
CoVer.minbutton =true
End Sub
'利用金字塔强大的order对象对每笔回报进行反馈
Sub ORDER_OrderStatusEx2(OrderID, Status, Filled, Remaining, Price, Code, Market, OrderType, Aspect, Kaiping, Account, AccountType)
''''''''''''''''''''''''跟从账户
if Status="Tradeing" and filled>0 and Account=CoVer_textbox2.text then
'正向跟踪
IF FX =0 THEN
if aspect=0 then
if kaiping=0 then order.Buy 1,ss,0,0,code,market,CoVer_textbox3.text,0
if kaiping>0 then order.sellshort 1,ss,0,0,code,market,CoVer_textbox3.text,0
'msgbox iCode & " " & iMarket
end if
if aspect=1 then
if kaiping=0 then order.Buyshort 1,ss,0,0,code,market,CoVer_textbox3.text,0
if kaiping>0 then order.sell 1,ss,0,0,code,market,CoVer_textbox3.text,0
end if
end if
'反向跟踪
IF FX=1 THEN
if aspect=1 then
if kaiping=0 then order.Buy 1,ss,0,0,code,market,CoVer_textbox3.text,0
if kaiping>0 then order.sellshort 1,ss,0,0,code,market,CoVer_textbox3.text,0
end if
if aspect=0 then
if kaiping=0 then order.Buyshort 1,ss,0,0,code,market,CoVer_textbox3.text,0
if kaiping>0 then order.sell 1,ss,0,0,code,market,CoVer_textbox3.text,0
end if
end if
END IF
'未成交单查询,不断做提示,大家也可以+点代码 让他发出声音或者发群消息/邮件/短信,不断骚扰你
IF Remaining<>0 then
call application.SetTimer(1,1000)
end if
End Sub
sub application_timer(id)
dim Orderid '订单ID
dim Filled '提交手数
dim Remaining '剩余手数
dim Action '买卖
dim OrderType '订单类型
dim LmtPrice '委托价
dim Account '账户
dim Kaiping '开平
dim i
i=0
if id = 1 then
if order.OrderNum2<>0 then
For i=0 to order.OrderNum2-1
Call Order.OrderInfo2(i,OrderID,ConSign,Filled,Remaining,Action,OrderType,LmtPrice,Account,Kaiping,Code,Market)
call application.MsgOut("有未成交单 市场代码: "&Market&" "&" "&"品种代码: " & Code)
Next
end if
if order.OrderNum2 = 0 then
application.KillTimer(id)
end if
end if
end sub
sub application_vbaend()
application.KillTimer(id)
end sub
下载信息 [文件大小: 下载次数: ] | |
![]() |
做成多个账户的最好,比如五个。
导入后,点击执行脚本 为什么没有窗口出现?