等级: 新手上路
- 注册:
- 2021-7-30
- 曾用名:
|
Sub StartTrade(sAccountID, sCode,sMarket)
set myreport=marketdata.GetReportData(sCode,sMarket)
'iFlag=document.GetExtData(lotflag01)+ document.GetExtData(lotflag02)
'application.MsgOut now & "显示持仓量:" &"信号:"&iFlag
'lotflags=sCode&"_flags"
iOpenVol=iFlag-(iBuyHold-iSellHold)'汇总持仓
' if iopenvol>0 and document.GetExtData(lotflags)=0 then
' Call document.SetExtData(lotflags,iopenvol)
' end if
' if iopenvol< 0 and document.GetExtData(lotflags)=0 then
' Call document.SetExtData(lotflags,-1*iopenvol)
' end if
'if iFlag>0 and document.GetExtData(lotflags)>0 then '信号是多单
if iFlag>0 then '信号是多单
iOpenVol=iFlag-(iBuyHold- iSellHold) '信号持仓-实际持仓,如果为正,说明信号持仓持仓大,那么就要补充开仓,如果小,说明实际持仓大,就得平掉多单
if iSellHold>0 then '如果此时帐户持有空单,就把空单全部平掉
Call order.SellShort(0,iSellHold,0,0,sCode,sMarket,sAccountID,0)
end if
if iOpenVol>0 then
Call order.Buy(0,iOpenVol,myreport.UpperLimitPrice,0,sCode,sMarket,sAccountID,0)
'Call document.SetExtData(lotflags,10)
elseif iOpenVol<0 then
Call order.Sell(0,Abs(iOpenVol),myreport.LowerLimitPrice,0,sCode,sMarket,sAccountID,0)
'Call document.SetExtData(lotflags,10)
end if
end if
'if iFlag<0 and document.GetExtData(lotflags)<0 then '信号是空单
if iFlag<0 then '信号是空单
iOpenVol=iFlag-(iBuyHold- iSellHold) '信号持仓-实际持仓,如果为正,说明信号持仓大,那么就要补充开仓,如果小,说明实际持仓大,就得平掉多单
if iBuyHold>0 then '如果此时帐户持有duo单,就把duo单全部平掉
Call order.Sell(0,iBuyHold,myreport.LowerLimitPrice,0,sCode,sMarket,sAccountID,0)
end if
if iOpenVol>0 then
Call order.SellShort(0,iOpenVol,myreport.UpperLimitPrice,0,sCode,sMarket,sAccountID,0)
'Call document.SetExtData(lotflags,10)
elseif iOpenVol<0 then
'Call order.BuyShort(0,Abs(iOpenVol),0,0,sCode,sMarket,sAccountID,0)
Call order.BuyShort(0,Abs(iOpenVol),myreport.LowerLimitPrice,0,sCode,sMarket,sAccountID,0)
'Call document.SetExtData(lotflags,10)
'application.MsgOut "信号:"&Abs(iOpenVol) & "价格:"&sAccountID & "周期:"& sCode & "shichang:"& sMarket
end if
end if
if iFlag=0 then '如果图表信号为0,就是没有持仓,那么将帐户的多、空单全部平掉
if iBuyHold>0 then '平帐户多单
Call order.Sell(0,iBuyHold,myreport.LowerLimitPrice,0,sCode,sMarket,sAccountID,0)
end if
if iSellHold>0 then '平帐户空单
Call order.SellShort(0,iSellHold,myreport.UpperLimitPrice,0,sCode,sMarket,sAccountID,0)
end if
end if
'application.MsgOut now & "持仓量:" &"信号1:"& iOpenVol
'application.MsgOut "信号:"&iOpenVol & "价格:"&sAccountID & "周期:"& sCode & "shichang:"& iBuyHold
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''http://www.weistock.com/bbs/dispbbs.asp?boardid=5&id=80709&page=0&move=next
|
|