 |
cgjj
總版主

註冊日期: Oct 2003
來 自:
文章數量: 18091 |
回覆: 增加多轉空、空轉多條件?
引用: 最初由 sync 發表
cgjj 版主您好:
1、損盈計算我想用開盤價當進價,是否只要將CC:=C;改成CC:=O;就可以了?
2、小弟想增加多轉空、空轉多條件?
增加:
6.空出轉多
-6.多出轉空
//[進出] 這變數值代表意義如下:
//1.多單進場, 2.多單出場, 3.多控利出, 4.多控損出, 5.強制出場
//-1.空單進場,-2.空單出場,-3.空控利出, -4.空控損出, -5.強制出場
小弟自行嘗試將以下程式加入到程式最後:
end else if 多空=空進[i] or 多空=-多進[i] then begin
進出[i]:=-多空*6; 多空:=-多空;
發現多轉空、空轉多訊號應該沒問題,可是不會計算此次交易次數,
而且損盈計算會出現錯誤,造成不到停損點數卻出現停損出場訊號,
再次麻煩總版主幫忙,謝謝。
原碼:
強出:=TIME>=132000;
限進:=TIME>=130000;
多進:=B1 and 強出=0 and 限進=0 or barpos=0;
多出:=多補 or barpos=0;
空進:=S1 and 強出=0 and 限進=0 or barpos=0;
空出:=空補 or barpos=0;
進場:=多進-空進;
出場:=多出-空出;
控損:=30;
控利:=60;
進價:=0;
OO:=O; CC:=C; HH:=H; LL:=L;
多空:=0; //1.多 -1.空 0.無
進出:=C*0 NOAXIS;
DECK:=date<>ref(date,1) or barpos=1;
for i = 1 to datacount do begin
if DECK[i] then CountN:=0;
if 多空=0 then begin
if 進場[i]<>0 and CountN<3 then begin
多空:=進場[i]; 進出[i]:=多空;
進價:=OO[i]; CountN:=CountN+1;
end;
end else if 多空<>0 then begin
損HL:=LL[i]*(多空=1)+HH[i]*(多空=-1);
盈HL:=HH[i]*(多空=1)+LL[i]*(多空=-1);
損T:=(損HL-進價)*多空;
盈T:=(盈HL-進價)*多空;
if 強出[i] then begin
進出[i]:=多空*5; 多空:=0;
end else if 多空=出場[i] then begin
進出[i]:=多空*2; 多空:=0;
end else if 損T<=-控損 then begin
進出[i]:=多空*4; 多空:=0;
end else if 盈T>=控利 then begin
進出[i]:=多空*3; 多空:=0;
end else if 多空=空進[i] or 多空=-多進[i] then begin
進出[i]:=-多空*6; 多空:=-多空;
進價:=OO[i]; CountN:=CountN+1;
end;
end;
end;
其中的此段程式
end else if 多空=空進[i] or 多空=-多進[i] then begin
...............
end;
其位置是否要往前調整, 視您自行想法來決擇拿捏了
|
|
向版主報告此篇 |  |
|
2012-07-25 16:18 |
|
|
|  |
本站所有內容未經作者授權禁止轉貼節錄, 發表言論僅供參考勿作為投資決策依據。瀏覽本站請使用 IE 5.5 以上版本, 最佳瀏覽解析度 1024 x 768 全彩。
|
Powered by: vBulletin Version 2.3.0 - Copyright©2000-, Jelsoft Enterprises Limited.
簡愛洋行 製作 Copyright 2003-. All Rights Reserved. 聯絡我們
|