我有個需求是
1.需要將過去五年的資料(收盤價) 判斷條件(大於月線)後分別放入陣列,之後須把陣列重複的數據給移除,再加以排序,那目前的程序如下,發現運行的時間會很久(約20-30秒),請問有改善方法 。
Value1 = DateAdd(date, "D", -365*5);
value2 = GetBarOffset(Value1);
Array_SetMaxIndex(array_top, 1825);
topCount=0;
For i = 0 to value2-1
Begin
t_sma20= average(close[i],20);
if close[i]>t_sma20 a then
begin
array_top[topCount] = t_sma20;
topCount=topCount+1;
end;
Array_SetMaxIndex(array_top, topCount);
//排序
Array_Sort(array_top,0,topCount-1,true);
//刪除同樣的元素
j=0;
For i=0 to topCount-1
begin
if array_top[j]<>array_top[i] then
begin
j=j+1;
array_top[j]=array_top[i];
end;
end;
topCount=j+1;
2.請問有矩陣自動刪除同樣元素的函示嗎?
11 評論