金字塔盈利加倉,虧損減倉代碼[金字塔模型]
- 咨詢內(nèi)容:
關(guān)于加倉減倉問題
比如ma(c,5)和ma(c,10)和ma(c,30)三根線開多
收盤價(jià)高于一根均線就加倉一次每低于一根線就減倉一次,直到holding=0.
開空收盤價(jià)低于一根均線就加倉一次
每高于一根線就減倉一次,直到holding=0.
ma5:ma(c,5);
ma10:ma(c,10);
ma30:ma(c,30);
//開多
if holding<=0 and c>ma5 and c<ma10 and c<ma30,then begin
sellshort(1,3,market);
buy(1,1,market);
end
//多加倉
if holding=1 and c>ma5 and c>ma10 and c<ma30 then buy(1,1,market);
if holding=2 and c>ma5 and c>ma10 and c>ma30 then buy(1,1,market);
if holding=-1 and c>ma5 and c>ma10 and c>ma30 then buy(1,3,market);
//平多加倉
if holding=2 and c>ma5 and c<ma10 and c<ma30 then sell(1,1,market);//開空
if (holding=3 or holding=0) and c>ma5 and c>ma10 and c<ma30 then BEGIN
sell(1,3,market);
buyshort(1,1,market);
end
//空加倉
if holding=-1 and c>ma5 and c<ma10 and c<ma30 then buyshort(1,1,market);
if holding=-2 and c<ma5 and c<ma10 and c<ma30 then buyshort(1,1,market);
if holding=1 and c<ma5 and c<ma10 and c<ma30 then buyshort(1,3,market);
//平空加倉
if holding=-2 and c>ma5 and c<ma10 and c<ma30 then sellshort(1,1,market);
有思路,想編寫各種指標(biāo)公式,程序化交易模型,選股公式,預(yù)警公式的朋友
可聯(lián)系技術(shù)人員 QQ: 262069696 進(jìn)行 有償 編寫!(不貴!點(diǎn)擊查看價(jià)格!)
相關(guān)文章
-
沒有相關(guān)內(nèi)容