longCurrentVolume函数怎么调用

算法: 一、满足a\b条件,买1手 二、满足a\b\c条件,买2手(需要检查现有持仓:如果空仓,直接买2手;如果有1手,再买1手) 请问是用longCurrentVolume函数来检查持仓吗,怎么调用它?

longCurrentVolume是Position结构体的一个属性,您可以在OnPosition事件中去调用。

回复:谢谢,说明文档好像没看到例子,我先试一试。

回复:蔡老师,麻烦说明一下pos.longCurrentVolume的用法,想实现:不足2手时,再买1手。 我写出来,要么是不断加仓,要么就没有买入信号。 Vars Global Integer myPos; //Numeric myPos; OnPosition(PositionRef pos) { //pos.longCurrentVolume = myPos ; myPos = pos.longCurrentVolume ; } If (MarketPosition <> 1 And ConCloseBigMa1 == True And ConMACDLong1 == True ) { Buy(1,data0.Open); myPos = myPos + 1 ; Commentary("myPos"+Text(myPos)); //显示的是之前买入的累加和,忽略了sell(0,open)作用? } If (MarketPosition == 1 And ConCloseBigMa1 == False Or ConExitMACDLong1 == True ) { sell(0,data0.Open); } //If (MarketPosition <> 1 And ConCloseBigMa1 == True And ConMACDLong2 == True) If (myPos < 2 And ConCloseBigMa1 == True And ConMACDLong2 == True) { Buy(1,data0.Open); myPos = myPos + 1 ; } If (MarketPosition == 1 And ConCloseBigMa1 == False Or ConExitMACDLong1 == True ) { sell(0,data0.Open); }

回复:用BuySell写的策略,难道非要通过检查账户实际仓位来控制加减仓吗?用CurrentContracts不也能控制吗

回复:对了,谢谢指点,好多函数的确不太熟悉。