怎样用VBS实现指定账户权益低于90万时强行平仓? [金字塔]
- 咨询内容:
如题
- 金字塔客服:
楼主可以打开帮助参考下VBA中的Order对象
另外软件内下单设置——止盈止损中中也是可以设置的
- 用户回复:
- 网友回复:
使用VBA编写的代码量较大,在此无法给你编写完整的,给出你一个实现的想法思路
1、你应该了解金字塔VBA的定时器功能,定期1秒检测帐户的动态权益,有关定时器的部分论坛已经很多讨论了,你可以自行搜索一下
2、这里给你摘抄部分的判断动态权益全部强平的部分代码
IsAlarm = 0'是否已经有过预警动作
dynamicpower= order.Account2(6,account)'得到账户动态权益
cash= order.Account2(3,account)'得到账户里的现金余额'//////////////////////////////////////////////////////////////////////////////////////////达到全平警戒线 强平资金:103,5000 当前权益只有103.5W的时候强平当前所有持仓
if dynamicpower<Forced_liquidation_capital and Count1 + Count2 > 0 then
application.PlaySoundFile "OrderNotify.wav"
IsAlarm = 1
Forced=1
if count1 > 0 Or Count2 > 0 then
application.MsgOut "强平"&Account&"账户所有持仓"
application.MsgOut "动态权益: "&dynamicpower
application.MsgOut "强平资金: "&Forced_liquidation_capital
Document.DebugFile "C:\OrderLog.txt","执行了强平:"&Account&"账户所有持仓", 1
End if
'//////////////////////////////////////////////////////////////////////////////////////////全平操作
dim BuyHoding
dim BuyCost
dim BuyTodayHoding
dim SellHoding
dim SellCost
dim SellTodayHoding
dim PNL
dim UseMargin
dim Code
dim Market
for i=0 to count1 - 1
Result = Order.HoldingInfo2(i,BuyHoding,BuyCost,BuyTodayHoding,SellHoding,SellCost,SellTodayHoding,PNL,UseMargin ,Code,Market)
If Result <> 1 Then
exit sub
End If
set Report1 = marketdata.GetReportData(Code,Market)
'application.MsgOut Report1.NewPriceif BuyHoding<>0 then
call order.Sell(1,BuyHoding,Report1.NewPrice,0,Code,Market,account,0)
application.MsgOut "品种:"&Code & " 平多:"&BuyHoding &" 账户:"&account
end if
if SellHoding<>0 then
call order.Sellshort(1,SellHoding,Report1.NewPrice,0,Code,Market,account,0)
application.MsgOut "品种:"&Code & " 平空:"&SellHoding&" 账户:"&account
end if
next
for i=0 to count2 - 1Result = Order.HoldingInfo(i, BuyHoding, BuyCost, BuyTodayHoding, SellHoding, SellCost, PNL, Code, Market)
If Result <> 1 Then
exit sub
End If
set Report1 = marketdata.GetReportData(Code,Market)
'application.MsgOut Report1.NewPriceif BuyHoding>0 then
call order.Sell(1,BuyHoding,Report1.NewPrice,0,Code,Market,account,0)
application.MsgOut "品种:"&Code & " 平多:"&BuyHoding &" 账户:"&account
end if
if BuyHoding<0 then
call order.Sellshort(1,BuyHoding,Report1.NewPrice,0,Code,Market,account,0)
application.MsgOut "品种:"&Code & " 平空:"&abs(BuyHoding) &" 账户:"&accountend if
next
end if
如果以上指标公式不适用于您常用的行情软件
或者您想改编成选股公式,以便快速选出某种形态个股的话,
- 上一篇:_declspec(dllexport) int WINAPI MYMAVA…
- 下一篇:没有了!
相关文章
-
没有相关内容