請(qǐng)問(wèn)老師,我想達(dá)到條件時(shí)開(kāi)倉(cāng)做空,用MARKETDATA_ReportNotify來(lái)追蹤止損下面的代碼對(duì)嗎? [金字塔]
- 咨詢內(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 then call 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) then call 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) then call 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) then call Order.Sellshort(1,1,ReportData.SellPrice1+MinTick*2,0,code,market,"",0) application.MsgOut "到達(dá)最終目標(biāo),剩余倉(cāng)位全部平倉(cāng)!?。? end if end if End Sub - 金字塔客服:
具體你用一下調(diào)試手段就可以了。
此外你要注意一下,下單前你要判斷是否有未成交單存在,或者下單后保留委托ID,待收到該委托ID的成交回報(bào)或者下單撤單失敗回報(bào)等情況后重置狀態(tài),這樣防止出現(xiàn)連續(xù)交易的現(xiàn)象
[此貼子已經(jīng)被作者于2014/3/21 18:20:50編輯過(guò)] - 用戶回復(fù):
謝謝您的回復(fù),我剛接觸金字塔的VBA沒(méi)多久,不知道怎么用調(diào)試的功能。您有沒(méi)有相關(guān)的例子介紹給我?謝謝了
- 網(wǎng)友回復(fù): “下單前你要判斷是否有未成交單存在,或者下單后保留委托ID,待收到該委托ID的成交回報(bào)或者下單撤單失敗回報(bào)等情況后重置狀態(tài),這樣防止出現(xiàn)連續(xù)交易的現(xiàn)象” 還有您說(shuō)的這些,不知道怎么弄啊。請(qǐng)問(wèn)代碼在哪能查到?
有思路,想編寫(xiě)各種指標(biāo)公式,程序化交易模型,選股公式,預(yù)警公式的朋友
可聯(lián)系技術(shù)人員 QQ: 1145508240 進(jìn)行 有償 編寫(xiě)!(不貴!點(diǎn)擊查看價(jià)格!)
相關(guān)文章
-
沒(méi)有相關(guān)內(nèi)容