Trading my strategy / Polynomial curve fitting / Iterate through rule variables
Author: supermagnetman
Creation Date: 10/18/2017 6:08 PM
profile picture

supermagnetman

#1
OK, As I continued to work to get the user interface better (re. the 1 point type used on the screen) I have found that wearing 3 pairs of reading glasses stacked on each other helps a lot but lots of the dialog boxes are still a matter of guess work as to what their label is, so the answer to my question my be more obvious if I the UI worked better. Just wanted to get that out there in case my question seemed ridiculous.

QUESTION 1 - I have successfully played with lots of strategies, created several rule based strategies and tweaked the variables to see the back test results. Now I want to go to the next step and connect this with my account and start using it in trading one test stock according to the rules strategy. I can't find anything that seems to do that. I think that is one aspect of the program that it does but I can't find where that is. I did use the data manager and connect to my account and it pulls in the list of the stocks. What I would really like would be for the program to be looking at the market data and provide some kind of signal for me to look at and make a trading decision.

QUESTION 2 - it looks like most of the strategies and rules are based on linear trend analysis. Are there any that would use like polynomial curve fitting? If not, if I dump the data out to Excel and develop, for example, a 7th order polynomial curve fitting equation to model a stock, is there a way to enter such an equation in the editor?

QUESTION 3 - Is there a way to programmatically set up a rules based strategy and iterate through its variables to determine which setting obtains the best performance? For example, It is interesting to see that for some stocks a 20 day moving average may lose money but a 12 day moving average beats the "buy and hold" option by 2 to 1. What I am doing is modeling a stock and then iterating manually through a range for the setting and recording the results to determine optimum. It would be nice if that could be done in a loop.

Thanks
I am getting to love this program despite my UI problems and hopefully one day that will get fixed.
George
profile picture

Eugene

#2
Hi George,

Nice to know you're having progress. As a one-time exception I will answers your assorted questions in this thread but should you need some follow-up re: any of these answers, I kindly ask you to either create new topics or search the forum and reuse closely matching forum threads.

QUOTE:
Now I want to go to the next step and connect this with my account and start using it in trading one test stock according to the rules strategy.

Trading (live or paper) is done through Alerts which can be generated by your Strategy (or Strategy Monitor, but let's focus on the former for now). In terms of Wealth-Lab User Guide, this is covered in such chapters as Strategy Window > Strategy Window Views > Alerts View, and then Orders, Orders > Paper Trading etc.

QUOTE:
Is there a way to programmatically set up a rules based strategy and iterate through its variables to determine which setting obtains the best performance?

Optimizing rule-bases strategies is covered in the Wealth-Lab User Guide > Strategy Window > Strategy Builder > Parameter Sliders for the Strategy Builder.

Required reading to understand what Optimization is about: Strategy Window > Optimization > Full Optimization

QUOTE:
develop, for example, a 7th order polynomial curve fitting equation to model a stock, is there a way to enter such an equation in the editor?

No problem to code this in Wealth-Lab. C# is powerful language and polymomial curve fitting seems to have already been implemented in a 3rd party library that can be connected to Wealth-Lab and used in WealthScript code-based Strategy:

Use Math.NET's Fit.Polynomial method on functions of multiple parameters
Polynomial Fitting in C#
Curve Fitting: Linear Regression

I'm not the go to guy for this kind of math stuff but should you need advice on plugging in an external library like Math.Net just fire away e.g.

Using MathNet.Numerics


P.S. Please ask different questions in different threads, be they new or a closely matching existing one. From a forum management standpoint, packing unrelated questions into one topic like this is suboptimal for many reasons. Thank you.
profile picture

supermagnetman

#3
Eugene

Thanks so much - that gives me enough to fill up my spare time for the next couple of weeks:)
George
profile picture

superticker

#4
QUOTE:
a 7th order polynomial curve fitting equation to model a stock
Some numerical analysis comments:

1) For a 7th-order polynomial, you should be prepared to deal with complex conjugate roots. I think Math.Net's routines may let you restrict the fit to real roots, but I don't have any experience doing that.

2) Although we would prefer to forget (Ha, ha.), but we are fitting a fuzzy-system price model here. Having said that, trying to extract precision out of a fuzzy system (say with a 7th-degree fit) is going to be problematic. If all you want to do is fit the price behavior to a "streaming fit", you might consider a quadratic or cubic spline fit instead.

A spline is a running set of end-to-end equations. For example, Postscript fonts are defined by cubic splines. Basically, the fonts are defined as individual points in 2D-space that a connected together with cubic polynomials (splines) from end-to-end. Take a look a Math.Net's interpolation routines if you might be interested in quadratic or cubic spline fits. https://numerics.mathdotnet.com/api/MathNet.Numerics.Interpolation/index.htm

I don't think the spline fits will deliver fit statistics directly, but you can certainly subtract the spline fit from the raw price to get a residual DataSeries, then perform statistics on those residuals with the https://numerics.mathdotnet.com/api/MathNet.Numerics.Statistics/RunningStatistics.htm library.

If your goal is to incorporate a "predictive stochastic model" (Is it?), then you should look at Wealth-Lab's Kalman indicator. http://www2.wealth-lab.com/WL5Wiki/Kalman.ashx The generalize Kalman filter is designed to handle a system of predictive equations. Unfortunately, the financial sector is only using one predictive equation right now in their Kalman solution, which is the Taylor series of the stock price (price [0th-order], price velocity [1st-order], and price acceleration [2nd-order] terms). But one can always code more predictive equations. :-)
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).