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