Glitch8
 ( 12.33% )
- ago
So, I'm very deep into working on the Chart Patterns Extension, and about to start a Genetic Evolver that will evolve profitable 2D PriceGrid patterns. This will be the second Genetic Evolver I create after the CandleStick one. So, it dawned on me: what if we had a Strategy Genetic Evolver? You would select your data, and an in-sample/out-of-sample range, and click Start. The Evolver would randomly generate and evolve Strategies generation after generation, until you are left with the best evolved Strategies.

Internally, the evolved Strategies would be Building Block based. The Evolver would use genes that leverage the Building Blocks. Genes like **Oscillator Oversold**, **MA Relationship**, **Crossovers**, and **Extreme Moves**. The genes would be discoverable so they could be expanded even in Extensions, so we could get **Candlestick Pattern** genes or **Chart Pattern** genes, or **Neural Network** genes, for the corresponding Extensions.

I think the ability to "evolve" a profitable Strategy in just a few clicks would be appealing, and could push WL7 into more of the mainstream than is now possible!
11
2,294
63 Replies

Reply

Bookmark

Sort
- ago
#1
- I do like making stuff like that too).

- I can't vote for this with my both hands as I think there are still many things to be improved in existing functionality. But my one-hand-vote is here).

- I'm sure one-click-anything can not be very profitable in trading, but I guess you are right in thinking it's a good stuff for mainstream easy to use trading.

- I would like to have something (this extension) that will be curve-fitting proof, that will be slow (but powerful) will be running all the time and creating something that really could be traded (but nothing like Grail) from time to time.
0
mjj38
- ago
#2
May I suggest that we make this thread a brain storming session on this subject?
0
Glitch8
 ( 12.33% )
- ago
#3
Of course, what are your ideas?
0
- ago
#4
Dion,

I must warn you that you are about to walk into a minefield! 😉 What you are suggesting is available in a few professional strategy development systems. I had an opportunity to test one of these packages a few years ago. Their selling point was that the user did not need to do anything - let the computer do the work! 😊

Basically, you are envisioning an ML approach to system development. With that approach comes a HOST of very significant issues that you will need to address. These include items such as statistical validity of the objective function calculated, predictive rather descriptive metrics for the objective function, statistical approaches to data selection and model validation (e.g. bagging), processes that reduce co-linear inputs, etc. And I have just scratched the surface. Furthermore, model development (ML or otherwise) using noisy stochastic datasets requires an extra level of care. This is one reason why so many trading systems "stop working" IMHO.

This is not an attempt to dissuade you from the effort, but rather a suggestion that a system like this needs to be well thought through to include all the relevant "pieces and parts" in the initial design before proceeding.

Oh, by the way, that development system that I mentioned that I evaluated a few years ago did wonderfully in-sample, but poorly out-of-sample on practically every model that it developed. Four weeks of extensive evaluation on my part led me to return it.

Vince
1
- ago
#5
I believe Dion can make it work without all that Carova's sky high IQ mumbo jumbo! 😂
0
- ago
#6
Eugene,

You are obviously a man of faith! 😁

Vince
0
Cone8
 ( 27.64% )
- ago
#7
Eugene has seen "the light" (and the work in progress). ;)
2
da420078
 ( 91.81% )
- ago
#8
Amazing!
In the spirit of brainstorming, as mjj3 suggested ...
Who is your target market?
Is it the institutional-level developer?
Is it the retail daytrader who's looking for the latest and greatest functionality?
Is it the average investor looking to beat the market in her retirement accounts?
Where should the main focus be?

What do "mainstream users" want, anyway? What does your research tell you?
Do they want something interactive and easy to use to experiment with?
Or do they not care what's going on behind the scenes and just want something that'll do all the work and give them an idea with minimal effort or understanding?
Speaking for myself, I favor an intuitive easy-to-use interface that lets me develop ideas in a visual way. I need to understand what forms the basis of a strategy and it's easier for me to see that visually.
0
- ago
#9
Knowing WL team, it will be easily adaptable for "all of the above" like the iPhone was for your grandma to figure out.
0
da420078
 ( 91.81% )
