 |
ZHACK
初級會員
註冊日期: Sep 2011
來 自:
文章數量: 4 |
[問題]兩個問題(獲利點數顯示+策略變換)
想請問版主
1.請問有辦法在K線圖中的策略出場點下方顯示從進場到出場共賺(賠)多少點嗎???
用DRAWTEXT畫不出來
2.請問若我想在A,B兩不同進出場策略之間做替換
替換規則為
先執行A策略(包含多進,多出,空進,空出)
當A策略連續虧損兩次 停用A策略
改用B策略(包含多進,多出,空進,空出)
當B策略連續虧損兩次 停用B策略 改用A策略
如此循環 該怎麼寫呢
謝謝版主
|
|
向版主報告此篇 |  |
|
2011-09-26 02:12 |
|
|
|  |
 |
cgjj
總版主

註冊日期: Oct 2003
來 自:
文章數量: 18091 |
回覆: [問題]兩個問題(獲利點數顯示+策略變換)
引用: 最初由 ZHACK 發表
想請問版主
1.請問有辦法在K線圖中的策略出場點下方顯示從進場到出場共賺(賠)多少點嗎???
用DRAWTEXT畫不出來
謝謝版主
參考範例:
m1:ma(c,5);
m2:ma(c,20);
進場:=cross(m1,m2);
出場:=cross(m2,m1);
盈虧:=C-REF(Close,barslast(進場));
DRAWICON(進場,L,1) pxdn10;
DRAWICON(出場,H,2) pxup40;
DRAWNUMBER(出場,H,盈虧,2) pxup80 ALIGN0;
|
|
向版主報告此篇 |  |
|
2011-09-26 09:23 |
|
|
|  |
 |
cgjj
總版主

註冊日期: Oct 2003
來 自:
文章數量: 18091 |
回覆: [問題]兩個問題(獲利點數顯示+策略變換)
引用: 最初由 ZHACK 發表
想請問版主
2.請問若我想在A,B兩不同進出場策略之間做替換
替換規則為
先執行A策略(包含多進,多出,空進,空出)
當A策略連續虧損兩次 停用A策略
改用B策略(包含多進,多出,空進,空出)
當B策略連續虧損兩次 停用B策略 改用A策略
如此循環 該怎麼寫呢
謝謝版主
參考範例:
原碼:
m1:ma(c,5); m2:ma(c,20);
m3:ma(c,10); m4:ma(c,30);
進A:=cross(m1,m2) or barpos=0;
出A:=cross(m2,m1) or barpos=0;
進B:=cross(m3,m4) or barpos=0;
出B:=cross(m4,m3) or barpos=0;
UMode:=0; //值: 0.策略A, 1.策略B
NowBS:=0; 進價:=0; XCount:=0;
CC:=Close; DoBS:C*0 NOAXIS;
for i=1 to datacount do begin
if UMode=0 then begin
//策略A
if 進A[i] and NowBS=0 then begin
NowBS:=1; 進價:=CC[i]; DoBS[i]:=1;
end else if 出A[i] and NowBS=1 then begin
NowBS:=0; DoBS[i]:=2;
if CC[i]-進價<0 then begin
XCount:=XCount+1;
if XCount=2 then begin
XCount:=0; UMode:=1;
end;
end else begin
XCount:=0;
end;
end;
end else begin
//策略B
if 進B[i] and NowBS=0 then begin
NowBS:=1; 進價:=CC[i]; DoBS[i]:=3;
end else if 出B[i] and NowBS=1 then begin
NowBS:=0; DoBS[i]:=4;
if CC[i]-進價<0 then begin
XCount:=XCount+1;
if XCount=2 then begin
XCount:=0; UMode:=0;
end;
end else begin
XCount:=0;
end;
end;
end;
end;
DoBS 值意義:
1.A進, 2.A出, 3.B進, 4.B出
|
|
向版主報告此篇 |  |
|
2011-09-26 11:41 |
|
|
|  |
 |
ZHACK
初級會員
註冊日期: Sep 2011
來 自:
文章數量: 4 |
回覆: 回覆: [問題]兩個問題(獲利點數顯示+策略變換)
引用: 最初由 cgjj 發表
參考範例:
原碼:
m1:ma(c,5); m2:ma(c,20);
m3:ma(c,10); m4:ma(c,30);
進A:=cross(m1,m2) or barpos=0;
出A:=cross(m2,m1) or barpos=0;
進B:=cross(m3,m4) or barpos=0;
出B:=cross(m4,m3) or barpos=0;
UMode:=0; //值: 0.策略A, 1.策略B
NowBS:=0; 進價:=0; XCount:=0;
CC:=Close; DoBS:C*0 NOAXIS;
for i=1 to datacount do begin
if UMode=0 then begin
//策略A
if 進A[i] and NowBS=0 then begin
NowBS:=1; 進價:=CC[i]; DoBS[i]:=1;
end else if 出A[i] and NowBS=1 then begin
NowBS:=0; DoBS[i]:=2;
if CC[i]-進價<0 then begin
XCount:=XCount+1;
if XCount=2 then begin
XCount:=0; UMode:=1;
end;
end else begin
XCount:=0;
end;
end;
end else begin
//策略B
if 進B[i] and NowBS=0 then begin
NowBS:=1; 進價:=CC[i]; DoBS[i]:=3;
end else if 出B[i] and NowBS=1 then begin
NowBS:=0; DoBS[i]:=4;
if CC[i]-進價<0 then begin
XCount:=XCount+1;
if XCount=2 then begin
XCount:=0; UMode:=0;
end;
end else begin
XCount:=0;
end;
end;
end;
end;
DoBS 值意義:
1.A進, 2.A出, 3.B進, 4.B出
若A策略多空進出場策略均不同
請問要怎麼將A策略寫進去?
想要將下方語法加進版主的A,B策略中
THX
進L:=進多A or barpos=0;
出L:=出多A or barpos=0;
進S:=進空A or barpos=0;
出S:=出空A or barpos=0;
NowLS:=0; //1.多, -1.空, 0.無
DOLS:=C*0;
Do進:=進L-進S; Do出:=出L-出S;
for i=1 to datacount do begin
if NowLS=0 then begin
NowLS:=Do進[i]; DOLS[i]:=NowLS;
end else begin
if NowLS=-Do進[i] then begin
NowLS:=Do進[i]; DOLS[i]:=NowLS*3;
end else if NowLS=Do出[i] then begin
NowLS:=0; DOLS[i]:=Do出[i]*2;
end;
end;
end;
//整併後的結果
進L:=DOLS=1 or DOLS=3; //多進
出L:=DOLS=2 or DOLS=-3; //多出
進S:=DOLS=-1 or DOLS=-3; //空進
出S:=DOLS=-2 or DOLS=3; //空出
ENTERLONG: 進L;
EXITLONG: 出L;
ENTERSHORT: 進S;
EXITSHORT: 出S;
|
|
向版主報告此篇 |  |
|
2011-09-26 16:43 |
|
|
|  |
本站所有內容未經作者授權禁止轉貼節錄, 發表言論僅供參考勿作為投資決策依據。瀏覽本站請使用 IE 5.5 以上版本, 最佳瀏覽解析度 1024 x 768 全彩。
|
Powered by: vBulletin Version 2.3.0 - Copyright©2000-, Jelsoft Enterprises Limited.
簡愛洋行 製作 Copyright 2003-. All Rights Reserved. 聯絡我們
|