How to do Trading Technical analysis calculations in sql server?
How i can do Technical Analysis indicator calculations like Average directiona开发者_开发百科l index, stochastic oscillators etc in SQL SERVER database by using T-SQL as doing in excel? If it possible, is it good for making procudures as doing macros in excel. Thanks in advance.
Procedural code is written in T-SQL in MS SQL Server. It's as good as Excel macros and perhaps a bit more powerful, but they aren't likely to be as familiar to you as good old Excel.
Figuring out where to do the calculations can be a difficult choice. It all depends on the performance you can get out of the T-SQL compared to the difficulties of doing this work client-side (replicating updates, etc.)
If you decide that you want to attempt to write these types of queries in T-SQL, here is a good article that will help you get started (it won't do your work for you but it will show you all the pieces you should need to do what you want):
http://www.sqlservercentral.com/articles/Moving+Average/69389/
In this article, the author shows how to use T-SQL to develop the Moving Averages. You can look at this article as a starting place for adapting your formulas into T-SQL.
Writing technical analysis code in T-SQL is not a good idea. If you really want to execute it on Database server; then I would recommend writing your code in any .NET language and uploading the code to SQL Server. Then you can invoke that code from T-SQL using "User defined functions". See this link.
I have done similar things in Oracle for a different purpose.
If possible, try to see if you can execute the code in client side or on a web server if that is applicable in your case.
精彩评论