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

[EquisMetaStock Group] Re: Rules Management for Trading System



PureBytes Links

Trading Reference Links


Hi Eric,

We have a similar problem, if we rescale tomorrow, a new high may have
been reached and the whole series is rescaled.  We simply ignore this
as we are interested in when the series crossed zero and is it 'high'
or 'low'.  The rescaling change it slightly and we don't worry about
it that much.

In terms of the formulas you give - again, just off the cuff - I think
you need to take absolutes.

> > S:=Mov(C,3,S)-Mov(C,50,S); 
> > T:=S/HHV(S,periods); for scaling between -1 and 1

Note that S will sometimes be negative.  Say a series of S looks like

    -10 -8 -5 -3 -1 0 1 4 6 8

then the higest value will be 8, not 10 (which you want) and it will
not rescale to between -1 and +1.  So use something like

    Highest(Abs(S))

or

    Maximum(Abs(S))

which will return 10.

If you do not want the series to keep on adjusting as you rescale,
you have to FIX the scaling factor.  Say you have 10 years worth of
data.  Just visually inspect it and see where it is a maximum or
minimum.  Say it reached -7 in October 1987 and that is the biggest
value it ever attained.  Then FIX the scaling to something like 10,
thus

    T = S / 10

Now you have no guarantee, but there is a very very slim chance that

    Abs(S)

will exceed 10 in value and thus T will mostly be between -1 and +1.

There is a fantastic device called the Kalman filter that we often
use to combine stuff.  It really is a marvel from engineering and was
used to put guys on the moon - or so I've heard.  It is not trivial,
but not that difficult either.  How it works is as follows.  Say you
and I estimate how far the moon is from the earth.  You estimate it
at say 1,000km and I at 1,010km.  The Kalman filter is a way to
optimally combine these two into a single estimate, somewhere
inbetween, of say 1,002km.  Note in this example that the Kalman
filter think you are better at estimating the distance.

All you need to implement the Kalman filter is the standard error
of each indicator, but the problem is, standard error of what?  Things
get complex here, and I'm going to write a whole manual before I get
to the math, so let me stop.  If you are interested, let me know,
and I'll try to do it at a later stage......

Anyhow, here are a few suggestions.  Assign arbitrary weights, say
1/4, to each one.  If you trust one indicator quite a bit, give it
a higher weight, say 1/2, and the balance to the rest.  We often
employ this!  You can also scale them.  Start with an arbitrary, but
big value, such as 1000, that you assign to each.  Say you have your
four indicators, T1 .. T4.  Create four weights, say w1 .. w4

    w1 = 1000
    w2 = 1000
    w3 = 1000
    w4 = 1000

You can also change this.  If you like T3 a lot and just want to mix
in the rest, do something like

    w1 = 1000
    w2 = 1000
    w3 = 4000        ### Note this change
    w4 = 1000

Now, you have to device some way in which to change this weight
every day.  Say if T1 .. T4 is positive, it means the market is
bullish, so you expect it to rise.  Now, construct a penalty
function, something like

    dr = C - Ref(C,-1)                          daily return
    p1 = ( dr * T1 > 0 ) - ( dr * T1 < 0 )      penalty function
    p2 = ( dr * T2 > 0 ) - ( dr * T1 < 0 )
    ...

Note that p1 .. p2 will be either +1 if both dr and T1 point in
the same direction, or -1 if they are out of sync.  So if T1 is
positive and the market rises (daily return positive), p1 will be
+1, but -1 otherwise.  Now you need to adjust the weights using
this.  The problem is that, if you simply add or subtract, you
can potentially reduce the 1000 starting value to nothing.  So rather
adjust it using some percentage.  Say you want to add 1% to the
weight every time the indicator is correct, and subtract 1% when it
is not.  Do something like

   pc = 0.01              percentage to penalise with
   w1 = w1 * ( 1 + p1 * pc )
   w2 = w2 * ( 1 + p2 * pc )
   ...

So at the end of each round, you have adjusted the weights w1 .. w4
with pc percent.  Now, to apply them.  First you need the sum, so
somewhere calculate

    w = w1 + w2 + w3 + w4