- ago
#10
There are, of course, finite resources.
So do you invest more resource making the system more approachable for the mainstream self-directed investor?
Or do you go deeper in complexity to appeal to a smaller market of very sophisticated users?
It's hard to do both well? Unless you happen to be Apple Inc.
0
- ago
#11
QUOTE:
... that development system ... I [Carova, Reply# 4] mentioned ... did wonderfully in-sample, but poorly out-of-sample on practically every model .... Four weeks of extensive evaluation ... led me to return it.

So any statistical, empirical model must strive for "par" when it comes to the number of degrees of freedom (model DF) to include in the model. You can overfit any model by loading up the model DFs. But you won't have good "par" and R-squared fit.

The challenge is coming up with a general solution that minimizes the number of empirical terms in the model while maximizing the R-squared fit. And that requires evaluating the Ps (probability of significance) of each individual prospective term. And after the stat package gives you that printout, you may decide to drop many insignificant terms and create new ones you haven't tried before.

My point is that finding the "ideal" general solution with "perfect par" is a touch-and-go operation by the researcher. The researcher has to use his wit to work through the statistical printouts to reach that ideal par (minimized model DFs and maximized R-squared). An undirected ML solution will always overfit your system as the above quote points out.
0
mjj38
- ago
#12
My two cents ...

How I've used this type of technology with good results.
a) Guided Approach - Most strategy types have a general structure. Optimize the strategy set within that general structure.

b) Enhance Existing Viable Strategy - Examine optional conditions to improve existing strategy, Improve efficiency for either the entry or exit conditions, try to incorporate ensemble conditions.

c) Data-mining - Most software out there in this space tries to create strategies from scratch using a huge search set and far too many conditions (curve fit). I like to search for 2 maybe 3 condition sets that show some type of edge. I then take that edge and try to build a strategy around that (9 out of 10 amount to nothing).

d) You need to focus on a number of techniques that ensure you are not just curve fitting (whole separate discussion, but I believe WL has some work to do here).

e) Optimize a portfolio of viable strategies to find out the best combination based on a given fitness function (or group of them).

f) Fitness Function Performance - Say you have 100 strategies across many markets. Walk-forward that entire portfolio to see which fitness functions actually have the best forward performance. (You might be surprised by the answer!)

2
- ago
#13
QUOTE:
Most software out there in this space tries to create strategies ... [with] far too many conditions (curve fit). I like to search for 2 maybe 3 condition sets that show some type of edge.

Exactly. And that's why the stat packages create long printouts evaluating the Ps of each condition (or term). It's a touch-and-go operation by the researcher to take these printouts and figure out which conditions (or terms) are most significant.

And correlation does not imply causation. I'm sure your stat professor taught you that. So the researcher needs to evaluate each condition (or term) from a relevance prospective as well. This isn't something you can do by machine. It requires a human mind and an understanding of the underlying process behind the model.

One can now ask, "How can WL help?" Probably the best way is to interface it to a stat package. R.NET has really already done that by interfacing any .NET software (including WL) to the R stat program. So you can sample WL simulations and produce a dataset to analyze in R. This is the most rational approach for addressing this statistical problem.
1
Glitch8
 ( 12.33% )
- ago
#14
Wow, would love to learn more about that, inlcuding any screen shots you might have. I always wanted to integrate more robust statistical analysis into WL's reporting to get a feel for how statistically significant backtest results are.
1
- ago
#15
QUOTE:
to learn more about that [using R with WL], including any screenshots you might have.
Well I haven't tried this yet, but it's on my list of things to do.

Using R with WL is such a new issue that I started a new topic. Please follow https://www.wealth-lab.com/Discussion/Using-the-R-statistics-program-with-WL-7247
2
- ago
#16
I like it!

Cool feature. I guess I've already created a new strategy with it's help)).

I'll post some improvements offers and a very small bug report a bit later.

