一個系統交易的實例:夾板
作者:開拓者 TB 來源:cxh99.com 發布時間:2012年09月20日
- 咨詢內容: 夾板在實盤中是一個很常見的運用,用于吃住震蕩行情。它有個上軌和一個下軌,行情突破上軌就做空;突破下軌就做多,在上下軌之間來回吃。如圖:
OpenCoverFor2Lines函數代碼
- TB技術人員:
- // 返回值: 1:有所動作,0:沒有動作
- // 返回值為非零時,把當前要建立的頭寸大小和方向寫入needPosition,把以什么價格去建立該頭寸寫入needPrice
- // 返回值: 1:有所動作,0:沒有動作
- // 返回值為非零時,把當前要建立的頭寸大小和方向寫入needPosition,把以什么價格去建立該頭寸寫入needPrice
-
- Params
- Numeric currentPosition(0); // 當前頭寸,可正可負
- Numeric firstLots(0);
-
- Numeric wantShort(120); // 開空倉位置
- Numeric wantLong(8); // 開多倉位置
-
- Numeric wantStopShort(0); // 空頭止損的位置
- Numeric wantStopLong(0); // 多頭止損的位置
-
-
- // 注意:以下兩個都是引用變量?。。。?/li>
- NumericRef needPosition; // 經過計算后的當前頭寸,正數:建立多倉,負數:建立空倉,零:平光所有頭寸
- NumericRef needPrice; // 建立needPosition時的價格
-
- Vars
- Numeric tem;
-
- Begin
-
- // 14:55:00平掉當日所有頭寸
- if(time >= 0.1455 && currentPosition != 0)
- {
- needPosition = 0;
- needPrice = close ;
- return 1;
- }
- if(currentPosition == 0)
- {
- // 無倉,準備侍機開倉
- if(close <= wantLong)
- {
- // 多頭
- needPosition = firstLots;
- needPrice = wantLong;
- return 1;
- }
- if(close >= wantShort)
- {
- // 空頭
- needPosition = -1 * firstLots;
- needPrice = wantShort;
- return 1;
-
- }
- return 0;
- }
-
- if(currentPosition > 0)
- {
- // 持多倉,準備止損或反轉
- if(close >= wantShort)
- {
- // 反轉
- needPosition = -1 * firstLots;
- needPrice = wantShort;
- return 1;
- }
-
- if(close <= wantStopLong)
- {
- // 止損
- needPosition = 0;
- needPrice = wantStopLong;
- return 1;
-
- }
- return 0;
- }
- if(currentPosition < 0)
- {
- // 持空倉,準備止損或反轉
- if(close <= wantLong)
- {
- // 反轉
- needPosition = firstLots;
- needPrice = wantLong;
- return 1;
- }
-
- if(close >= wantStopShort)
- {
- // 止損
- needPosition = 0;
- needPrice = wantStopShort;
- return 1;
-
- }
- return 0;
- }
- return 0;
- End
復制代碼[ 本帖最后由 skywalker 于 2008-5-24 14:05 編輯 ]
夾板的公式導入文件
- TB客服: 夾板的公式導入文件:
twoLines.rar (5.32 KB, 下載次數: 749) 2008-5-24 14:09:23 上傳下載次數: 749
- 網友回復:
原帖由 skywalker 于 2008-5-24 13:52 發表 ![]()
tem = OpenCoverFor2Lines(MarketPosition(),firstLots,upperLine,lowerLine,wantStopShort,wantStopLong,needPosition,needPrice);
/* ******************************************************* ...
OpenCoverFor2Lines ?
- 網友回復: