以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  高级功能研发区  (http://weistock.com/bbs/list.asp?boardid=5)
----  [原创]将asset输出到excel的自定义函数  (http://weistock.com/bbs/dispbbs.asp?boardid=5&id=4585)

--  作者: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;

 

效果图:

 

图片点击可在新窗口打开查看


--  作者:阿火
--  发布时间:2010/12/26 22:38:57
--  
牛,好东西。
--  作者:z7c9
--  发布时间:2011/1/6 18:18:51
--  
图片点击可在新窗口打开查看
--  作者:期指新手
--  发布时间:2011/1/6 19:53:29
--  

还不会做自定义函数,把资产会成每天盈亏怎么写?


--  作者:阿火
--  发布时间: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