What I like the most is the viriability of strtategies, looks like it's very large.
I also like that this extension is user friendly.

I'll leave it live it's own life for a night).
0
Glitch8
 ( 12.33% )
- ago
#17
Certain combinations can cause it to throw an error and stop evolving. I may have caught this, but not sure, so if you see the evolution stopped that's why. You can resume after this. If this happens let me know because I'll need to delve further.
0
- ago
#18
My small bug was about dragging and dropping metrics in Preferences. It works weird - it drops the metrics sometimes without unpressing a button and takes an another metrics you do not expect.

Another "issue" it looks like some combinations can make a backtest very slow for a certain strategy. Here is an example of such strategy. An average generation took 2-3 minutes, but this strategy have been backtesting for half an hour or an hour already. And this stops the whole process, maybe you could hardstop such strategies or let other strategies evolve independently or something.



I got an exception about a strategy that is not good in log, so I guess it's cought successfuly).

Generation 1: 1,86min
Generation 1: 2,12min
Generation 2: 2,73min
Strategy 43 (SSmSL-CmN-Cs) Exception: Strategy Compile failed. Отсутствует аргумент, соответствующий требуемому формальному параметру "period" из "BullPowerVG.BullPowerVG(BarHistory, int)"..Поле "MyStrategy.stops" никогда не используется..Полю "MyStrategy.trailing" присвоено значение, но оно ни разу не использовано..
Generation 3: 1,78min
Generation 4: 1,67min


in English something like: "Exception: Strategy Compile failed. there is not argument matching a formal parameter "period" in "BullPowerVG.BullPowerVG(BarHistory, int)"... "MyStrategy.stops" field is never used... "MyStrategy.trailing" field is initialized but it's never used"


And: I'm not sure, I haven't even watched the video yet)), maybe it's explpained there (or maybe I do not get the whole idea), but maybe we could outfilter some strategies (like strategies with positionsCount less then N), or is this the idea of Use Filter Set?))
0
- ago
#19
upd.: drag and drop issue is reproduced only when using Windows RDP connection.
0
Glitch8
 ( 12.33% )
- ago
#20
Yes, we log these Strategy errors, but they will just cause that Strategy to not proceed to the next generation. If you notice any very slow ones you can right click and remove them manually too.

And yeah, use Filter Sets to establish your own filtering.
0
Cone8
 ( 27.64% )
- ago
#21
Chart Pattern conditions will definitely add more time to backtests. You can deselect those from the Evolver Preferences, or, reduce the number of passes in the Chart Patterns Preferences.
0
- ago
#22
I guess deleting a strategy that is still backtesting does not solve the problem - I still can't push stop button after deleting.

And I hope I'll find the place where I can create filter sets after I watch the video)).
0
- ago
#23
Sorry for giving a feedback before watching a video)).

The evolver looks even cooler after watching a video, good job!
1
Glitch8
 ( 12.33% )
- ago
#24
Stop does not immediately stop everything, it allows the current generation to complete gracefully.
1
- ago
#25
A terrific addition to the WL7 toolset!
1
mjj38
- ago
#26
Looks great. A few questions:

a. Can you explain the roll of the "Building Block Template Strategies" in more detail?
b. Can you add the option of saving/loading Search Settings?
c. Consider separating Entry and Exit Genetic Searches. (potentially reduces the search set as well) It would be interesting to be able to take an existing strategy with good entry metrics (Efficiency, Eratio, etc) and search for better exit conditions.
d. Have standard exit approaches that can be applied. I can optimize for an max 5 day eratio with a standard exit of 5 days.
1
Glitch8
 ( 12.33% )
- ago
#27
You can accomplish alot of this by building your own genes. Yes, it's possible, they are extendible. But we need to document that in the extension API :)
2
Glitch8
 ( 12.33% )
- ago
#28
Template Strategies are the 5 slots that come pre-loaded with a simple archetypical Strategy.

They are:

