累加 [金字塔]
- 咨询内容:
为什么这个CS1不会进行累加呢?我输出后它一直是等于1。Dim ID1Sub TLStart()
'注册CF09和CF11品种
call marketdata.RegReportNotify("CU05","SQ")
call marketdata.RegReportNotify("AL05","SQ")End Sub'响应注册的品种行情变化通知Sub MARKETDATA_ReportNotify(ReportData)
'得到这两个品种的行情报价
Set Report1 = marketdata.GetReportData("CU05","SQ")
Set Report2 = marketdata.GetReportData("AL05","SQ")
'得到品种的持仓量等信息
dim BuyHoding1
dim BuyHlding2
dim BuyTodayHoding1
dim BuyTodayHoding2
dim SellHoding1
dim SellHoding2
dim SellTodayHoding1
dim SellTodayHoding2
dim BuyCost
dim SellCost
dim PNL
Dim UseMargin Dim cs1
'取指定持仓品种信息
call Order.HoldingInfoByCode2("CU05","SQ",BuyHoding1,BuyCost,BuyTodayHoding1,SellHoding1,SellCost,SellTodayHoding1,PNL,UseMargin)
call Order.HoldingInfoByCode2("AL05","SQ",BuyHoding2,BuyCost,BuyTodayHoding2,SellHoding2,SellCost,SellTodayHoding2,PNL,UseMargin) num = ORDER.ORDERNUM2
'当差价出现大于1800时进行套利开仓
Diff = Report1.SellPrice1 - Report2.BuyPrice1 '分别取卖价和买价计算差价 application.MsgOut TIME&", "&Report1.SellPrice1&", "&Report2.BuyPrice1&", "&Diff if Diff < 33315 then CS1= CS1+1 End if if CS1=1 then ID1 = Order.Buy(0,1,46100,0,"CU05","SQ","",0) ID2 = Order.BuyShort(1,1,Report2.BuyPrice1,0,"AL05","SQ","",0) application.MsgOut TIME&", "&ID1&","&ID2 end if
application.MsgOut CS1 End Sub [此贴子已经被作者于2017/3/27 9:53:54编辑过] - 金字塔客服:
Dim cs1 ‘变量定义放在过程外面而不是在行情事件触发时候每次初始
Dim ID1 Sub TLStart() - 用户回复:
在过程里不能申明模块级变量跟全局变量吗?
此主题相关图片如下:变量.png
有思路,想编写各种指标公式,程序化交易模型,选股公式,预警公式的朋友
可联系技术人员 QQ: 511411198 进行 有偿 编写!(不贵!点击查看价格!)
相关文章
-
没有相关内容