folkchen 發表於 12-10-28 13:24
我是沒有逐筆去對,寫個小程式去比對沒有K棒的結算日就可以了
Hi, F大:
依照您的點子, 先比對 "預期結算日" 有沒有K棒, 若無, 順延到下一支,
我已寫出程式碼, 經過仔細逐筆核對交易所資料三次, 確定無誤.
這樣就不必列舉例外的結算日了.
預期結算日函數名稱: _ExpectedCloseDate 程式碼如下:
-------------------------------------------------------------------
var: pMon("");
var: pVar1(0);
pMon = MidStr(NumToStr(date,0),1,IFF(date < 1000101,4,5));
VALUE1 = StrToNum(pMon + "01");
VALUE2 = 3-DayOfWeek(VALUE1);
if VALUE2 < 0 then begin
VALUE2 = VALUE2 + 7;
end;
_ExpectedCloseDate = StrToNum(pMon)*100 + (VALUE2 + 15);
預期結算日函數, 是把MC官網函數程式碼,
例外結算日期全部刪掉.
------------------------------------------------------- 指標程式碼:
-------------------------------------------------------
var: SettledAlready(False);'此變數為當月結算與否的 flag
var:NumberOfText(0);
'若進入新月份, flag 歸 false
if month(date)<> month(date[1]) then begin
SettledAlready=False;
end;
'如果 大於或等於預期結算日,而且還沒有結算的話 ...
if date>= _ExpectedCloseDate and SettledAlready=False then begin
SettledAlready=True;
ARW_new(date, time, low, false);
NumberOfText=NumberOfText+1;
arw_setstyle(NumberOfText,14);
arw_setsize(NumberOfText,20);
arw_setcolor(NumberOfText,yellow);
arw_settextbgcolor(NumberOfText,Blue);
arw_settextcolor(NumberOfText,White);
arw_settext(NumberOfText, MidStr(NumToStr(date,0),2,6));
end;
謝謝您的點子!
|