(急急急)為什么只能交易一次多單,之后就不交易了?大神們幫看
作者:開(kāi)拓者 TB 來(lái)源:cxh99.com 發(fā)布時(shí)間:2014年12月17日
- 咨詢(xún)內(nèi)容:
大神們幫看看,一下的程序在自動(dòng)化交易時(shí),這個(gè)程序就只做一次多,之后信號(hào)怎么變都不交易了。是什么問(wèn)題?謝謝啦!
會(huì)不會(huì)是NowHold=A_TotalPosition();需要返回的時(shí)間,后面的程序都執(zhí)行完了,還沒(méi)有返回正確的量,所以一直無(wú)法正確執(zhí)行?
Hold=策略計(jì)算出來(lái)的應(yīng)該的持倉(cāng)數(shù);(比如2代表2張多單,-1代表1張空單)
NowHold=A_TotalPosition();是現(xiàn)在賬戶(hù)持有的合約數(shù);
If(NowHold>0)
{
//加多單
If(Hold>NowHold){
DoSuccessful=Buy(Hold-NowHold,BuyPrice);
//減多單
}Else If(Hold<NowHold And Hold>=0){
DoSuccessful=Sell(NowHold-Hold,SellPrice);
//做空
}Else If(Hold<0){
DoSuccessful=SellShort(Abs(Hold),SellPrice);
}
//空倉(cāng)
}Else If(NowHold==0){
//做多
If(Hold>0){
DoSuccessful=Buy(Hold,BuyPrice);
//做空
}Else If(Hold<0){
PlotNumeric("Hold<0 NowHold=0",0);
DoSuccessful=SellShort(Abs(Hold),SellPrice);
}
//做空
}Else If(NowHold<0){
//做多
If(Hold>0){
DoSuccessful=Buy(Hold,BuyPrice);
//減空單
}Else If(Hold<=0 And Hold>NowHold){
DoSuccessful=BuyToCover(Hold-NowHold,BuyPrice);
//加空單
}Else If(Hold<NowHold){
DoSuccessful=SellShort(NowHold-Hold,SellPrice);
}
}
- TB技術(shù)人員:
nowhold的值在歷史K線(xiàn)都是無(wú)效值吧?那以此變量為判斷條件的信號(hào)除了最后K線(xiàn)應(yīng)該都消失了。