Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Hey so I got Accord.net up and running on NT8, but the documentation on its code is very limited. I want to work with it more, who has experience coding with it, examples, doesn't necessarily have to be with NT. Simply how to use its functions and what they can do.
Ok Ill get this going so more people can start working and developing with Accord Net. I created two indicators to show how its done., linear and polynomial regression. Please use this to learn how to code for Accord Net for indicators. There is so much more potential with this add on, neural networks, machine learning, regression, complicated mathematics.
If you have trouble adding the dlls to NT, please let me know. Also, these indicators are for NT8 only! Pass on the good will.
I am currently working on a multi linear regression indicator, but no dice. Anyone can figure it out? I am trying to use past price data, 1, 2 bars ago, as inputs, and 0 bars ago as outputs. NT8 with Accord Net only.
Looks like some great work, I have some older Accord DLLs and need to update before I can try these. I haver 3.0.2 but looks like you are using a few newer classes such as "PolynomialLeastSquares()" which from the manual requires:
Assembly: Accord.Statistics (in Accord.Statistics.dll) Version: 3.4.0
I will update a bit later and try this out. You are right, Accord brings a lot of power to .NET and NinjaTrader.
The biggest issue is figuring out how to use its functions. It was trial and error to figure the first two out. The poly is not as smooth as i hoped for. Also, copy the dlls to your NT bin program file location. Reference from there.
Ya, had to find the ZIP version for 3.4 on Github, got everything setup but broke my older code with 3.0.2, some major changes in this release. I had some matrix math functions that I had to disable, will get back to that later.
Hummm..... One of the reasons I stopped using Accord.NET were a few bugs I found and couldn't get corrected. I am starting to think after a quick review, there may be bugs in the " PolynomialLeastSquares()" class... The Intercept just makes no sense even when I set the input/output data to a straight line (0,0), (1,1), ... (Period-1,Period-1). Also, the sign seems inverted and might be off by one degree of freedom.
I have modified the PolyRegression OnBarUpdate() to include the following, using the Transform() value of the point we wish to predict (-1.0) as you have time running backwards to point 0.0. I first started to work with predicting the next PolyRegressionLine[] point to smooth the line, to no avail. It just doesn't seem to be working right based upon the output of the 3rd degree fit:
The sample output is:
You can see the Intercept doesn't match, the sign is inverted. Also, it is a 3rd Degree Polynomial so there should be an X^3 term and doesn't show. Not exactly sure what might be wrong, but seems like the "Learn()" didn't work right maybe because of the missing X^3 in the hypothesis?
For the Linear case "OrdinaryLeastSquares()" things seem to work with this codeblock:
You can see this is a 1st degree equation, linear, and the Intercept matches and has the X^1 term.
Here is my output from my original code. The weights are either extremely small or large, intercept very big. but the line is more or less similar to other poly regs.
I think your code covers some of the problem with the base class so I wouldn't trust it. The Intercept shouldn't be that big, it should be around the Final Time Point (as X=0 at that point).
I don't think it is your code, you should use the "Transform" to make sure you are doing the vector math correctly... Usually it is A1*X^1+A2*X^2... I think you may have reversed it to get a reasonable answer: A1*X^3+....
I also don't think the Intercept should appear (even with the wrong sign) in the weights, so I just think there is a calculation problem in Accord.