一、由于這里mp[1]取的是前一根bar的數(shù)值,并不是前一筆tick的數(shù)值,所以在限制bar只有一筆進(jìn)場和出場的情況下,如果mp<>mp[1]為true,那么在當(dāng)根bar內(nèi)就會一直為true。
二、close是實(shí)時變化的,所以在bar內(nèi)的某筆tick上close>=close[1]+5成立,然后aa變量被賦值為true;然后下一筆tick的時候,mp<>mp[1]仍然成立,aa又被賦值為false了;這時,close>=close[1]+5可能不再成立了,因為close在bar內(nèi)是實(shí)時變化的,這樣,aa變量就沒有達(dá)到您想要的效果。
三、使用barstatus關(guān)鍵字進(jìn)行判斷了一下,使mp<>mp[1] and flag=0這個條件在bar內(nèi)只可能成立一次,也就是mp<>mp[1]在bar內(nèi)第一次成立的時候,代碼如下:
[IntrabarOrderGeneration = True]?
setfpcompareaccuracy(fpcverylowaccuracy);
var:?
IntraBarPersist aa(False),
IntraBarPersist bb(False),
IntraBarPersist cc(0),
IntraBarPersist dd(0),
IntraBarPersist mp(0),
intrabarpersist flag(0);??
mp=marketposition;
if barstatus=0 then flag=0;
if mp<>mp[1] and flag=0??then begin?
? ? aa=False;?
? ? bb=False;?
? ? flag=1;
? ? end;
if Close>=Close[1]+5??then aa=True;
if aa then bb=true;
commentary(" 300yun=", bb) ;、close是實(shí)時變化的,所以在bar內(nèi)的某筆tick上close>=close[1]+5成立,然后aa變量被賦值為true;然后下一筆tick的時候,mp<>mp[1]仍然成立,aa又被賦值為false了;這時,close>=close[1]+5可能不再成立了,因為close在bar內(nèi)是實(shí)時變化的,這樣,aa變量就沒有達(dá)到您想要的效果。
三、使用barstatus關(guān)鍵字進(jìn)行判斷了一下,使mp<>mp[1] and flag=0這個條件在bar內(nèi)只可能成立一次,也就是mp<>mp[1]在bar內(nèi)第一次成立的時候,代碼如下:
[IntrabarOrderGeneration = True]?
setfpcompareaccuracy(fpcverylowaccuracy);
var:?
IntraBarPersist aa(False),
IntraBarPersist bb(False),
IntraBarPersist cc(0),
IntraBarPersist dd(0),
IntraBarPersist mp(0),
intrabarpersist flag(0);??
mp=marketposition;
if barstatus=0 then flag=0;
if mp<>mp[1] and flag=0??then begin?
? ? aa=False;?
? ? bb=False;?
? ? flag=1;
? ? end;
if Close>=Close[1]+5??then aa=True;
if aa then bb=true;
commentary(" 300yun=", bb) ;