1. RSI overbought/oversold
2. 3x2 consecutive down/up days
3. SMA 50/200 crossover
4. MACD signal line
5. Simple dipbuyer
1
mjj38
- ago
#29
For the template strategies, the solver substitutes different indicators for the ones used in the template strategy and varies the parameters of those strategies? Does it limit the substitutions by type of indicator? or parameters by used by any method?
1
- ago
#30
Just updated to the latest version and started working with this feature, really fascinating stuff. It already seems clear to me that this is going to be the future. It's really good.

I am running into the mentioned issue with getting hung/stuck on occasional generations. I've tried to right-click and remove the associated strategy, but it seems there's not much that can be done other than wait and hope it eventually resolves. I have stuff like this in my log:

QUOTE:
Generation 4: 1.63min
Generation 5: 17.41sec
Generation 6: 2 hrs, 9 mins
Generation 7: 17.83sec
Generation 8: 18.42sec


QUOTE:
Generation 14: 31.52sec
Generation 15: 22.58sec
Generation 16: 2 hrs, 5 mins
Generation 17: 22.36sec
Generation 18: 27.33sec
Generation 19: 23.19sec


Hopefully it will eventually be possible to auto-kill these long-running generations.
0
Glitch8
 ( 12.33% )
- ago
#31
Hmm, yes we need to do something about this. already getting some ideas. any update on your cancel pending issue? is it solved in b44?
1
- ago
#32
QUOTE:
any update on your cancel pending issue? is it solved in b44?

I haven't tested my live strategy enough with B44 yet to say for certain, I will report back once I have a better idea. Thanks for the fix.
0
- ago
#33
After a night of evoling WL7 starts using the whole (32 Gb in this case) abount of RAM. I can't see HDD/SSD usage on my dedicated server, but the speed of WL7 in the morning says it uses swap.
0
- ago
#34
We were evolving on 10 years of S&P500 on Daily.
0
- ago
#35
I have a question, what does this mean? - When the process is at 100-th generation, but the largest generation number of a strategy let's say 5. Does this mean something like: somewhere like at 2-nd generation the was a good strategy an it evolved for like 3 generations and became even better and no children and no random strategies of all next 95 generations were not better then theese children. Like this?

Does the process looks like: when the next generation starts you take take TOP best from previous generation with no changes, than children from those strategies and some fully ranfom new strategies?
0
Glitch8
 ( 12.33% )
- ago
#36
No, if you’re on Gen 100 and a Strategy has been around for 5 Generations, then it appeared on Gen 95.
0
- ago
#37
QUOTE:
No, if you’re on Gen 100 and a Strategy has been around for 5 Generations, then it appeared on Gen 95.


Oh, so strategy generation is a generation from the oldest strategy's ancestor, I see. So every strategy evolves all the time, no strategy goes to the next iteration as it is with no changes, right?
0
Glitch8
 ( 12.33% )
- ago
#38
The top 5 performers do go onto the next generation unchanged, and they also introduce a mutated variant.
0
- ago
#39
I see, thanks.
0
- ago
#40
Evolver began to stop ater a couple of generations. Like "Evolver stopped at generation 4".

In log:
CODE:
Generation 1: 2,01min Generation 2: 2,40min Generation 3: 2,28min Strategy 68 (BmSL-SmO-Bls-Sp-Sls) Exception: Collection was modified; enumeration operation may not execute. Strategy 66 (BmSL-Sls-SSlSX-CmSL-Cp) Exception: Object reference not set to an instance of an object. Strategy 72 (BlN-SlsSL) Exception: Object reference not set to an instance of an object. Strategy 71 (Bls-SlsO-SSlSX-Cls-CmSX-ClsSX-Cls) Exception: Object reference not set to an instance of an object.


Reopening an evolver window doesn't solve the problem.

What I did:

I ran evolving), many runs were successful, but after a certain moment all are not. What was the difference - I guess this time I pushed Start after stoping, but previous time I closed the window maybe, not sure actually, as always it looks like I didn't do anything special that could cause this)), no special ideas to reproduce also.

