PureBytes Links
Trading Reference Links
|
ChiChungChoi, simultaneous entry/exits can be manipulated in two
simple ways:
#1 Ignore:
entry/exit signals cancel each other.
#2 Preference given to:
new entry if currently Short,
new exit if currently Long.
Take a look at the MS code here:
http://www.metastocktools.com/#metastock
"System/signal indicators" section, "Trade signals" link.
> MSFL does not allow a time series as a parameter in the 'Power'
> function. So we have to use exps and lns.
MG, if you're not too busy modeling the World's economy, do you know
of a simple way to use the Log() (natural Logarithm) and Exp()
functions to calculate Power(DataArray,VariablePower)?
Example:
DataArray:=C;
VarPower:=Mov(C,21,E)/C;
Pwr(DataArray,VarPower) <-- only constant data allowed.
jose '-)
http://www.metastocktools.com
--- In equismetastock@xxxxxxxxxxxxxxx, "MG Ferreira" <quant@xxxx>
wrote:
>
> Hi Eric,
>
> I am not at the office at the moment, and all of these are just off
> the cuff. I suggest you pick one of the following ideas:
> 1. combine it into a single signal
> 2. react to the most recent signal
> 3. weigh the signals
>
> We mostly use 1 and often 3. Using 3 is very similar to using 2,
> and sort of a way to combine 1 and 2 into one - hope you are less
> confused than I am at the moment....
>
> Anyhow, here are some suggestions. Using 1, you could combine it
> into single signal by e.g. netting the two singals, so that the
> stronger one will determine the position. The problem is that the
> faster RSI will normally dominate, but in the example they are close
> enough to try. So, from
>
> > Vs = RSI(9) - 70
> > Vl = RSI(14) - 30
> >
> > Ts = min(0,Vs)*(Ss<0);
> > Tl = max(0,Vl)*(Sl>0);
>
> calculate a single signal as something like
>
> Tls = Tl + Ts;
>
> The second suggestion, reacting to the most recent signal, entails
> monitoring when each one fired, using something like
>
> Bl := BarsSince(Sl=0);
> Bs := BarsSince(Ss=0);
>
> which gives the bars since each signal fired. Now, use the most
> recent one, so
>
> Tls := ( Bl < Bs ) - ( Bs < Bl );
>
> I haven't tested this, but I hope that it will be zero if both Bl
> and Bs are zero, +1 if Bl fired more recently than Bs and -1 if Bs
> was the most recent one that fired.
>
> Finally, the third suggestion. This is sort of an advanced way to
> combine the two into a single indicator but also taking into account
> the number of bars since it last fired. You can optimise it or
> apply something like the Kalman filter, but I suggest you just play
> around a bit with it and see if it works or not. We will basically
> add an exponential decay to each signal. So as soon as a signal
> 'fires' we start to diminish its strength exponentially so that, if
> the other one fires, it will be strong. To illustrate, say we
> diminish the strength by 10% each bar, then, suppose the signal
> strength is 100 for the next ten bars, we will adjust this to
> something like
>
> 100, 90, 81, 72.9, 65.6, 59.0, 53.1, 47.8, 43.0, 38.7
>
> Note that, by the tenth bar, we are using 0.387 of the original
> signal. The 'idea' behind this is that, when a signal changes, it
> has maximum impact but this impact dies out over time. If you just
> went long based on a model, we suppose it to be a good signal but if
> the model still is long ten say weeks from now we treat it with much
> more caution. To do this, we still use the BarsSince function,
> something like
>
> Vs = RSI(9) - 70
> Vl = RSI(14) - 30
>
> Ts = min(0,Vs)*(Ss<0);
> Tl = max(0,Vl)*(Sl>0);
>
> Bl := BarsSince(Sl=0);
> Bs := BarsSince(Ss=0);
>
> Fl := Exp( Bl * Ln( 0.9 ) );
> Fs := Exp( Bs * Ln( 0.9 ) );
>
> Tls = Tl * Fl + Ts * Fs;
>
> What we want to do is something like dampening factor raised to the
> power of the number of bars since the signal fired, but MSFL does
not
> allow a time series as a parameter in the 'Power' function. So we
> have to use exps and lns. Note, it may be Log in stead of Ln in the
> above, I am not sure exactly which one MSFL uses. In the end, we
> calculate a factor Fl and Fs with which we adjust the long and short
> signal and then we use this to combine them. To have the signal
> strength fall by 10% in each bar, use 0.9 as above. To make it fall
> by 1%, use 0.99 and so on. These are the type of values you should
> play with. If you use something big like 20 or 50%, it will fall
> too quick.
>
> You can also consider using different factors since the signals use
> different time periods. Since the short one in your example is
> quicker, we dampen it more, say something like
>
> Fl := Exp( Bl * Ln( 0.95 ) );
> Fs := Exp( Bs * Ln( 0.90 ) );
>
> so that the short signal falls by 10% and the long by 5%. In
> practise, unless the signals fire fairly close to one another, this
> will not produce results substantially different to the one where
> you use just the most recent signal. You can also use a linear
> dampening or very small factors (something like Ln( 0.99 ) or
> Ln( 0.999 ) in the above) to get signals that are not totally
> dominated by this dampening.
>
> To use a linear factor, do something like
>
> Fl := 1 - Bl / 100;
> Fs := 1 - Bs / 100;
>
> This has some additional problems, as it will reverse after 100 bars
> and is a bit slow, but at least something else to experiment with.
>
> Regards
> MG Ferreira
> TsaTsa EOD Programmer and trading model builder
> http://www.ferra4models.com
> http://fun.ferra4models.com
>
>
> --- In equismetastock@xxxxxxxxxxxxxxx, chichungchoi <no_reply@xxxx>
wrote:
>
> Hi MG Ferreira:
>
> How about to define LONG AND SHORT signals separately? such as
> LONG: RSI(14)>30;
> SHORT: RSI(9)<70;
>
> Ss =-(RSI(9)<70)*(Ref(RSI(9),-1)>=70);
> we get a -1 value every time we have to short.
> Sl =+(RSI(14)>30)*(Ref(RSI(14),-1)<=30);
> and we get a +1 every time we have to go long.
>
> At this moment, I cannot combine all of this into a single
> indicator, because I want to apply penalty function for LONG and
> SHORT signals separately.
> Do you have any suggestion on how to approach Kalman filter in this
> case?
>
> Indicating the strength for each sigals, then
> we add the following:
>
> Vs = RSI(9) - 70
> Vl = RSI(14) - 30
>
> Ts = min(0,Vs)*(Ss<0);
> Tl = max(0,Vl)*(Sl>0);
>
> Normalization between -1 and +1
> Ts_Norm = Ts/ABS(min(Ts));
> Tl_Norm = Tl/max(Tl);
>
> At this moment, LONG AND SHORT signals could occur at the same time.
> Do you have any idea how to handle the signals in this case?
> Under different kinds of situation, LONG signal will be triggered.
> For example, Tl_Norm > 30% or Ts_Norm>Ref(Ts_Norm,-1)
> Do you have any more suggestion on how to trigger the LONG signal in
> another way?
>
> 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/
|