EA Switcher - page 6

 

Trend detector

Facinating thread everyone. I'm sure someting like this has been on everyone's mind for a while. There have been a lot of great ideas raised here, so I would like to offer some thoughts of my own.

The first hurdle is detecting the market action (trending or ranging). There have been many indicators used that try to detect market action, and perhaps these will do ok. I've looked at slope indicators, with the help of Igorad, and you can get lost in timeframe issues (may be trending on 5m TF, but ranging on 1H, and trending again on the daily TF). Therefore, it might simplify things to focus on a single TF to start with, say the daily or 4H.

What I think would work best for detecting trends or ranging would be an indicator that utilized the correlation coefficient, or "r-value". If one tries to fit a line through a recent set of data, one will always be able to, and you could even calulate a slope factor. However, any trades based soley on this information would be misleading. The missing factor is the r-value of the equation describing the line. R-value's provide insight as to how tight the data points line up to the equated line. Therefore, if we had an indicator that calculated:

1. Slope of the best fit line through the recent data (i.e. 100 data points)

2. The p-value, to determine if the slope was statistically significant, and

2. The r-value, or even r-squared value indicating how well the data conforms to the line.

If the market is trending, you will obviously expect a trend with a slope (greater than some pre-determined value, positive or negative) that is both statistically significant (p-value less than 0.05), AND a relatively high (or low) r-value.

A ranging market would have a statistically insignificant trendline, and the r-value would be close to zero.

Is coding for something like this possible? I would imagine there would have to be a fairly large dll to handle the statistical elements.

One last thought that will have to be considered on ANY market condition indicator is how long the various "phases" run for, and how soon into any phase can an indication be made....

Just my $0.02 worth.

Doug

If there ithe r-value is close to zero (either negative or positive), then the data doesn't fit the line well,

 

IMO a trend is too subjective to automate. First of all, can anybody actually define what a trend is?

Then on which timeframe etc. and most indicators will announce the trend when it's too late or when it's about to reverse - today's market being a good example.

I would suggest an alternative strategy. Monitor the results of the EAs within the portfolio on a daily or weekly basis and adapt position size, % of capital or even adjust stops and targets depending on performance.

We've all seen systems that work in trending markets do badly in sideways periods, and ranging systems fail in trending markets etc. so why not use this fact to our advantage when we have a portfolio containing EAs for all market conditions?

 
rolange:
IMO a trend is too subjective to automate. First of all, can anybody actually define what a trend is?

Then on which timeframe etc. and most indicators will announce the trend when it's too late or when it's about to reverse - today's market being a good example.

I would suggest an alternative strategy. Monitor the results of the EAs within the portfolio on a daily or weekly basis and adapt position size, % of capital or even adjust stops and targets depending on performance.

We've all seen systems that work in trending markets do badly in sideways periods, and ranging systems fail in trending markets etc. so why not use this fact to our advantage when we have a portfolio containing EAs for all market conditions?

Rolange,

I understand what you're getting at, however it's basically the same thing as trying to predict trending vs. ranging. If you have one EA that has done particularly well during the past "X" time period, what makes you think it will do better in "X+1" time periods? I guess the bottom line for both our trains of thought is to try and determine some kind of "cycle time", such that once you can identify a period where the market is acting a certain way, how much longer can it be expected to act that way ... I get the feeling this is key.

One thing we totally agree on, and could use some feedback from other members about, is to try and define exactly what defines a trending market.

Doug

 

Sorry I have to disagree. Money management is quite different from market dynamics.

I was thinking of something along these lines....

Variable Fractional Percent (VFP) money management.

Firstly calculate daily Net Asset Value (NAV) gain or loss in percent.

Start trading at a conservative 5% FFP (or whatever suits). But instead of using a Fixed Fractional percent, use a range say 2%-25%. Move up and down the scale by adding or subtracting half of the last daily NAV percentage.

For example start at 5% FFP

Next day profit on trades = 1.5%

Therefore next FFP = 5 + (1.5 * 0.5 ) = 5.75%

Say then there is a loss of 3%

Next FFP = 5.75 + (-3 * 0.5) = 4.25%

Obviously use ranges and a daily factor (here 50%) that suits, this method rewards good methods, and lightens up very quickly on bad.

 
rolange:
Sorry I have to disagree. Money management is quite different from market dynamics.

I was thinking of something along these lines....

Variable Fractional Percent (VFP) money management.

Firstly calculate daily Net Asset Value (NAV) gain or loss in percent.

Start trading at a conservative 5% FFP (or whatever suits). But instead of using a Fixed Fractional percent, use a range say 2%-25%. Move up and down the scale by adding or subtracting half of the last daily NAV percentage.

For example start at 5% FFP

Next day profit on trades = 1.5%

Therefore next FFP = 5 + (1.5 * 0.5 ) = 5.75%

Say then there is a loss of 3%

Next FFP = 5.75 + (-3 * 0.5) = 4.25%

Obviously use ranges and a daily factor (here 50%) that suits, this method rewards good methods, and lightens up very quickly on bad.

That's a very interesting technique for money management, and I think it has a lot of merit Are there any EA's that use this technique that you're aware of?

Using this method of managing the EA's in the "portfolio", we could avoid the philosophical debates about the definition of a trend, and how to determine when one has started/ended.

I understand what you were referring to now.

Thanks.

Doug

 

Trend indicator

Hello.

Concerning a Trending Market....

Have you see this indictator ? : https://www.mql5.com/en/forum

Thanks for feedback.

 

btw thanks for all people who are interesting about this kind of EA idea... We will build it ;-)

 
dswk:
Hi forex-tsd community.

First of all sorry for my bad english, it's not my mother tongue.

I've one idea :

Can we create 1 EA who are able to "switch" between 1, 2 or more others EA.

The switch calculation would be based on the market attitude. means : use XXX ea if the market is Trend or use YYY ea if the market is "Flat" and "side"...

Any opinions or code ?

Thanks.

It's much more convenient for me to code everything in one EA and have multiple modes. It can shift from one of three or more modes (as you said based on trend, flat, side, etc.) This will be more efficient and effective because it will save processing time, limit possible bugs, and most important of all become easily portable and exchangeable.

The secret is not in switching, the challenge is in knowing what market conditions are you in!

 
investor_me:
The secret is not in switching, the challenge is in knowing what market conditions are you in!

i agree on this sentence.

But one of the quality of the "switcher" is to not be limited to 1,2 or 3 strategies implemented in the code.

We need to be able to "plug" an EA (whatever what EA is) to the market decision component.

Please see post : https://www.mql5.com/en/forum/175657/page3

(I don't know if it's technicaly feasible in MQL4 but normally...... )

Regards.

 

Igorad sent PM to me that he likes our idea about EA Switcher and especially about this post made by dswk.

And just to re-mind to myself about some market analysis which I did one year ago using digital filters indicators somewhere here.

Reason: