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

奇狐社區論壇 (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=13406)


由 waterguyss 在 2010-04-08 12:59 發表:

[求救]如何加快運算速度?

U:=if(c>ref(c,1),c-ref(c,1),0);
D:=if(c<ref(c,1),ref(c,1)-c,0);
Usum:=sum(U,10);
Dsum:=sum(D,10);
RSI1:Usum*100/(Usum+Dsum);
minno:=lbound(RSI1);
maxno:=ubound(RSI1);
for i = minno+1 to maxno do begin
if Usum[i]+Dsum[i]=0 then Begin
if RSI1[i]=0 and RSI1[i-1]=100 then Begin
RSI1[i]:=100;
end;
end;
end;

請問以上奇狐程式碼 有辦法改寫成更快的運算方式嗎??

感謝~~ 


由 cgjj 在 2010-04-08 13:26 發表:

回覆: [求救]如何加快運算速度?

引用:
最初由 waterguyss 發表
U:=if(c>ref(c,1),c-ref(c,1),0);
D:=if(c<ref(c,1),ref(c,1)-c,0);
Usum:=sum(U,10);
Dsum:=sum(D,10);
RSI1:Usum*100/(Usum+Dsum);
minno:=lbound(RSI1);
maxno:=ubound(RSI1);
for i = minno+1 to maxno do begin
if Usum[i]+Dsum[i]=0 then Begin
if RSI1[i]=0 and RSI1[i-1]=100 then Begin
RSI1[i]:=100;
end;
end;
end;

請問以上奇狐程式碼 有辦法改寫成更快的運算方式嗎??

感謝~~ 



您是要算 RSI 指標嗎?
奇狐已有內建了唷
指標名稱就是 RSI


由 waterguyss 在 2010-04-08 13:30 發表:

我不是要用RSI指標
這是我自己要用的指標~~

請問以上奇狐程式碼 有辦法改寫成更快的運算方式嗎??
感謝~~ 

 


由 cgjj 在 2010-04-08 15:47 發表:

引用:
最初由 waterguyss 發表
我不是要用RSI指標
這是我自己要用的指標~~

請問以上奇狐程式碼 有辦法改寫成更快的運算方式嗎??
感謝~~ 

 



M:=c-ref(c,1);
Usum:=sum(if(M>0,M,0),10);
Dsum:=sum(if(M<0,-M,0),10);
UUDD:=Usum+Dsum;
RSI1:Usum*100/(UUDD);
CK:=UUDD=0 and RSI1=0;
RSI1:=if(CK and ref(RSI1,barslast(CK=0))=100,100,RSI1);


由 waterguyss 在 2010-04-08 16:56 發表:

引用:
最初由 cgjj 發表
M:=c-ref(c,1);
Usum:=sum(if(M>0,M,0),10);
Dsum:=sum(if(M<0,-M,0),10);
UUDD:=Usum+Dsum;
RSI1:Usum*100/(UUDD);
CK:=UUDD=0 and RSI1=0;
RSI1:=if(CK and ref(RSI1,barslast(CK=0))=100,100,RSI1);



大大您好:
CK:=UUDD=0 and RSI1=0; 這一行看不太懂
不過我猜 應該是這樣
創一個CK的數列
若 UUDD[i]=0 且 RSI1[i]=0 則 CK[i]=1 若不合則CK[i]=0

是這樣嗎???

感恩~


由 cgjj 在 2010-04-08 17:48 發表:

引用:
最初由 waterguyss 發表
大大您好:
CK:=UUDD=0 and RSI1=0; 這一行看不太懂
不過我猜 應該是這樣
創一個CK的數列
若 UUDD[i]=0 且 RSI1[i]=0 則 CK[i]=1 若不合則CK[i]=0

是這樣嗎???

感恩~



Yes


由 waterguyss 在 2010-04-08 18:58 發表:

再請教大大另ㄧ個程式碼



ll:=L;
hh:=H;
cc:=C;

