sub marketdata_reportnotify(reportdata)
dim multiplier
dim mintick
dim shortpercent
dim longpercent
dim buyhoding
dim buytodayhoding
dim sellhoding
dim selltodayhoding
dim buycost
dim sellcost
dim pnl
dim usemargin
dim orderid
dim consign
dim filled
dim remaining
dim ordertype
dim lmtprice
lots=1
account="888888"
code=reportdata.label
market=reportdata.marketname
len=strlen(code)
prefix=strleft(code,len-2)
if prefix="IF" then
totalbars=270
myentrytime=time>#9:16:00# and time<#15:14:00#
myexittime=time>=#15:15:00#
else
totalbars=225
myentrytime=time>#9:01:00# and time<#14:59:00#
myexittime=time>=#15:00:00#
end if
exitbars=code&"_exitbars"
actiontime=code&"_actiontime"
set myreport=marketdata.getreportdata(code,market)
set myhistory=marketdata.gethistorydata(code,market,0)
set myminutedata=marketdata.getminutedata(code,market)
barpos1=myhistory.count-1
high1=myhistory.high(barpos1-1)
low1=myhistory.low(barpos1-1)
barpos2=myminutedata.count-1
minvolume=200
entrylongcond=myreport.newprice>=high1 and myreport.sellvolume1<=minvolume and barpos1>document.getextdata(exitbars)
entryshortcond=myreport.newprice<=low1 and myreport.buyvolume1<=minvolume and barpos1>document.getextdata(exitbars)
entrylongprice=myreport.newprice
entryshortprice=myreport.newprice
call order.contract(code,market,multiplier,mintick,shortpercent,longpercent)
call order.holdinginfobycode2(code,market,buyholding,buycost,buytodayholding,sellholding,sellcost,selltodayholding,pnl,usemargin,account)
stoploss=2*mintick
breakeven=mintick
sleeptime=1
if document.getextstring(actiontime)="" then
actiondiff=sleeptime
else
actiondiff=datediff("s",document.getextstring(actiontime),now)
end if
if actiondiff<sleeptime then
exit sub
end if
if buyholding=0 and sellholding=0 then
call getpendingorder(orderid,consign,filled,remaining,0,ordertype,lmtprice,account,0,code,market)
if entrylongcond then
if remaining=0 then
order.buy 0,lots,entrylongprice,0,code,market,account,0
call document.setextstring(actiontime,now)
call document.setextdata(downs,0)
application.msgout code&"多开下单"
exit sub
elseif entrylongprice>lmtprice then
order.cancelorder orderid
call document.setextstring(actiontime,now)
application.msgout code&"多开撤单"
exit sub
end if
end if
end if
if buyholding=0 and sellholding=0 then
call getpendingorder(orderid,consign,filled,remaining,1,ordertype,lmtprice,account,0,code,market)
if entryshortcond then
if remaining=0 then
order.buyshort 0,lots,entryshortprice,0,code,market,account,0
call document.setextstring(actiontime,now)
call document.setextdata(ups,0)
application.msgout code&"空开下单"
exit sub
elseif entryshortprice<lmtprice then
order.cancelorder orderid
call document.setextstring(actiontime,now)
application.msgout code&"空开撤单"
exit sub
end if
end if
end if
if buyholding>0 and sellholding=0 then
if myminutedata.bidprice(barpos2)<myminutedata.bidprice(barpos2-1) and myminutedata.askprice(barpos2)<myminutedata.askprice(barpos2-1) then
call document.setextdata(downs,document.getextdata(downs)+1)
end if
call getpendingorder(orderid,consign,filled,remaining,1,ordertype,lmtprice,account,2,code,market)
if myreport.buyprice1<=buycost-stoploss and myreport.buyvolume1<=minvolume then
if remaining=0 then
order.sell 0,buyholding,myreport.buyprice1,0,code,market,account,0
call document.setextstring(actiontime,now)
call document.setextdata(exitbars,barpos1)
application.msgout code&"多损下单"
exit sub
elseif myreport.buyprice1<lmtprice then
order.cancelorder orderid
call document.setextstring(actiontime,now)
application.msgout code&"多损撤单"
exit sub
end if
elseif document.getextdata(downs)>=1 then
if remaining=0 then
order.sell 0,buyholding,buycost+breakeven,0,code,market,account,0
call document.setextstring(actiontime,now)
call document.setextdata(exitbars,barpos1)
application.msgout code&"多盈下单"
exit sub
elseif buycost+breakeven<lmtprice then
order.cancelorder orderid
call document.setextstring(actiontime,now)
application.msgout code&"多盈撤单"
exit sub
end if
end if
end if
if buyholding=0 and sellholding>0 then
if myminutedata.bidprice(barpos2)>myminutedata.bidprice(barpos2-1) and myminutedata.askprice(barpos2)>myminutedata.askprice(barpos2-1) then
call document.setextdata(ups,document.getextdata(ups)+1)
end if
call getpendingorder(orderid,consign,filled,remaining,0,ordertype,lmtprice,account,2,code,market)
if myreport.sellprice1>=sellcost+stoploss and myreport.sellvolume1<=minvolume then
if remaining=0 then
order.sellshort 0,sellholding,myreport.sellprice1,0,code,market,account,0
call document.setextstring(actiontime,now)
call document.setextdata(exitbars,barpos1)
application.msgout code&"空损下单"
exit sub
elseif myreport.sellprice1>lmtprice then
order.cancelorder orderid
call document.setextstring(actiontime,now)
application.msgout code&"空损撤单"
exit sub
end if
elseif document.getextdata(ups)>=1 then
if remaining=0 then
order.sellshort 0,sellholding,sellcost-breakeven,0,code,market,account,0
call document.setextstring(actiontime,now)
call document.setextdata(exitbars,barpos1)
application.msgout code&"空盈下单"
exit sub
elseif sellcost-breakeven>lmtprice then
order.cancelorder orderid
call document.setextstring(actiontime,now)
application.msgout code&"空盈撤单"
exit sub
end if
end if
end if
end sub
sub getpendingorder()
application.MsgOut "sss"
dim orderid
dim consign
dim filled
dim remaining
dim action
dim ordertype
dim lmtprice
dim account
dim kaiping
dim code
dim market
for i=0 to order.ordernum2-1
call order.orderinfo2(i,orderid,consign,filled,remaining,action,ordertype,lmtprice,account,kaiping,code,market)
application.MsgOut "account="&account
if code=mycode and market=mymarket and action=myaction and kaiping=mykaiping and account=myaccount then
myorderid=orderid
myconsign=consign
myfilled=filled
myremaining=remaining
myordertype=ordertype
mylmtprice=lmtprice
exit for
else
myorderid=0
myconsign=0
myfilled=0
myremaining=0
myordertype=0
mylmtprice=0
end if
next
end sub
sub mytest()
if time>=#8:23:00# and time<=#8:24:00# then
application.MsgOut time
else
application.MsgOut "aa"
end if
end sub
哪位高人翻译(注解)一下
请问此策略是基于什么样的理论?
楼主请翻译(注解)一下,谢谢