開(kāi)拓者夾板交易策略源碼(振蕩交易模型)[開(kāi)拓者公式]
- 內(nèi)容: 夾板在實(shí)盤(pán)中是一個(gè)很常見(jiàn)的運(yùn)用,用于吃住震蕩行情。它有個(gè)上軌和一個(gè)下軌,行情突破上軌就做空;突破下軌就做多,在上下軌之間來(lái)回吃。
OpenCoverFor2Lines函數(shù)代碼
- 源碼:
- // 返回值: 1:有所動(dòng)作,0:沒(méi)有動(dòng)作
- // 返回值為非零時(shí),把當(dāng)前要建立的頭寸大小和方向?qū)懭雗eedPosition,把以什么價(jià)格去建立該頭寸寫(xiě)入needPrice
- // 返回值: 1:有所動(dòng)作,0:沒(méi)有動(dòng)作
- // 返回值為非零時(shí),把當(dāng)前要建立的頭寸大小和方向?qū)懭雗eedPosition,把以什么價(jià)格去建立該頭寸寫(xiě)入needPrice
- Params
- Numeric currentPosition(0); // 當(dāng)前頭寸,可正可負(fù)
- Numeric firstLots(0);
- Numeric wantShort(120); // 開(kāi)空倉(cāng)位置
- Numeric wantLong(8); // 開(kāi)多倉(cāng)位置
- Numeric wantStopShort(0); // 空頭止損的位置
- Numeric wantStopLong(0); // 多頭止損的位置
- // 注意:以下兩個(gè)都是引用變量?。。。?/li>
- NumericRef needPosition; // 經(jīng)過(guò)計(jì)算后的當(dāng)前頭寸,正數(shù):建立多倉(cāng),負(fù)數(shù):建立空倉(cāng),零:平光所有頭寸
- NumericRef needPrice; // 建立needPosition時(shí)的價(jià)格
- Vars
- Numeric tem;
- Begin
- // 14:55:00平掉當(dāng)日所有頭寸
- if(time >= 0.1455 && currentPosition != 0)
- {
- needPosition = 0;
- needPrice = close ;
- return 1;
- }
- if(currentPosition == 0)
- {
- // 無(wú)倉(cāng),準(zhǔn)備侍機(jī)開(kāi)倉(cāng)
- if(close <= wantLong)
- {
- // 多頭 www.tumamayizhan.com
- needPosition = firstLots;
- needPrice = wantLong;
- return 1;
- }
- if(close >= wantShort)
- {
- // 空頭
- needPosition = -1 * firstLots;
- needPrice = wantShort;
- return 1;
- }
- return 0;
- }
- if(currentPosition > 0)
- {
- // 持多倉(cāng),準(zhǔn)備止損或反轉(zhuǎn)
- if(close >= wantShort)
- {
- // 反轉(zhuǎn)
- needPosition = -1 * firstLots;
- needPrice = wantShort;
- return 1;
- }
- if(close <= wantStopLong)
- {
- // 止損
- needPosition = 0;
- needPrice = wantStopLong;
- return 1;
- }
- return 0;
- }
- if(currentPosition < 0)
- {
- // 持空倉(cāng),準(zhǔn)備止損或反轉(zhuǎn)
- if(close <= wantLong)
- {
- // 反轉(zhuǎn)
- needPosition = firstLots;
- needPrice = wantLong;
- return 1;
- }
- if(close >= wantStopShort)
- {
- // 止損
- needPosition = 0;
- needPrice = wantStopShort;
- return 1;
- }
- return 0;
- }
- return 0;
- End
- // 來(lái)源: www.tumamayizhan.com
有思路,想編寫(xiě)各種指標(biāo)公式,程序化交易模型,選股公式,預(yù)警公式的朋友
可聯(lián)系技術(shù)人員 QQ: 262069696 進(jìn)行 有償 編寫(xiě)!(不貴!點(diǎn)擊查看價(jià)格!)
相關(guān)文章
-
沒(méi)有相關(guān)內(nèi)容