如何bar內(nèi)傳遞 [MC]
-
MC用戶求助:
一、由于這里mp[1]取的是前一根bar的數(shù)值,并不是前一筆tick的數(shù)值,所以在限制bar只有一筆進(jìn)場(chǎng)和出場(chǎng)的情況下,如果mp<>mp[1]為true,那么在當(dāng)根bar內(nèi)就會(huì)一直為true。
二、close是實(shí)時(shí)變化的,所以在bar內(nèi)的某筆tick上close>=close[1]+5成立,然后aa變量被賦值為true;然后下一筆tick的時(shí)候,mp<>mp[1]仍然成立,aa又被賦值為false了;這時(shí),close>=close[1]+5可能不再成立了,因?yàn)閏lose在bar內(nèi)是實(shí)時(shí)變化的,這樣,aa變量就沒(méi)有達(dá)到您想要的效果。
三、使用barstatus關(guān)鍵字進(jìn)行判斷了一下,使mp<>mp[1] and flag=0這個(gè)條件在bar內(nèi)只可能成立一次,也就是mp<>mp[1]在bar內(nèi)第一次成立的時(shí)候,代碼如下:
[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í)時(shí)變化的,所以在bar內(nèi)的某筆tick上close>=close[1]+5成立,然后aa變量被賦值為true;然后下一筆tick的時(shí)候,mp<>mp[1]仍然成立,aa又被賦值為false了;這時(shí),close>=close[1]+5可能不再成立了,因?yàn)閏lose在bar內(nèi)是實(shí)時(shí)變化的,這樣,aa變量就沒(méi)有達(dá)到您想要的效果。
三、使用barstatus關(guān)鍵字進(jìn)行判斷了一下,使mp<>mp[1] and flag=0這個(gè)條件在bar內(nèi)只可能成立一次,也就是mp<>mp[1]在bar內(nèi)第一次成立的時(shí)候,代碼如下:
[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) ;
有思路,想編寫各種指標(biāo)公式,程序化交易模型,選股公式,預(yù)警公式的朋友
可聯(lián)系技術(shù)人員 QQ: 511411198 進(jìn)行 有償 編寫!(不貴!點(diǎn)擊查看價(jià)格!)
相關(guān)文章
-
沒(méi)有相關(guān)內(nèi)容