-- 作者:z7c9
-- 发布时间:2010/12/25 17:36:35
-- [原创]将asset输出到excel的自定义函数
自定义函数MyAssets:
以下内容为程序代码:
1 dim oexcel 2 3 Function MyAssets(Formula,barpos,year,month,day,asset) 4 \'系统会在逐周期模式解释公式时的每个周期都会调用此函数一遍,因此设计时应该注重程序的执行效率,不要重复的执行一些没必要的代码 5 if barpos=1 then 6 set oexcel=createobject("excel.application") 7 oexcel.visible=true 8 oexcel.workbooks.add 9 end if 10 11 oexcel.cells(barpos,1)=cstr(year)+"-"+cstr(month)+"-"+cstr(day) 12 oexcel.cells(barpos,2)=asset 13 14 End Function
MyAssets使用示例:
以下内容为程序代码:
1 buy(holding=0 and weekday=1,1,limitr,open); 2 sell(holding>0 and weekday=2,holding,limitr,close); 3 4 myassets(barpos,year,month,day,round(asset)),linethick0;
效果图:

|
-- 作者:阿火
-- 发布时间:2011/1/7 10:02:27
--
if time=closetime(0) then
myasset:=asset-valuewhen(date<>ref(date,1),asset);
myassets(barpos,year,month,day,round(myasset)),linethick0;
end
|