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

[amibroker] A new method, IV



PureBytes Links

Trading Reference Links




The Daily-Weekly Stochastic divergence gives interesting 
Entries/Exits for futures.
Should we use it as a basis of a trading system to 
trade both Light Crude Oil and Gold ?
This method has some suggestions on the subject:
 
// CLZ03, GCZ03 research, by D. Tsokakis, 
Nov2003
START=DateNum()==990802 
;Plot(10000,"",1,1);per=100;EVENT=BarsSince(START)%per==0;// 
The Daily-Weekly Stochastic DivergenceTimeFrameSet( 
inDaily ); sD = StochD(); TimeFrameSet( inWeekly ); sW=StochD(); 
TimeFrameRestore(); DailyStochD=TimeFrameExpand( sD, 
inDaily);WeeklyStochD=TimeFrameExpand(sW,inWeekly);Cond1=Ref(DailyStochD,-1)==HHV(DailyStochD,3);sD1=ValueWhen(Cond1,Ref(DailyStochD,-1));Cond2=Ref(DailyStochD,-1)>70 
AND Ref(sD1,-1)>sD1 
;Cond3=WeeklyStochD>Ref(WeeklyStochD,-5);Div=Cond2 AND 
Cond3;Cond11=Ref(DailyStochD,-1)==LLV(DailyStochD,3);sD11=ValueWhen(Cond11,Ref(DailyStochD,-1));Cond21=Ref(DailyStochD,-1)<30 
AND Ref(sD11,-1)<sD11 
;Cond31=WeeklyStochD<Ref(WeeklyStochD,-5);Div1=Cond21 AND 
Cond31;// The trading system
Buy=div1;Sell=div;Short=Sell;Cover=Buy;// the 
Indicator builder 
partE34=Equity(1,0);z=Cum(event);Counter=Cum(EVENT)%10;shape=IIf(Counter==1,shapeDigit0,IIf(Counter==2 
,shapeDigit1,IIf(Counter==3 ,shapeDigit2,IIf(Counter==4 
,shapeDigit3,IIf(Counter==5 ,shapeDigit4,IIf(Counter==6 
,shapeDigit5,IIf(Counter==7 ,shapeDigit6,IIf(Counter==8 
,shapeDigit7,IIf(Counter==9 
,shapeDigit8,shapeDigit9)))))))));PlotShapes(shape*EVENT,colorBlack,0,Graph0,0);dcounter=1+Cum(Counter==1 
AND Ref(Counter,-1)==0);dshape=IIf(dCounter==1,shapeNone,IIf(dCounter==2 
,shapeDigit1,IIf(dCounter==3 ,shapeDigit2,IIf(dCounter==4 
,shapeDigit3,IIf(dCounter==5 ,shapeDigit4,IIf(dCounter==6 
,shapeDigit5,IIf(dCounter==7 ,shapeDigit6,IIf(dCounter==8 
,shapeDigit7,IIf(dCounter==9 
,shapeDigit8,shapeDigit9)))))))));PlotShapes(dshape*event,colorBlack,0,Graph0,10);// 
The Automatic Analysis 
partAddColumn(z-1,"IP",1.0,colorBlack,colorOrange);AddColumn(E34,"E");for(IPsAgo=2;IPsAgo<LastValue(z);IPsAgo=IPsAgo+1){Progress=100*(-1+E34/ValueWhen(event,E34,IPsAgo+1));AddColumn(Progress,WriteIf(IPsAgo==2,"Progress 
","")+WriteVal(IPsAgo,1.0)+" IPs 
ago",1.2,colorBlack,IIf(Progress>0,colorBrightGreen,colorRed));}Filter=event;
 
Explore both above futures for all quotations [data at least 
from Jan1999 till now...]
The attached gif is the main purpose of this 
study.
The way LightCrudeOil is traded does not match to 
this style, it has a lot of problems [red cells] for both the 
short-term
and the long-term trader. The Daily-Weekly divergence may give 
interesting signals, but it can not be the basis of a system,
its role should be only consultive.
The Gold trading profile is closer to this method.[the matrix 
is full of green cells for short and long time frames]
The  D-W StochD Div may be the basis of a trading system, 
if we suppose that gold traders
will not change dramatically thier habits.
Above all, the Daily-Weekly divergence is a way to "code" the 
style of trading.
[CL goes much better with the usual daily chart 
Stochastic Divergence, as posted from time to time to this great 
list...]
 
 

 
----- Original Message ----- 
From: <A 
title=tsokakis@xxxxxxxxx href="">Dimitris Tsokakis 

To: <A title=amibroker@xxxxxxxxxxxxxxx 
href="">amibroker@xxxxxxxxxxxxxxx 
Sent: Tuesday, November 04, 2003 2:08 PM
Subject: A new method, III

Here is another, interesting, QQQ approach.
The P=15, d=65 gave nice profits the bearish years, has some 
small problem the last months of the bearish cycle [IP5 to IP6] and 

is profitable again.
The "5 IPs ago" followers [time frame =500 bars] did not even 
feel the IP5, IP6 decline.
The respective code is
 
START=DateNum()==1000601 
;Plot(5000,"",1,1);per=100;EVENT=BarsSince(START)%per==0;// The 
trading 
systemP=Optimize("p",15,5,50,5);X5=100*((Sum(IIf(C>Ref(C,-1),(C-Ref(C,-1)),0),P))-(Sum(IIf(C<Ref(C,-1),(Ref(C,-1)-C),0),P)))/((Sum(IIf(C>Ref(C,-1),(C-Ref(C,-1)),0),P)+(Sum(IIf(C<Ref(C,-1),(Ref(C,-1)-C),0),P))));d=Optimize("d",65,-80,80,1);Sell=Cross(x5,d);Buy=Cross(-D,X5);Buy=ExRem(Buy,Sell);Sell=ExRem(Sell,Buy);Short=Cross(D,X5);Cover=Buy;// 
the Indicator builder 
partE34=Equity(1,0);z=Cum(event);Counter=Cum(EVENT)%10;shape=IIf(Counter==1,shapeDigit0,IIf(Counter==2 
,shapeDigit1,IIf(Counter==3 ,shapeDigit2,IIf(Counter==4 
,shapeDigit3,IIf(Counter==5 ,shapeDigit4,IIf(Counter==6 
,shapeDigit5,IIf(Counter==7 ,shapeDigit6,IIf(Counter==8 
,shapeDigit7,IIf(Counter==9 
,shapeDigit8,shapeDigit9)))))))));PlotShapes(shape*EVENT,colorBlack,0,Graph0,0);dcounter=1+Cum(Counter==1 
AND Ref(Counter,-1)==0);dshape=IIf(dCounter==1,shapeNone,IIf(dCounter==2 
,shapeDigit1,IIf(dCounter==3 ,shapeDigit2,IIf(dCounter==4 
,shapeDigit3,IIf(dCounter==5 ,shapeDigit4,IIf(dCounter==6 
,shapeDigit5,IIf(dCounter==7 ,shapeDigit6,IIf(dCounter==8 
,shapeDigit7,IIf(dCounter==9 
,shapeDigit8,shapeDigit9)))))))));PlotShapes(dshape*event,colorBlack,0,Graph0,10);// 
The Automatic Analysis 
partAddColumn(z-1,"IP",1.0,colorBlack,colorOrange);AddColumn(E34,"E");for(IPsAgo=2;IPsAgo<LastValue(z);IPsAgo=IPsAgo+1){//AddColumn(ValueWhen(event,E34,IPsAgo+1),"E34 
2 
IPsAgo");Progress=100*(-1+E34/ValueWhen(event,E34,IPsAgo+1));AddColumn(Progress,WriteIf(IPsAgo==2,"Progress 
","")+WriteVal(IPsAgo,1.0)+" IPs 
ago",1.2,colorBlack,IIf(Progress>0,colorBrightGreen,colorRed));}Filter=event;
 
Do not be surprised with the modified 
d=Optimize("d",65,-80,80,1); , some stocks style is contrarian and it is better 
to buy high CMO and sell low...
 
----- Original Message ----- 
From: <A 
title=tsokakis@xxxxxxxxx href="">Dimitris Tsokakis 

To: <A title=amibroker@xxxxxxxxxxxxxxx 
href="">amibroker@xxxxxxxxxxxxxxx 
Sent: Tuesday, November 04, 2003 1:15 PM
Subject: A new method, II

The same code may give another interesting 
result.
Select a stock, say BEAS and hit optimize.
Replace the optimal solution [=41] in the default 
place
<FONT 
face="Times New Roman">d=<FONT 
size=2>Optimize("d"<FONT 
size=2>,41,<FONT 
size=2>10,80<FONT 
size=2>,1);
and Explore the current stock for all quotations. 

The result matrix is quite informative for the past behavior 
of the recent optimal solution. It was always good, had some problems around 
IP5, IP6
[autumn 2002] but came back to profits.
The optimal d=64 for CSCO was not 
always safe.
For INTC, the d=13 is also interesting : After a congestive 
period around IP5, IP6 [spring-autumn 2002] it came back to progressive 
profits.
The optimal d=54 for ^NDX is rather coincidental [the profits 
are mainly due to the period IP2 to IP3] and does not give [IMO] any kind of 

guarantee for a future use. 
 
----- Original Message ----- 
From: <A 
title=tsokakis@xxxxxxxxx href="">Dimitris Tsokakis 

To: <A title=amibroker@xxxxxxxxxxxxxxx 
href="">amibroker@xxxxxxxxxxxxxxx 
Sent: Tuesday, November 04, 2003 12:28 PM
Subject: A new method

Except the Equity values, we need the Equity progress as time 
goes by. 
A stock may be highly profitable for 6 months, two years 
ago and presents high Equity value in a 3-year period, 
but it may be a loser the last year.
For this study we may establish some Inspection Points, 
equally distributed in the test period and check the relative Equity 
progress.
The code is divided into 4 parts.
1. Introduction
START=DateNum()==1000601 ;Plot(5000,"",1,1);
My data begin on Jan2000. The majority of the 
indicators I use are well defined the first 6 months. June1, 2000 is a good 
starting point .
The 5000 line is placed below the initial Equity 10000, many 
stocks have loosing periods and it is used to align the IP digits.
per=100;EVENT=BarsSince(START)%per==0;The IPs will be 
placed every 100 bars for the inspection EVENT. The distance of each IP from the 
starting date is a multiple of 100.
2. The trading system
CMO5 with threshold d=58 was selected for the 
examples.Long&Short trades are included, the system is almost always in the 
market.
3. The Indicator builder 
part
Scan and backtest the stock [or the database] for all 
quotations. Hit Equity button and you will automatically have a new IB pane 
with
the Equity, the B&H yellow line and the IPs counter on the 
same graph. If you place your cursor on IP6 you may read the respective 
Equity
and B&H value.
4. The AA part.
Explore the stock [or the database] for all 
quotations.
The 
Filter=event; 
will check only the IP dates.
The 1st column is the name of the stock, the 2nd is the IP 
dates
The 3rd column is the IP number [from 0 to 8 in the 
example]
The 4th column[E34] is the Equity value for the respective 
IP.
We see for APOL 21,830 on 1/6/2000, 28900 on 23/10/2000 
etc.
The 5th column[Progress 2 IPs ago] checks per IP the % of the 
Equity progress 2 IPs ago.
The 8th IP is compared to the 6th, the 7th is compared to the 
5th etc.
The two first IPs are without comparison.
The 6th column[3 IPS ago] checks per IP the % progress of 
the Equity compared to the IP 3 IPs ago.
The comparison will be continued 
until the progress of the last IP related to the first.
We read in APOL last row, last column 314.64. The  Equity 
for IP8 is 90,518.73, the Equity for IP0 is 21,830.66
and the progress is 90,518.73/21,830.66=4.1464 or 314.64%, 
which gives the gain if the Entry is IP0 and the Exit is IP8. 
For easy reading, positive progress has green background and 
negative progress has red.
 
// The progress of the Equity curve, by D. 
Tsokakis, Nov2003
START=DateNum()==1000601 
;Plot(5000,"",1,1);per=100;EVENT=BarsSince(START)%per==0;// 
The trading 
systemP=5;X5=100*((Sum(IIf(C>Ref(C,-1),(C-Ref(C,-1)),0),P))-(Sum(IIf(C<Ref(C,-1),(Ref(C,-1)-C),0),P)))/((Sum(IIf(C>Ref(C,-1),(C-Ref(C,-1)),0),P)+(Sum(IIf(C<Ref(C,-1),(Ref(C,-1)-C),0),P))));d=Optimize("d",58,10,80,1);Sell=Cross(x5,d);Buy=Cross(-D,X5);Buy=ExRem(Buy,Sell);Sell=ExRem(Sell,Buy);Short=Cross(D,X5);Cover=Buy;// 
the Indicator builder 
partE34=Equity(1,0);z=Cum(event);Counter=Cum(EVENT)%10;shape=IIf(Counter==1,shapeDigit0,IIf(Counter==2 
,shapeDigit1,IIf(Counter==3 ,shapeDigit2,IIf(Counter==4 
,shapeDigit3,IIf(Counter==5 ,shapeDigit4,IIf(Counter==6 
,shapeDigit5,IIf(Counter==7 ,shapeDigit6,IIf(Counter==8 
,shapeDigit7,IIf(Counter==9 
,shapeDigit8,shapeDigit9)))))))));PlotShapes(shape*EVENT,colorBlack,0,Graph0,0);dcounter=1+Cum(Counter==1 
AND Ref(Counter,-1)==0);dshape=IIf(dCounter==1,shapeNone,IIf(dCounter==2 
,shapeDigit1,IIf(dCounter==3 ,shapeDigit2,IIf(dCounter==4 
,shapeDigit3,IIf(dCounter==5 ,shapeDigit4,IIf(dCounter==6 
,shapeDigit5,IIf(dCounter==7 ,shapeDigit6,IIf(dCounter==8 
,shapeDigit7,IIf(dCounter==9 
,shapeDigit8,shapeDigit9)))))))));PlotShapes(dshape*event,colorBlack,0,Graph0,10);// 
The Automatic Analysis 
partAddColumn(z-1,"IP",1.0,colorBlack,colorOrange);
<FONT 
size=2>AddColumn(E34,"E34");for(IPsAgo=2;IPsAgo<LastValue(z);IPsAgo=IPsAgo+1){Progress=100*(-1+E34/ValueWhen(event,E34,IPsAgo+1));AddColumn(Progress,WriteIf(IPsAgo==2,"Progress 
","")+WriteVal(IPsAgo,1.0)+" IPs 
ago",1.2,colorBlack,IIf(Progress>0,colorBrightGreen,colorRed));}Filter=event;
 
In every cell of this AA matrix we read the % progress of the 
Equity in comparison to the previous IPs [in the example per=100 means we check 

200 bars ago, 300 bars ago etc]
Let us have a first taste of the matrix info:
*APOL is full of green cells. At any 
IP the correlation to any previous IP is positive. The first column presents the 
progress related to 2IPs ago.
It was +129.10% back on March2001, +58.16% <FONT 
size=2>on Oct2002 and just a +5.19% on Aug2003, compared to the Equity 200 bars 
ago.
[Time for a red cell in the next inspection ???]
*The tough question for APOL is already a fact for 
BEAS. 
The last IP has red cells, compared to the 2IPs ago, 3IPS ago, 
4IPS ago and 5IPS ago [500 bars ago]
*APCC was a horrible example for CMO5, 
it was steadily a loser from IP0 to IP6.
The last IP8 is 97.12% profitable for the last 200 bars and 
34.86% profitable for the last 300 bars.
The preference of APOL or APCC is not an easy question. 

A recent trader would enjoy almost a double price with APCC 
and only a 5% with the top APOL.
*BGEN has some CMO5 problems the last 
3 IPs. The small +3.24% [IP5, column 2IPs ago] was quite informative for BGEN 
future movements...
*INTC is not good the last 400 bars 
[The small +3.83 at the IP4 anticipated a red future...]
The last -9.50% is an indication for positive IPs 
soon.
*INTU has some good CMO5 news. After 
the decline of the "2IPs ago" column [66%, 39%, 13%, 2%] a new +46% came to 
change the perspectives .
I think we may "read" a lot of informations from this 
matrix.
Dimitris Tsokakis






Yahoo! Groups Sponsor


  ADVERTISEMENT 









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.



Attachment:
1futures.gif

Attachment: Description: "Description: GIF image"