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

RE: [amibroker] Backtest Market Order



PureBytes Links

Trading Reference Links




<FONT face=Arial color=#0000ff 
size=2>Dimitris,
Thanks 
for finishing this! I have copied the optimal values and added it to a 
commentary screen on the main indicator for future 
reference.
 
Regards, 
Jayson 
<FONT face=Tahoma 
size=2>-----Original Message-----From: DIMITRIS TSOKAKIS 
[mailto:TSOKAKIS@xxxxxxxxx]Sent: Friday, March 05, 2004 4:10 
AMTo: amibroker@xxxxxxxxxxxxxxxSubject: [amibroker] A Ti3 
crash test[4]We may have the range of parameter S for 
various DEMA/TEMA periods .The maximum distorsion of Ti3 will be between the 
DEMA and TEMA generally accepted distorsion levels.Higher S values will 
cause [undesirable] oscillations.For a specific application just add a 
lineS_range(16);at the end of the code.// The range of the 
parameter S for various Ti3 
periodsL1=LastValue(Cum(1));D=100;DD=110;C0=IIf(Cum(1)>L1-d,dd,d);Plot(C0,"\nCLOSE",1,8);PERIOD=30;//the 
DEMA and TEMA 
periodS1=DEMA(C0,PERIOD);S2=TEMA(C0,PERIOD);Div1=100*(s1-C0)/LastValue(C0);MaxDiv1=LastValue(Highest(Div1));Div2=100*(s2-C0)/LastValue(C0);MaxDiv2=LastValue(Highest(Div2));Plot(S1,"",colorRed,8);z=WriteVal(period,1.0);Plot(S2,"",colorBrightGreen,8);Title="Max 
Div for DEMA("+z+") ="+WriteVal(MaxDiv1,1.2)+"%"+", 
TEMA("+z+")="+WriteVal(Maxdiv2,1.2)+"%"+"\nThe parameter S should 
be";//the Ti3 functionfunction 
T3(price,periods,s){e1=EMA(price,periods);e2=EMA(e1,Periods);e3=EMA(e2,Periods);e4=EMA(e3,Periods);e5=EMA(e4,Periods);e6=EMA(e5,Periods);c1=-s*s*s;c2=3*s*s+3*s*s*s;c3=-6*s*s-3*s-3*s*s*s;c4=1+3*s+s*s*s+3*s*s;Ti3=c1*e6+c2*e5+c3*e4+c4*e3;return 
ti3;}//the S_range procedureprocedure 
S_range(x){k=0;smin=0;step=0.01;for(s=0.5;s<1.5;s=s+step){Ti3=T3(C0,X,s);Div3=100*(Ti3-C0)/LastValue(C0);MaxDiv3=LastValue(Highest(Div3));if(MaxDiv3>=MaxDiv1 
AND 
MaxDiv3<=MaxDiv2){Plot(Ti3,"\nT3",colorLightBlue,1);k=k+1;smin=smin+IIf(k==1,s,0);}}smax=smin+(k-1)*step;Title=Title+"\nfor 
Ti3("+WriteVal(x,1.0)+")  from "+WriteVal(smin,1.2)+" to 
"+WriteVal(smax,1.2);}//Applicationfor(x=5;x<=PERIOD;x=x+5){S_range(x);}Title=Title+"\n\nSpecific 
application";//Specific applicationS_range(16);Dimitris 
Tsokakis--- In amibroker@xxxxxxxxxxxxxxx, "DIMITRIS TSOKAKIS" 
<TSOKAKIS@xxxx> wrote:> We suppose > a. The price goes 
from 100 to 110 in one day.> b. The DEMA(20) exceeds the final value by 
MaxDiv1.> c. The TEMA(20) exceeds the final value by MaxDiv2.> d. 
We replace above averages with Ti3(5)> d. The MaxDiv of the Ti3(5) should 
vary from MaxDiv1 to MaxDiv2 in > order to preserve the usual shape of 
smoothing lines and avoid > oscillations*.> The following IB code 
will calculate automatically the range of the > parameter 
S.>  > // The range of the parameter S > 
L1=LastValue(Cum(1));D=100;DD=110;> C0=IIf(Cum(1)>L1-d,dd,d);> 
Plot(C0,"\nCLOSE",1,8);> PERIOD=20;//the DEMA and TEMA period> 
S1=DEMA(C0,PERIOD);> S2=TEMA(C0,PERIOD);> 
Div1=100*(s1-C0)/LastValue(C0);MaxDiv1=LastValue(Highest(Div1));> 
Div2=100*(s2-C0)/LastValue(C0);MaxDiv2=LastValue(Highest(Div2));> 
Plot(S1,"\nDEMA",colorRed,1);z=WriteVal(period,1.0);> 
Plot(S2,"\nTEMA",colorBrightGreen,1);> Title="Maximum Divergence for 
\nDEMA("+z+") ="+WriteVal(MaxDiv1,1.2)> 
+"%"+"\nTEMA("+z+")="+WriteVal(Maxdiv2,1.2)+"%";> //the Ti3 
average> function T3(price,periods,s)> {> 
e1=EMA(price,periods);> e2=EMA(e1,Periods);> 
e3=EMA(e2,Periods);> e4=EMA(e3,Periods);> 
e5=EMA(e4,Periods);> e6=EMA(e5,Periods);> c1=-s*s*s;> 
c2=3*s*s+3*s*s*s;> c3=-6*s*s-3*s-3*s*s*s;> 
c4=1+3*s+s*s*s+3*s*s;> Ti3=c1*e6+c2*e5+c3*e4+c4*e3;> return 
ti3;> }> > X=Param("X",5,3,20,1);//the Ti3 period> 
k=0;smin=0;step=0.01;> for(s=0.5;s<1.5;s=s+step)> {> 
Ti3=T3(C0,X,s);> 
Div3=100*(Ti3-C0)/LastValue(C0);MaxDiv3=LastValue(Highest(Div3));> 
if(MaxDiv3>=MaxDiv1 AND MaxDiv3<=MaxDiv2)> {> 
Plot(Ti3,"\nT3",colorBlue,1);k=k+1;> smin=smin+IIf(k==1,s,0);> 
}> }> smax=smin+(k-1)*step;> Title=Title+"\nThe 
Ti3("+WriteVal(x,1.0)+") parameter S should be > from 
"+WriteVal(smin,1.2)+" to "+WriteVal(smax,1.2);> > 
APPLICATION> According to the above calculation, S should vary from 0.77 
to 0.87.> Plot the upper and lower Ti3 lines together with DEMA and TEMA 
with> > //the Ti3 average> function 
T3(price,periods,s)> {> e1=EMA(price,periods);> 
e2=EMA(e1,Periods);> e3=EMA(e2,Periods);> 
e4=EMA(e3,Periods);> e5=EMA(e4,Periods);> 
e6=EMA(e5,Periods);> c1=-s*s*s;> c2=3*s*s+3*s*s*s;> 
c3=-6*s*s-3*s-3*s*s*s;> c4=1+3*s+s*s*s+3*s*s;> 
Ti3=c1*e6+c2*e5+c3*e4+c4*e3;> return ti3;> }> 
Ti3a=T3(C,5,0.77);> Ti3b=T3(C,5,0.87);> 
Plot(C,"Close",colorBlack,64);> Plot(Ti3a,"Ti3a",colorRed,1);> 
Plot(Ti3b,"Ti3b",colorBrightGreen,1);> 
Plot(DEMA(C,20),"DEMA",colorYellow,1);> 
Plot(TEMA(C,20),"TEMA",colorBlue,1);> > When the stock has sharp 
changes [10%-20% in 2-3 days], Ti3 lines are > much faster, without 
the undesirable price overshots. > [*replace 0.77 with 1.77 in 
Ti3a=T3(C,5,0.77) to see how the red line > begins to oscillate 
around the price !!]> In final analysis, a (Ti3a+Ti3b)/2 would be almost 
ideal.> Dimitris Tsokakis> --- In amibroker@xxxxxxxxxxxxxxx, 
"DIMITRIS TSOKAKIS" <TSOKAKIS@xxxx> > wrote:> > We 
suppose again the price move from 100 to 110 in one day.> > The 
DEMA/TEMA averages will exceed the final price by > MaxDiv1/MaxDiv2 
> > respectively.> > The question is to find the range of 
parameter s which will cause > to > > Ti3 smoother a MaxDiv3 
with> > > > MaxDiv1<= MaxDiv3 <=MaxDiv2> > 
> > The following IB code will find> > > > // The 
parameter s limitations  > > 
L1=LastValue(Cum(1));D=100;DD=110;> > 
C0=IIf(Cum(1)<L1-D,D,DD);> > Plot(C0,"\nCLOSE",1,8);> > 
PERIOD=20;z=WriteVal(period,1.0);> > S1=DEMA(C0,PERIOD);> > 
S2=TEMA(C0,PERIOD);> > 
Div1=100*(s1-C0)/LastValue(C0);MaxDiv1=LastValue(Highest(Div1));> > 
Div2=100*(s2-C0)/LastValue(C0);MaxDiv2=LastValue(Highest(Div2));> > 
Plot(S1,"\nDEMA",colorRed,1);> > 
Plot(S2,"\nTEMA",colorBrightGreen,1);> > Title="Maximum Divergence for 
\nDEMA("+z+") ="+WriteVal(MaxDiv1,1.2)> > 
+"%"+"\nTEMA("+z+")="+WriteVal(Maxdiv2,1.2)+"%";> > function 
T3(price,periods,s)//According to Jayson message 59811 > > {> 
> e1=EMA(price,periods);> > e2=EMA(e1,Periods);> > 
e3=EMA(e2,Periods);> > e4=EMA(e3,Periods);> > 
e5=EMA(e4,Periods);> > e6=EMA(e5,Periods);> > 
c1=-s*s*s;> > c2=3*s*s+3*s*s*s;> > 
c3=-6*s*s-3*s-3*s*s*s;> > c4=1+3*s+s*s*s+3*s*s;> > 
Ti3=c1*e6+c2*e5+c3*e4+c4*e3;> > return ti3;> > }> 
> X=Param("X",5,3,20,1);> > for(s=0.7;s<1;s=s+0.01)> > 
{> > Ti3=T3(C0,X,s);> > 
Div3=100*(Ti3-C0)/LastValue(C0);MaxDiv3=LastValue(Highest(Div3));> > 
if(MaxDiv3>=MaxDiv1 AND MaxDiv3<=MaxDiv2)> > {> > 
Plot(Ti3,"\nT3",colorBlue,1);> > 
Title=Title+"\nTi3("+WriteVal(x,1.0)+") [s="+WriteVal(s,1.2)+"]> > 
="+WriteVal(maxDiv3,1.2)+"%";> > }> > }> > 
> > EXAMPLE> > For Ti3(10) s should be in the range 
[0.70-0.79]> > For Ti3(5) s should be in [0.77-0.87]> > 
> > s values above this range will cause significant perturbation of 
> the > > Ti3 smoother and will introduce probable 
oscillation.> > Dimitris Tsokakis> > --- In 
amibroker@xxxxxxxxxxxxxxx, "DIMITRIS TSOKAKIS" > <TSOKAKIS@xxxx> 
> > wrote:> > > Let us suppose a stock goes from 100 to 
110 in one day.> > > We shall examine the response of DEMA, TEMA 
and Ti3 averages.> > > These smoothers catch the new price in some 
days, then go higher > > and > > > find again 
[asymptotically] the final price.> > > For a given DEMA/TEMA period 
we may calibrate the Ti3 period to > > > obtain the same Maximum 
Divergence from the final price.> > > EXAMPLE> > > For 
DEMA/TEMA period=20, we need Ti3 periods  x=4 and x=7 > > > 
respectively to avoid exceeding the DEMA/TEMA MaxDiv.> > > > 
> > // Ti3 crash test and Maximum Divergence, by D. Tsokakis, March 
> 2004> > > function T3(price,periods)//According to 
Jayson“s message 59811 > > > {> > > s = 0.83;> 
> > e1=EMA(price,periods);> > > e2=EMA(e1,Periods);> 
> > e3=EMA(e2,Periods);> > > e4=EMA(e3,Periods);> > 
> e5=EMA(e4,Periods);> > > e6=EMA(e5,Periods);> > > 
c1=-s*s*s;> > > c2=3*s*s+3*s*s*s;> > > 
c3=-6*s*s-3*s-3*s*s*s;> > > c4=1+3*s+s*s*s+3*s*s;> > > 
Ti3=c1*e6+c2*e5+c3*e4+c4*e3;> > > return ti3;> > > 
}> > > L1=LastValue(Cum(1));D=100;DD=110;> > > 
C1=IIf(Cum(1)<L1-D,D,DD);> > > Plot(C1,"\nCLOSE",1,8);> 
> > PERIOD=20;> > > S1=DEMA(C1,PERIOD);> > > 
S2=TEMA(C1,PERIOD);> > > X=Param("X",3,3,20,1);> > > 
Ti3=T3(C1,X);> > > //The maximum divergence> > > 
Div1=100*(s1-C1)/LastValue(C1);MaxDiv1=LastValue(Highest(Div1));> > 
> Div2=100*(s2-C1)/LastValue(C1);MaxDiv2=LastValue(Highest(Div2));> 
> > 
Div3=100*(Ti3-C1)/LastValue(C1);MaxDiv3=LastValue(Highest(Div3));> 
> > Plot(S1,"\nDEMA",colorRed,1);> > > 
Plot(S2,"\nTEMA",colorBrightGreen,1);> > > 
Plot(Ti3,"\nT3",colorBlue,1);> > > z=WriteVal(period,1.0);> 
> > Title="Maximum Divergence for \nDEMA("+z+") ="+WriteVal> 
(MaxDiv1,1.2)> > > 
+"%"+"\nTEMA("+z+")="+WriteVal(Maxdiv2,1.2)+"%"+"\n     
Ti3> > ("+WriteVal> > > 
(x,1.0)+")="+WriteVal(maxDiv3,1.2)+"%";Send BUG REPORTS 
to bugs@xxxxxxxxxxxxxSend SUGGESTIONS to 
suggest@xxxxxxxxxxxxx-----------------------------------------Post 
AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: <A 
href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check 
group FAQ at: <A 
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 



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








Yahoo! Groups Links
To visit your group on the web, go to:http://groups.yahoo.com/group/amibroker/ 
To unsubscribe from this group, send an email to:amibroker-unsubscribe@xxxxxxxxxxxxxxx 
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.