 |
waterguyss
初級會員
註冊日期: Apr 2010
來 自:
文章數量: 7 |
[求救]如何加快運算速度?
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;
請問以上奇狐程式碼 有辦法改寫成更快的運算方式嗎??
感謝~~
|
|
向版主報告此篇 |  |
|
2010-04-08 12:59 |
|
|
|  |
 |
cgjj
總版主

註冊日期: Oct 2003
來 自:
文章數量: 18172 |
回覆: [求救]如何加快運算速度?
引用: 最初由 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
|
|
向版主報告此篇 |  |
|
2010-04-08 13:26 |
|
|
|  |
 |
waterguyss
初級會員
註冊日期: Apr 2010
來 自:
文章數量: 7 |
我不是要用RSI指標
這是我自己要用的指標~~
請問以上奇狐程式碼 有辦法改寫成更快的運算方式嗎??
感謝~~
|
|
向版主報告此篇 |  |
|
2010-04-08 13:30 |
|
|
|  |
 |
cgjj
總版主

註冊日期: Oct 2003
來 自:
文章數量: 18172 |
引用: 最初由 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);
|
|
向版主報告此篇 |  |
|
2010-04-08 15:47 |
|
|
|  |
 |
waterguyss
初級會員
註冊日期: Apr 2010
來 自:
文章數量: 7 |
引用: 最初由 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
是這樣嗎???
感恩~
|
|
向版主報告此篇 |  |
|
2010-04-08 16:56 |
|
|
|  |
 |
waterguyss
初級會員
註冊日期: Apr 2010
來 自:
文章數量: 7 |
再請教大大另ㄧ個程式碼
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.因為不知怎麼縮排 所以用...代替
|
|
向版主報告此篇 |  |
|
2010-04-08 18:58 |
|
|
|  |
 |
waterguyss
初級會員
註冊日期: Apr 2010
來 自:
文章數量: 7 |
再請教版大一個問題
假設我有ㄧ個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線低點畫出小箭頭
以上的程式碼是可以達成這個目的
只是有沒有更聰明更優化的寫法??
感恩~~
|
|
向版主報告此篇 |  |
|
2010-04-08 22:27 |
|
|
|  |
本站所有內容未經作者授權禁止轉貼節錄, 發表言論僅供參考勿作為投資決策依據。瀏覽本站請使用 IE 5.5 以上版本, 最佳瀏覽解析度 1024 x 768 全彩。
|
Powered by: vBulletin Version 2.3.0 - Copyright©2000-, Jelsoft Enterprises Limited.
簡愛洋行 製作 Copyright 2003-. All Rights Reserved. 聯絡我們
|