Restarting WL7 fixes this.
0
Glitch8
 ( 12.33% )
- ago
#41
This is normal, there will be Strategies that produce these kinds of errors because certain indicators and parameter combinations just don't work. There are too many combinations to proactively prevent them all, so we just log the error and don't allow the Strategy to proceed further.
0
- ago
#42
I'm not sure you got me right)

The case you are talking about is quite common in log, it does not cause evolver stopping or unabling to start it after it stops. But in the case described the evolving stops by itself and arter starting it again it runs only for a couple of generations and stops again. Only WL7 restarting helps.
0
Glitch8
 ( 12.33% )
- ago
#43
OK thanks, I will investigate!
0
- ago
#44
This tool is amazing!

I was a bit unsure what to expect, because I was afraid that whatever good strategy would come out of this process, it could be excessively “curve-fitted”. However, despite some obvious fitting effect, I found very good ideas out of this that can then be made more robust; ideas that went in directions that I would have never tried myself.

I especially like the fact that the resulting systems are not black boxes; but a clear set of building blocks (my best systems so far even only have a couple of conditions), which can then be easily converted to code.

This added a tremendous value to the WL suite.

Very well done!
2
Glitch8
 ( 12.33% )
- ago
#45
Yes, that's the idea! The tool is intended to "open your mind" to new possibilities for exploration, not necesarily to generate the Holy Grail in and of itself :)
1
- ago
#46
Indeed. One of the things that I missed from WL6 was the library of pre-existing strategies to get some ideas from. This tool more than compensates for it: I leave the PC crunching during the night; and then check in the morning what exciting combinations were found. This really helps to beat the "writer's block" in strategy design. Been using it since a couple of days and I can definitely say it increased my motivation for this business.

This feature should be more predominant in WL's site. There are dedicated software out there that does the same almost exclusively, with far less good results. One of them even costs 60K!
3
- ago
#47
Intersting observation: I made like 10-20 evolver runs. I took best strategies out of these runs, then I sifted ones with acceptable OOS results - like 2/3-1/2 of them. 8 strategies in total. Then I made a metastrategy out of these strategies. So the interesting observation is that 7/8 strategies have 0.9-0.95 correlation with each other, and there is only one (actually it's the only one short strategy) that has 0.5 correlation.

You may know that you don't get much benefit when using many correlated strategies. The metrics of the portfolio will not be better then the metrics of the single strategie, like max drawdown etc.

I tried to use different metrics to be maximized while learning, only the filter preset was the sam, but there were nothing special there, like 500+ trades, PF 1+, barhHold [5;125].

I'll keep on using this tool for more insights. I'll try to play more with filters, maybe that's the key.

And some ideas that are not feature requests but something to think about maybe:

1. There is no much benefit of holding the process running for a long time, because... some strategies which means there genes become dominant very fast. Like you maximize PF, there will be a group of strategies with similar genes (a family), they become dominant, they will have good metrics and there children will, no randomized new strategies will have no much chances to compete with them, so they'll have very small chances to have children and the further the process goes, the more this stratification of society is.

2. Maybe the evolver could have a trigger/triggers to stop or rerun the evolver like gene stability measure, if the evolver sees that the gene stagility within 20 iterations top winners is very high, maybe it's time to rerun the whole process.

3. Maybe the evolver should have some kind of list of filter presets to get strategies out of this process to store them. Like the evolver sees that a certain strategy is good enough (matches on of the "this one is good" filter presets) and collects this strategy in a list so that a user could look at it closer. And if the evolver has triggers to rerun, like I said in (2), it could be a mechanism to store good strategies of the run (if the evolution leaded it to good strategies).

4. Or... maybe there could be more then one sandboxes, like 3-5, with there own enclosed evolution, and from time to time top winners out of these sndboxes become gene sources for the main sandbox where different families'genes soup is cooking or differen families' instances compete and evolve.
2
- ago
#48
I really like this strategy evolver. One addition I'd like to see is the same position sizing options as we have when we start our own building block strategy (shown below), is that possible?

1
Glitch8
 ( 12.33% )
- ago
#49
The Evolver already considers position sizing as one of its mutatable parameters.
0
- ago
#50
I understand this is already optimized, just asking if we can request this added user customization to match users normal trading patterns just like how we develop our own strategies and match our trading accounts margin.
0
Glitch8
 ( 12.33% )
- ago
#51
Sure, everything is on the table!
0
- ago
#52
A few general questions:

1) Does the "Filter Set" affect the evolution of the strategy in any way, or simply hide certain rows from being displayed to the user?