and then, finally, combine the four indicators as follows:

    T = ( w1 * T1 + w2 * T2 + w3 * T3 + w4 * T4 ) / w / 4

I've added the / 4 bit, as T1 .. T4 is somewhere between -1 and +1,
so that T also will be between -1 and +1.

We use this often when we combine nets, so we have say four nets
and we combine them using the Kalman filter or something like this.

Again, I have not tested these, so use with care.  The important
thing is to grasp the idea, then you can play around with your own
ideas.  Here is another idea.  The example above will penalise with
+1 or -1 and only works on the sign of T1 .. T4.  It does not take
the magnitude of T1 .. T4 into account at all.  Say you want to
penalise based on the magnitude of T1 .. T4 and the direction the
market moved in.  Then change the penalty function to something like

    dr = C - Ref(C,-1)                       daily return
    p1 = abs( T1 ) * ( ( dr * T1 > 0 ) - ( dr * T1 < 0 ) )
                                             new penalty function
    ...

Here you penalise it more if T1 is high, but wrong.  Another one,
that we often use, is to penalise it by the market's return.  So if
T1 is positive, no matter how much, and the market falls a lot, we
want to penalise it more.  So do something like

    dr = C / Ref(C,-1) - 1                   daily return, now a %
    p1 = abs( C ) * ( ( dr * T1 > 0 ) - ( dr * T1 < 0 ) )
                                             new penalty function
    ...

Since the daily return is very small, typically a percent or less,
a day, increase pc quite a bit, say

    pc = 0.1

or even

    pc = 1

Anyhow, some ideas to toy around with.  The Kalman filter is very
similar, but optimal, and it's weights derive from the standard
error of each indicator.  It also adjusts after each round, but in
an optimal way, and is often used in variable parameter functions,
where the parameters vary as new information comes available.  But
the stuff I've given here should also work in practise provided you
have sufficient data to start up with.  So you need some 'time' for
the weights to settle down somewhere and it is interesting in itself
to plot those weights w1 .. w4 over time to see when functions worked
(the rising weights) and when not (the falling ones)....

Regards
MG Ferreira
TsaTsa EOD Programmer and trading model builder
http://www.ferra4models.com
http://fun.ferra4models.com






--- In equismetastock@xxxxxxxxxxxxxxx, pumrysh <no_reply@xxxx> wrote:
> 
> See if this will help
> http://trader.online.pl/MSZ/e-w-Normalizing_Indicators.html
> 
> Preston
> 
> 
> --- In equismetastock@xxxxxxxxxxxxxxx, chichungchoi <no_reply@xxxx> 
> wrote:
> > 
> > 
> > Hi MG Ferreira
> > 
> > Referring to last reply on message of 16628
> > 
> > S:=Mov(C,3,S)-Mov(C,50,S); 
> > T:=S/HHV(S,periods); for scaling between -1 and 1
> > Using the moving average for normalization, I can use the Highest
> (S) 
> > for scaling, however, when I use the function Highest(), then it 
> will 
> > pick the maximum value based on the available loaded data, which 
> > cause the problem on the value of T, since the maximum value keeps 
> > changing according to different length of loaded periods. Then 
> > I think of using a fixed length period to determine the Maximum 
> value 
> > of S for scaling.  At this point, I get no idea how to choose the 
> > period length, 
> > do you have any suggestion please?
> > 
> > 
> > On the other hand, in term of combining different indicators into 
> one,
> > do you have any suggestion on how to determine the weighting factor 
> > for each indicators?
> > I understand the net will do this job, but in my case, I need to 
> > combine indicators manually, such as 4 indicators together, do you 
> > have any suggestion please?
> > Thank you
> > Eric





------------------------ Yahoo! Groups Sponsor --------------------~--> 
What would our lives be like without music, dance, and theater?
Donate or volunteer in the arts today at Network for Good!
http://us.click.yahoo.com/Tcy2bD/SOnJAA/cosFAA/BefplB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/equismetastock/

<*> To unsubscribe from this group, send an email to:
    equismetastock-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/