奇狐社區論壇
在這個頁面顯示本主題全部的 5 個文章

奇狐社區論壇 (http://www.chiefox.com.tw/bbs/index.php)
- 問題交流 (http://www.chiefox.com.tw/bbs/forumdisplay.php?forumid=28)
-- [問題]兩個問題(獲利點數顯示+策略變換) (http://www.chiefox.com.tw/bbs/showthread.php?threadid=16081)


由 ZHACK 在 2011-09-26 02:12 發表:

[問題]兩個問題(獲利點數顯示+策略變換)

想請問版主
1.請問有辦法在K線圖中的策略出場點下方顯示從進場到出場共賺(賠)多少點嗎???
用DRAWTEXT畫不出來

2.請問若我想在A,B兩不同進出場策略之間做替換
替換規則為
先執行A策略(包含多進,多出,空進,空出)
當A策略連續虧損兩次 停用A策略
改用B策略(包含多進,多出,空進,空出)
當B策略連續虧損兩次 停用B策略 改用A策略
如此循環 該怎麼寫呢

謝謝版主


由 cgjj 在 2011-09-26 09:23 發表:

回覆: [問題]兩個問題(獲利點數顯示+策略變換)

引用:
最初由 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;


由 cgjj 在 2011-09-26 11:41 發表:

回覆: [問題]兩個問題(獲利點數顯示+策略變換)

引用:
最初由 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進價:=0XCount:=0;
CC:=CloseDoBS: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
:=0DoBS[i]:=2;
      if 
CC[i]-進價<0 then begin
        XCount
:=XCount+1;
        if 
XCount=2 then begin
          XCount
:=0UMode:=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
:=0DoBS[i]:=4;
      if 
CC[i]-進價<0 then begin
        XCount
:=XCount+1;
        if 
XCount=2 then begin
          XCount
:=0UMode:=0;
        
end;
      
end else begin
        XCount
:=0;
      
end;
    
end;    
  
end;
end;

DoBS 值意義:
  1.A進, 2.A出, 3.B進, 4.B出


由 ZHACK 在 2011-09-26 16:43 發表:

回覆: 回覆: [問題]兩個問題(獲利點數顯示+策略變換)

引用:
最初由 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進價:=0XCount:=0;
CC:=CloseDoBS: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
:=0DoBS[i]:=2;
      if 
CC[i]-進價<0 then begin
        XCount
:=XCount+1;
        if 
XCount=2 then begin
          XCount
:=0UMode:=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
:=0DoBS[i]:=4;
      if 
CC[i]-進價<0 then begin
        XCount
:=XCount+1;
        if 
XCount=2 then begin
          XCount
:=0UMode:=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;


由 cgjj 在 2011-09-27 15:23 發表:

回覆: 回覆: 回覆: [問題]兩個問題(獲利點數顯示+策略變換)

引用:
最初由 ZHACK 發表
若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;
...........................



後面您貼的這段程式進出的做法
與前面我回您的那段程式, 思考點是不同的

後面這段其有反手做的情況 (DOLS=3 or DOLS=-3)
也就是有[多出]和[空進]在同根的狀況

前面給您的範例只有多方的部份處理, 並無空方的

若要將空方納入, 必需先了解您的訊號特性, 才能處理洽當
例如: 有無反手做的狀況, 多空是否有重疊之處


全部時間均為台灣時間, 現在時間為06:36
在這個頁面顯示本主題全部的 5 個文章


Powered by: vBulletin Version 2.3.0 - Copyright©2000-, Jelsoft Enterprises Limited.

簡愛洋行 製作 Copyright 2003-. All Rights Reserved.