咨詢(xún)內(nèi)容:請(qǐng)問(wèn)各位老師,我想達(dá)到條件時(shí)開(kāi)倉(cāng)做空,用MARKETDATA_ReportNotify來(lái)追蹤止損下面的代碼對(duì)嗎?這樣在價(jià)格達(dá)到止損價(jià)格是,是馬上能夠觸發(fā)嗎? Sub Test2(code,market,price,stopprice)call marketdata.RegReportNotify(code,market) order.OrderQueue = 1if Hour(Time) >09 and Hour(Time) <=14 and SellHolding= 0 thencall order.buyshort(0,2,price,stopprice,code,market,"",0) '這里下限價(jià)單,能行嗎? end if
End Sub Sub MARKETDATA_ReportNotify(ReportData) '得到這品種的行情報(bào)價(jià)set ReportData = MarketData.GetReportData(code,market) '取指定持倉(cāng)品種信息call Order.HoldingInfoByCode2(code,market,BuyHoding1,BuyCost,BuyTodayHoding1,SellHoding1,SellCost,SellTodayHoding1,PNL,UseMargin) ''''''''''''''''品種信息 call order.Contract(code,market, Multipliter, MinTick, ShortPercent, LongPercent) if Hour(Time) >=09 and Hour(Time) <=14 and SellHolding > 0 then '止損時(shí)的報(bào)價(jià)是止損價(jià)格+10點(diǎn),保證必須成交if ReportData.buyPrice1 >= (zsprice) thencall Order.Sellshort(0,2,ReportData.buyPrice1+MinTick*2,0,code,market,"",0)application.MsgOut "注意!!!到達(dá)止損價(jià)格!!!"end if '達(dá)到2倍止損距離時(shí),平倉(cāng)1手,保留1手人工平倉(cāng)。 '止損時(shí)的報(bào)價(jià)是止損價(jià)格+5點(diǎn),保證必須成交if ReportData.SellPrice1 <= (kcprice-(zsprice-kcprice)*2) thencall Order.Sellshort(0,1,ReportData.SellPrice1+MinTick*2,0,code,market,"",0)application.MsgOut "到達(dá)第一目標(biāo)價(jià)格!!!"end if '達(dá)到5倍止損距離時(shí),全部平倉(cāng)。if ReportData.SellPrice1 <= (kcprice-(zsprice-kcprice)*5) thencall Order.Sellshort(1,1,ReportData.SellPrice1+MinTick*2,0,code,market,"",0)application.MsgOut "到達(dá)最終目標(biāo),剩余倉(cāng)位全部平倉(cāng)!!!"end ifend ifEnd Sub