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

Re: Amibroker and Optimization



PureBytes Links

Trading Reference Links

By the way, here is an improved formula, to avoid decimal levels like 
16.5 etc.
The range is somehow extended but, for some stocks it is useful.
[It permits D1, D2 to move in the 70% of the min/max distance]
Indeed, the optimal solution has the last short back in Oct 2001.
This short is profitable now ~22%.
In indicator builder, plot RRR, D1 and D2 to see the reason.
The last year RRR oscillates mainly from 5 to 15.
For the period Jan 2001 till now for example, [12,11,16] is cute and 
you may consider it as a more "local" solution.
The last Short is very nice...
[Do not forget to replace default optimization values with the 
results of optimization research.]

/*Smoothed D-ratio optimized trading system*/
R=500*(H-L)/(H+L);
Z=Optimize("Z",14,10,25,1);
RRR=DEMA(R,Z);
Rmin=LastValue(Lowest(R));RminF=floor(LastValue(Lowest(R)))+1;
Rmax=LastValue(Highest(R));RmaxC=ceil(LastValue(Highest(R)))-1;
RRRmin=LastValue(Lowest(RRR));RRRminF=floor(LastValue(Lowest(RRR)))+1;
RRRmax=LastValue(Highest(RRR));RRRmaxC=ceil(LastValue(Highest(RRR)))-
1;
Filter=1;
AddColumn(R,"D-ratio");
AddColumn(RRR,"DEMA D-ratio");
AddColumn(Rmax,"HIGHEST D-ratio");
AddColumn(Rmin,"LOWEST D-ratio");
AddColumn(RRRmax,"HIGHEST DEMA D-ratio");
AddColumn(RRRmin,"LOWEST DEMA D-ratio");
AddColumn(RRRmaxC,"HIGHEST DEMA D-ratio C");
AddColumn(RRRminF,"LOWEST DEMA D-ratio F");
D1=Optimize("D1",15,RRRminF,0.7*RRRmaxC,1);
D2=Optimize("D2",16,floor(1.3*RRRminF),RRRmaxC,1);
F1=RRR>=D2;F2=RRR<=D1;
Sell=F2;Buy=F1;
Buy=ExRem(Buy,Sell);Sell=ExRem(Sell,Buy);
Short=Sell;Cover=Buy;
Short=ExRem(Short,Cover);Cover=ExRem(Cover,Short);
Plot(RRR,"",1,1);Plot(D1,"",4,1);Plot(D2,"",5,1);

For many combinations the system prefers D1, D2 with similar or 
identical values.
Dimitris Tsokakis
PS. To remind, once again, previous performance does not guarantee 
future performance...
--- In amibroker@xxxx, "wingnut_1944" <dingo@xxxx> wrote:
> I was trying to be very thorough in the information I provided and 
> only forgot the symbol.. Not bad for me!
> 
> It is the always mysterious QQQ.
> 
> Sorry about that!
> 
> --- In amibroker@xxxx, "dtsokakis" <TSOKAKIS@xxxx> wrote:
> > You forget to mention the stock under optimization.
> > In many examples we have no trades for a long period, so, there 
is 
> > not something wrong at the first sight.
> > If for Z, D1, D2 you have had some nice trades, highly profitable 
> > perhaps, the system "avoids" to change these levels and cancels 
> some 
> > periods.
> > For TTM [trade the market] systems I have met sometimes 
> long "silent" 
> > periods. If they are in the beginning of the test period, it 
means 
> > that the system fits better to the recent period. If the silent 
> > period is the recent one, it is not a good sign. May be this 
system 
> > is not operating any more [it is somehow "out of fashion"]
> > I have numerous examples for both logics.
> > I prefer systems with "normal" distribution of profitable trades.
> > I avoid systems with two or three excellent trades the first half 
> of 
> > 2000, with a result +1000% and then many losers wich give a final 
> > +300%.
> > Dimitris Tsokakis
> > --- In amibroker@xxxx, "wingnut_1944" <dingo@xxxx> wrote:
> > > Dimitris,
> > > 
> > > I pasted the code listed below into the Automatic Analysis 
window 
> > and 
> > > ran an optimization from Jan 1 2000 thru July 2 2002 with the 
> > > following optimization results:
> > > 
> > > Z = 15
> > > D1 = 14
> > > D2 = 16.5
> > > 
> > > But there are no trades after Oct 4, 2001!
> > > 
> > > Obviously I'm doing something wrong.
> > > 
> > > My Settings are:
> > > 
> > > Positions = long and short
> > > commissions = 20 points ( I am assuming that this is $20)
> > > Buy/sell/short/cover = open with delay of 1
> > > Max Stop Loss of 10% with exit at stop
> > > Profit target and trailing stop are disabled.
> > > 
> > > What am I doing wrong?
> > > 
> > > 
> > > R=500*(H-L)/(H+L);
> > > Z=Optimize("Z",10,5,20,5);
> > > RRR=DEMA(R,Z);
> > > Rmin=LastValue(Lowest(R));RminF=floor(LastValue(Lowest(R)))+1;
> > > Rmax=LastValue(Highest(R));RmaxC=ceil(LastValue(Highest(R)))-1;
> > > RRRmin=LastValue(Lowest(RRR));RRRminF=floor(LastValue(Lowest
> (RRR)))
> > +1;
> > > RRRmax=LastValue(Highest(RRR));RRRmaxC=ceil(LastValue(Highest
> > (RRR)))-
> > > 1;
> > > D1=Optimize("D1",14,RRRminF,RRRminF+0.5*(RRRmaxC-RRRminF),1);
> > > D2=Optimize("D2",16.5,RRRminF+0.5*(RRRmaxC-RRRminF),RRRmaxC,1);
> > > F1=RRR>=D2;F2=RRR<=D1;
> > > Sell=F2;Buy=F1;
> > > Buy=ExRem(Buy,Sell);Sell=ExRem(Sell,Buy);
> > > Short=Sell;Cover=Buy;
> > > Short=ExRem(Short,Cover);Cover=ExRem(Cover,Short);
> > > Plot(R,"D-ratio",1,1);Plot(RRR,"DEMA D-ratio",7,8);
> > > Plot(D2,"Buy Level",5,1);Plot(D1,"Sell Level",4,1);
> > > 
> > > 
> > > --- In amibroker@xxxx, "dtsokakis" <TSOKAKIS@xxxx> wrote:
> > > > Sometimes it is good to estimate the efficiency of your tool.
> > > > Read 
http://groups.yahoo.com/group/Trading_Systems/message/588 
> to 
> > > see 
> > > > better.
> > > > Dimitris Tsokakis