PureBytes Links
Trading Reference Links
|
The wild wrapping demon was there, once again, to cut a
valuable line at the end of the loop
<FONT face="Times New Roman"
color=#ff0000>G=<FONT
size=2>IIf(E11==G,0<FONT
face=Verdana size=2><FONT
face="Times New Roman">,G);
<FONT face="Times New Roman"
color=#000000>and take it to his dusty lair !!
<FONT face="Times New Roman"
color=#000000>Sometimes two Equity values are identical. For k=30 and for k=40
we may have E[30]=E[40]=the highest E at the Inspection
Point.
<FONT face="Times New Roman"
color=#000000>The code, without the missing line, would then ADD the kappas and
find the best choice between 30<=k<=50 is the k=70
!!!!!
<FONT face="Times New Roman"
color=#000000>Dimitris Tsokakis
----- Original Message -----
From: <A
title=tsokakis@xxxxxxxxx href="">Dimitris Tsokakis
To: <A title=amibroker@xxxxxxxxxxxxxxx
href="">amibroker@xxxxxxxxxxxxxxx
Sent: Friday, October 10, 2003 11:03 AM
Subject: The Inspection Points and the Hi-pass Filter [Equity
application]
Suppose now a
mono-parametric trading system optimization
<FONT
face="Times New Roman">k=Optimize("k",30,30,50,5);Buy=Cross(StochD(),K);Sell=Cross(50,StochD());
We search, looking at
the past performance, for an optimal solution.Our hope is to apply this
optimal for the next trading movements and make similar profits.We all know,
however, that the market changes and new parameter values give a better
performance.For MSFT the optimizations areIn Fig. 1 3/1/2000 till
31/12/2001In Fig. 2 3/1/2000 till 31/12/2002In Fig. 3 3/1/2000 till
3/1/2003If we decide by the end of 2001 to use the two-year optimization of
Fig. 1, we should trade the stock using k=50.But, another parameter value,
k=30, was the best for 2002 and 2003 and so on.The situation is more
complicated in a multi-parametric trading system used frequently in real
conditions by the mechanical system traders. If the optimal result comes
out of 5 parameters, we have to go back many years and check the robustness
of this optimal solution. Here is a drawback of this method, 3 or 5 years
ago the conditions of the market were different.The market itself may
control the parameters of a system.This feedback relation may be active with
the Inspection Points and the Hi-pass filter.The code will establish first
some Inspection Points.[fixed or variable].It will check all the parametric
Equity values, select the highest, find the respective K and apply it for the
next trading period.[Another idea is to use the average of the top3 Equities
]The result will be a variable K, closely related to the market
performance.The sure thing is that we shall avoid the troubles of the worst
optimization case. Even if the worse scenario is selectedfor a period, it
will fail right to the next inspection and will be substituted immediately
!!Of course, since this type of inspection is not emotional, the rejected K
may be selected again two years later.It is the market that dictates the
rules, not our [defective] emotions or bad memories.The Equity
controlled variable K comes from the code
//
InspectionPoints/Hi-pass filter applied to a monoperametric trading
systemSTART=DateNum()==1000530 ;x=101;EVENT=BarsSince(START)%x==0;//
Inspect every x bars after the START
dateG=0;CountER=0; for(K=30;K<=50;K=K+5){Buy=Cross(StochD(),K);Sell=Cross(50,StochD());E1=Equity(1,0);E11=ValueWhen(EVENT,E1);T11=ValueWhen(EVENT,Cum(1));G=IIf(G>E11,G,E11);CountER=CountER+1;PG=100*(-1+E1/E11);}CountER=0;Kpass=0;HIPASS=0;for(K=30;K<=50;K=K+5){Buy=Cross(StochD(),K);Sell=Cross(50,StochD());E1=Equity(1,0);E11=ValueWhen(EVENT,E1);CountER=CountER+1;PASS=IIf(E11==G,E1,0);HIPASS=HIPASS+PASS;GAIN=100*(-1+HIPASS/G);K1=IIf(E11==G,K,0);Kpass=Kpass+K1;<FONT
face=Verdana size=2>
<FONT face="Times New Roman"
color=#ff0000>G=<FONT
size=2>IIf(E11==G,0<FONT
face=Verdana size=2>,G);
}// Kpass trading
applicationBuy=Cross(StochD(),Kpass);Sell=Cross(50,StochD());
The result is in
Fig.4The optimization was giving from +3.85% to -33.19%, the Inspection
Points were close to the optimaland far from the worst scenario. The
Inspection every 101 bars was arbitrarily selected for the example.A x
research may give much better results, as you see at Fig. 5.In this example
x was fixed from the beginning.For a more sensitive approach, x may be
conditional and "feel" the main market movements, although this subject is
beyond the scope of this text.The outline of this method is more important :
We may have a REALISTIC use of optimization, close to the market
behavior.Note also that, in some cases, the Inspection Points method
results were better than the optimal.PETM, for example, was in the profits
range +174%[K=50] to +360%[K=35]The Inspection Points method was at +409% .
The explanation is very interesting : The automatic K selection used the
worse K=50 for the first 5 months and then the optimal K=35 for the rest of
the period.!! Of course the method "understood" to use K=35 fromOct2000
[K=35 is the optimal we know now...] and, on the other side, will not hesitate
to re-use K=50 wheneverthe future market conditions suggest it.
Dimitris
Tsokakis
<FONT
face="Times New Roman">
----- Original Message -----
From: <A
title=tsokakis@xxxxxxxxx href="">Dimitris Tsokakis
To: <A title=amibroker@xxxxxxxxxxxxxxx
href="">amibroker@xxxxxxxxxxxxxxx
Sent: Thursday, October 09, 2003 12:36 PM
Subject: The Inspection Points and the Hi-pass Filter
The
Counter=0;
for(K=30;K<100;K=K+20){E1=MA(C,k);CountER=CountER+1;Plot(E1,"\nE1["+WriteVal(K,1.0)+"]",1+Counter,1);}
will plot in IB the group of simple moving averages MA(C,30),
MA(C,50),MA(C,70) and MA(C,90).My data begins on Jan3, 2000.After some
reasonable period the usual indicators are defined and may be compared.Let
us select as a starting date the end of May2000.START=DateNum()==1000530
;In T/A studies we use various parameters, not always the same. An MA(C,k)
may give good results for k=30, but, as the market character changes, k=50
may be more expressive, one year later. For this reason we
re-optimizeparameters from time to time, hoping to see better performance in
the [unknown] next days/weeks/months/yearsaccording to the used
timeframe.How about doing this job automatically ?One method is to
establish the Inspection Points.For example, the
x=101;START=DateNum()==1000530
;EVENT=BarsSince(START)%x==0;PlotShapes(shapeCircle*EVENT,colorRed);
will establish an Inspection [RED] Point every 101 bars
after the START of May30, 2000.The AFL inspector will check the parameters
under his criteria at the inspection points, will take a decision and will ask
to apply this decision until the next inspection.Suppose the criterion is to
ride on the highest MA and use this MA for the next 101 bars.The procedure
should be repeated at all Inspection Points.The reslut will be a variable
parameter k with a market feedback every 101 bars.The Hi-pass filter gives a
solution to this request.
// A Hi-pass filter at the Inspection Pointsx=101;// the
inspection frequencySTART=DateNum()==1000530
;EVENT=BarsSince(START)%x==0;// the inspection
eventPlotShapes(shapeCircle*EVENT,colorRed);// puts a red dot at the
inspection
pointsG=0;CountER=0; for(K=30;K<100;K=K+20){E1=MA(C,k);//
the moving average value for the various kE11=ValueWhen(EVENT,E1);// the MA
value at the inspection pointT11=ValueWhen(EVENT,Cum(1));// the inspection
timeG=IIf(G>E11,G,E11);CountER=CountER+1;Plot(E1,"\nE1["+WriteVal(K,1.0)+"]",1+Counter,1);}Plot(G,"\nG",colorBlue,8);//
this line remembers the highest MA until the next
inspectionCountER=0;Kpass=0;HIPASS=0;for(K=30;K<100;K=K+20){E1=MA(C,k);E11=ValueWhen(EVENT,E1);CountER=CountER+1;PASS=IIf(E11==G,E1,0);HIPASS=HIPASS+PASS;K1=IIf(E11==G,K,0);Kpass=Kpass+K1;}Plot(HIPASS,"\nHI-PASS
[k="+WriteVal(kpass,1.0)+"]",colorBlack,8);// the final Hi-pass line//
Plot(Kpass,"Kpass",colorYellow,styleOwnScale);GraphZOrder=0;
The code lets the highest MA [at the inspection point] to pass
the inspection and be in use until the next red dot.In the att. gif, at
point P1 the green [90-bar] MA was the highest. The Hi-pass [dotted black]
line keeps this MA until pointP2, no matter if the green line was lower a
few days after the inspection P1. At P2 the market character has changed to
bullish.The 30-bar [white] MA is now the highest and the the new Hi-pass
line will follow it for the next 101 bars.The blue G line gives the ground
level, ie the value of the last inspection.You may see easier the final
Hi-pass line by changing GraphZOrder=0; to GraphZOrder=1;Uncomment the
// Plot(Kpass,"Kpass",colorYellow,styleOwnScale); line to see the K values in
the past history of the stock.The inspection method is objective, free from
psychological constraints and helps to hold a decision for the next x
trading days.
[this is more difficult than the code itself !!]
The inspection frequency may be fixed or variable
.
[Since we usually Buy at +1 Open, we may re-inspect before
every "Buy"...]
One interesting application is the parametric Equity
.
If we ride on the highest equity line and we have the
inspection feedback, we may avoid the known dangers of
overptimization
and make some more low-risk money.
Dimitris Tsokakis
Yahoo! Groups Sponsor
Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
|