一、由于這里mp[1]取的是前一根bar的數值,并不是前一筆tick的數值,所以在限制bar只有一筆進場和出場的情況下,如果mp<>mp[1]為true,那么在當根bar內就會一直為true。
二、close是實時變化的,所以在bar內的某筆tick上close>=close[1]+5成立,然后aa變量被賦值為true;然后下一筆tick的時候,mp<>mp[1]仍然成立,aa又被賦值為false了;這時,close>=close[1]+5可能不再成立了,因為close在bar內是實時變化的,這樣,aa變量就沒有達到您想要的效果。
三、使用barstatus關鍵字進行判斷了一下,使mp<>mp[1] and flag=0這個條件在bar內只可能成立一次,也就是mp<>mp[1]在bar內第一次成立的時候,代碼如下:
[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是實時變化的,所以在bar內的某筆tick上close>=close[1]+5成立,然后aa變量被賦值為true;然后下一筆tick的時候,mp<>mp[1]仍然成立,aa又被賦值為false了;這時,close>=close[1]+5可能不再成立了,因為close在bar內是實時變化的,這樣,aa變量就沒有達到您想要的效果。
三、使用barstatus關鍵字進行判斷了一下,使mp<>mp[1] and flag=0這個條件在bar內只可能成立一次,也就是mp<>mp[1]在bar內第一次成立的時候,代碼如下:
[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) ;