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