[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] Optimizing


  • Date: Wed, 6 Jan 2010 11:10:30 -0500
  • From: Ted Byers <r.ted.byers@xxxxxxxxx>
  • Subject: Re: [amibroker] Optimizing

PureBytes Links

Trading Reference Links



Hi Howard, Markus,

Please pardon the intrusion, but both questions relate to my question.

It may be naive, but I would think that a trend following system would perform best when there is a reasonably strong trend, and that a mean reversion system would perform best when the trend is weak, if there is one at all.  So, then, suppose one has written a set of 8 functions that compute the buy, sell, short and cover signals: half for the trend following and half for the mean reversion parts of a composite system, and a 9th that uses a reasonably responsive indicator of trend strength to generate a boolean controlling whether or not one wants trend following or mean reversion at a given point in time for a given security (so if oil is showing a strong trend but telcos are relatively flat, one can use trend following in the one case and mean reversion in the other: if you don't like that pair, pick a pair that you'd expect to be uncorrelated and the point remains the same).  I may be a heretic, but I normally assume there are no invariants, whether through time or through space: in this case the space is defined by the universe of securities.

I can see it getting complicated as I would expect any open positions at those times when one switches between trend following and mean reversion would have to be assessed as to whether they ought to remain open (would it be most sensible to close them regardless or just leave them unless the signal from the current system is either buy or neutral).  Obviously, to be viable, one must take steps to prevent the trend following functions from becoming mean reversion functions.  In this case, and assuming the duration of a trend is typically shorter than the in sample period, one needs to be able to tell the optimization function/system that it is to be constrained so that a given relation must always exist between two or more of the parameters, and that there may be more than one such constraint.

I can see how I'd code this in C++ (that is almost trivial), but how would one code this in AFL?

Could one use something like the following and get the expected result:

MA1Length = Optimize("MA1Length",50,50,200,1);
MA2Length = Optimize("MA2Length",201,MA1Length,300,1);
MA3Length = Optimize("MA3Length",100,100,300,1);
MA4Length = Optimize("MA4Length",50,50,MA3Length,1);

Cheers

Ted

On Wed, Jan 6, 2010 at 8:19 AM, Howard B <howardbandy@xxxxxxxxx> wrote:
 

Hi Markus --

When the relationship between the two moving average lengths changes, the system changes from being a trend following system to being a mean reversion system.  It remains a "long" system when the signals generated are Buy = cross(MA1,MA2);  It becomes a "short" system when the signals generated are Short = cross(MA1,MA2);

Why exclude them?  You may very well find that the system works best as a mean reversion system.

But if you insist on limiting the variables, try this:

//////////////////////////////////

MA1Length = Optimize("MA1Length",50,50,200,1);
MA2Length = Optimize("MA2Length",100,100,300,1);

MA1 = MA(C,MA1Length);
MA2 = MA(C,MA2Length);

// Generate a Buy signal when MA1 crosses up through MA2,
// but only when the length of MA1 is less than the length of MA2
Buy = (MA1Length<MA2Length) AND Cross(MA1,MA2);
Sell = Cross(MA2,MA1);

///////////////////////////////////



Thanks,
Howard




On Wed, Jan 6, 2010 at 5:44 AM, Markus Witzler <funnybiz@xxxxxx> wrote:
 

Hello,
 
let´s say I intend to optimize a 2 MA crossover system with MA1 and MA2.
 
Possible range for MA1: 50-200
Possible range for MA2: 100-300
 
Now, there are some instances in which periodicity of MA1 is higher than the one of MA2, thereby creating a "short" system.
 
How does one exclude these "redundant" combinations from optimization?
 
Thanks
 
Markus




--
R.E.(Ted) Byers, Ph.D.,Ed.D.
TED@xxxxxxxxxxxxxxxxxxxxxxx
CTO
Merchant Services Corp.
350 Harry Walker Parkway North, Suite 8
Newmarket, Ontario
L3Y 8L3


__._,_.___


**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/





Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___