2) When I try to "Evolve for" a metric that was created with the "Formula ScoreCard" extension, it shows up as a blank column in the Evolver window results. Is it still working? The same metric shows up correctly in Optimization window results.

3) Often I will let the Strategy Evolver run for around 24 hours, and it will seem to converge to a single structure that is used in all strategies in the Evolver results. If I were to leave all the settings unchanged, but start the process over again, is the intended result that I would converge to that same "optimal" strategy? Or is there an intentional random aspect, and I might end up converging on some completely different strategy structure on a subsequent run?
0
Glitch8
 ( 12.33% )
- ago
#53
1) It does not affect the evolution.

2) Hmmm I will ask DrKoch about that.

3) If one of the "template" strategies in slots 1-5 (or 6-10 if assigned) were markedly better on the historical data than the others, then it's possible that it would converge to the same kind of strategy.
1
- ago
#54
Are the "Evolver Preferences" working as expected? I wanted to try evolving a strategy for Short positions, so I unchecked all of the "Buy" and "Sell" Strategy Genes. However, after 100 completed generations, I'm only seeing strategies in the Evolver results that use "Buy at Market" and "Sell at Market" design blocks.
0
Cone8
 ( 27.64% )
- ago
#55
What DataSet and range are you evolving on? It's likely that one or more of preconfigured Strategies in slots 1 to 5 perform much better than a short strategy on that data.
1
Glitch8
 ( 12.33% )
- ago
#56
The evolver will still use the 5 “starter” strategies. The check boxes only control which genes are selected for randomized strategies, so it’s working as expected.
1
- ago
#57
Thanks for the clarification, guys. I still love this tool and I'm using it daily, but also still struggling with it sporadically getting stuck on evolving a generation at random times for unknown reasons. Unfortunately, it seems like the only way forward is to force-kill WL7 and start evolving from the beginning. Really looking forward to eventually running it for 24+ hours and seeing what it comes up with!
0
- ago
#58
I really love it too, constantly running it on my 2nd PC and saving top results for all different datasets, it's great!
2
Glitch8
 ( 12.33% )
- ago
#59
We are working on a timeout mechanism to automatically kill problematic strategies that get stuck.
2
- ago
#60
Top winners of different Evolver runs correlate a lot. I mean between runs. Did anyone notice that? Maybe it's run settings, that couse this, maybe it's the whole idea of the Evolver in its current state like there is no much variaty in the current algorithm that causes this convergence. I don't mean variety of genes or something.

Maybe it's the same pattern every time that become dominant with no chances for strategies of diferent kinds evolve or something.

I didn't look closer, just trying to think about, the only point I can see is that the result strategies of different runs correlate a lot.
1
- ago
#61
Early instantiations of evolutionary optimizers suffered from this limitation (similar to the Einstellung effect in humans) and have been addressed in many ways.

The underlying issue is that early "high performance" strategies effectively prevent "even better" strategies from ever being explored by "crowding out" the genes that might give rise to them.

Vince
2
- ago
#62
QUOTE:
and have been addressed in many ways


So.... what are these solutions?
1
- ago
#63
Hi DrKoch!

There are so many approaches that I will not re-list them here, but rather suggest that you look at some of the articles in this link to help identify the ones that might be most suitable for the particular optimizer design you are using:

https://www.google.com/search?q=prevent+premature+convergence+in+evolutionary+algorithms&source=hp

Vince

0

Reply

Bookmark

Sort