[XS進階] 法人同買同賣日 20160331
variable:date1(0),date2(0),date3(3);
variable:msg(""); //宣告msg字串
value1=GetField("外資買賣超","D");
value2=GetField("投信買賣超","D");
value3=GetField("自營商買賣超","D");
value4=GetField("普通股股本","Q"); //單位:億
value5=GetField("法人買賣超張數","D"); //單位:千張
value6=(value5*10000)/(value4*100000000)*100;
//當日買賣超總面值佔股本比例
if value1<0 and value2<0 and value3<0 then //法人同賣
begin
date3=date;
end;
if value1>0 and value2>0 and value3>0 then //法人同買
begin
date1=date2;
date2=date;
ret=1;
end;
if date1>=date3 then msg="同買" else msg="同賣";
//偵測離最近一次是同買或同賣
//outputfield用來新增欄位
outputfield1(datetostring(date2),"同買日");
outputfield2(datetostring(date3),"上次同賣日");
outputfield3(datetostring(maxlist(date1,date3))+msg,"上次同買或同賣日");
outputfield4(value4,"股本");
outputfield5(value6,"佔股本%");