一個(gè)系統(tǒng)交易的實(shí)例:夾板
作者:開拓者 TB 來源:cxh99.com 發(fā)布時(shí)間:2012年09月20日
- 咨詢內(nèi)容: 夾板在實(shí)盤中是一個(gè)很常見的運(yùn)用,用于吃住震蕩行情。它有個(gè)上軌和一個(gè)下軌,行情突破上軌就做空;突破下軌就做多,在上下軌之間來回吃。如圖:
OpenCoverFor2Lines函數(shù)代碼
- TB技術(shù)人員:
- // 返回值: 1:有所動(dòng)作,0:沒有動(dòng)作
- // 返回值為非零時(shí),把當(dāng)前要建立的頭寸大小和方向?qū)懭雗eedPosition,把以什么價(jià)格去建立該頭寸寫入needPrice
- // 返回值: 1:有所動(dòng)作,0:沒有動(dòng)作
- // 返回值為非零時(shí),把當(dāng)前要建立的頭寸大小和方向?qū)懭雗eedPosition,把以什么價(jià)格去建立該頭寸寫入needPrice
-
- Params
- Numeric currentPosition(0); // 當(dāng)前頭寸,可正可負(fù)
- Numeric firstLots(0);
-
- Numeric wantShort(120); // 開空倉(cāng)位置
- Numeric wantLong(8); // 開多倉(cāng)位置
-
- Numeric wantStopShort(0); // 空頭止損的位置
- Numeric wantStopLong(0); // 多頭止損的位置
-
-
- // 注意:以下兩個(gè)都是引用變量?。。?!
- NumericRef needPosition; // 經(jīng)過計(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)
- {
- // 無倉(cāng),準(zhǔn)備侍機(jī)開倉(cāng)
- if(close <= wantLong)
- {
- // 多頭
- 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
復(fù)制代碼[ 本帖最后由 skywalker 于 2008-5-24 14:05 編輯 ]
夾板的公式導(dǎo)入文件
- TB客服: 夾板的公式導(dǎo)入文件:
twoLines.rar (5.32 KB, 下載次數(shù): 749) 2008-5-24 14:09:23 上傳下載次數(shù): 749
- 網(wǎng)友回復(fù):
原帖由 skywalker 于 2008-5-24 13:52 發(fā)表 ![]()
tem = OpenCoverFor2Lines(MarketPosition(),firstLots,upperLine,lowerLine,wantStopShort,wantStopLong,needPosition,needPrice);
/* ******************************************************* ...
OpenCoverFor2Lines ?
- 網(wǎng)友回復(fù):