X:=ㄧ些計算式
for i=1 to datacount do begin (把變數歸零)
....sig[i]:=0; (訊號變數 只有4個值 1 2 3 4)
....hl[i]:=0; (紀錄關鍵高低的變數)
end;
for i = 2 to datacount do begin
..if X[i-1]<=150 and X[i]>150 and sig[i-1]<>2then Begin
.....sig[i]:=1;
.....if sig[i-1]=1 or sig[i-1]=2 then Begin
........hl[i]:=hl[i-1];
.....end;
....else begin
.......hl[i]:=ll[i];
.....end;
..end else if X[i-1]>=70 and X[i]<70 and sig[i-1]<>4then Begin
.....sig[i]:=3;
.....if sig[i-1]=3 or sig[i-1]=4 then Begin
........hl[i]:=hl[i-1];
.....end;
.....else begin
........hl[i]:=hh[i];
.....end;
..end else if sig[i-1]=3 and cc[i]>hl[i-1] and X[i]>70 then Begin
.....sig[i]:=2;
..end else if sig[i-1]=1 and cc[i]<hl[i-1] and X[i]<150 then Begin
.....sig[i]:=4;
..end;
..else begin
......sig[i]:=sig[i-1];
......hl[i]:=hl[i-1];
..end;
end;


請問要怎麼改寫 讓他運算速度變快呢??
感謝

ps.因為不知怎麼縮排 所以用...代替


由 cgjj 在 2010-04-08 19:54 發表:

引用:
最初由 waterguyss 發表
再請教大大另ㄧ個程式碼



ll:=L;
hh:=H;
cc:=C;

X:=ㄧ些計算式
for i=1 to datacount do begin (把變數歸零)
....sig[i]:=0; (訊號變數 只有4個值 1 2 3 4)
....hl[i]:=0; (紀錄關鍵高低的變數)
end;
for i = 2 to datacount do begin
..if X[i-1]<=150 and X[i]>150 and sig[i-1]<>2then Begin
.....sig[i]:=1;
.....if sig[i-1]=1 or sig[i-1]=2 then Begin
........hl[i]:=hl[i-1];
.....end;
....else begin
.......hl[i]:=ll[i];
.....end;
..end else if X[i-1]>=70 and X[i]<70 and sig[i-1]<>4then Begin
.....sig[i]:=3;
.....if sig[i-1]=3 or sig[i-1]=4 then Begin
........hl[i]:=hl[i-1];
.....end;
.....else begin
........hl[i]:=hh[i];
.....end;
..end else if sig[i-1]=3 and cc[i]>hl[i-1] and X[i]>70 then Begin
.....sig[i]:=2;
..end else if sig[i-1]=1 and cc[i]<hl[i-1] and X[i]<150 then Begin
.....sig[i]:=4;
..end;
..else begin
......sig[i]:=sig[i-1];
......hl[i]:=hl[i-1];
..end;
end;


請問要怎麼改寫 讓他運算速度變快呢??
感謝

ps.因為不知怎麼縮排 所以用...代替



for i=1 to datacount do begin (把變數歸零)
....sig[i]:=0; (訊號變數 只有4個值 1 2 3 4)
....hl[i]:=0; (紀錄關鍵高低的變數)
end;

可簡化為這兩行
sig:=c*0;
hl:=sig;

其餘部份難以再簡化, 因為迴圈中有涉及累算
僅看程式碼, 不知原始要算的內容, 很難再優化處理


由 waterguyss 在 2010-04-08 22:27 發表:

再請教版大一個問題

假設我有ㄧ個30分線週期的交易系統(指標名稱為:30EMA)
我現在要在5分線的週期表現出來

5分線週期的程式碼如下:

買進:"30EMA.Buy#MIN30";
K30:=(minute>15 and minute<=20) or (minute>45 and minute<=50);
drawicon(買進 and K30,L-0.001*L,4);

因為30分K線的收盤時間都是每小時的15分和45分
我希望當30分K出現訊號時(例如:10:45分)
在5分K線的週期中 10:46~10:50這根K線低點畫出小箭頭
以上的程式碼是可以達成這個目的
只是有沒有更聰明更優化的寫法??
感恩~~


由 cgjj 在 2010-04-09 09:31 發表:

引用:
最初由 waterguyss 發表
再請教版大一個問題

假設我有ㄧ個30分線週期的交易系統(指標名稱為:30EMA)
我現在要在5分線的週期表現出來

5分線週期的程式碼如下:

買進:"30EMA.Buy#MIN30";
K30:=(minute>15 and minute<=20) or (minute>45 and minute<=50);
drawicon(買進 and K30,L-0.001*L,4);

因為30分K線的收盤時間都是每小時的15分和45分
我希望當30分K出現訊號時(例如:10:45分)
在5分K線的週期中 10:46~10:50這根K線低點畫出小箭頭
以上的程式碼是可以達成這個目的
只是有沒有更聰明更優化的寫法??
感恩~~



買進:"30EMA.Buy#MIN30";
買進:=買進 and ref(買進,1)=0;
drawicon(買進,L-0.001*L,4);


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


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

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