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

[amibroker] Inspection Points, Hi-pass Equity for the whole Market, part III



PureBytes Links

Trading Reference Links




The Inspection Points theory becomes very interesting when 
applied to profitable trading systems.
The system
 
// System xII
<FONT 
size=2>STARTBUY=DateNum()==1020222;STARTSELL=DateNum()==1020308;X=26;Y=24;Buy=BarsSince(STARTBuy)%X==0;Sell=BarsSince(STARTSell)%Y==0;Short=Sell;Cover=Buy;
is  profitable for the N100 database.[+346% when 
buy/sell/short/cover at +1Open, commission 0.25%, all stops disabled, initial 
equity=100007losers/94winners up to 2,650%, 8 stocks >+1000%, 17 stocks 
between +500% and +1000%].With the use of the Inspection Points, you could 
trade only one stock and come to a final Equity 205,911 !!How does it work 
:At each IP the code selects automatically the top Equity stock and follows 
its trades up to the next IP.The selections for the 8 IPs and the respective 
movements wereIP0 ADCT, buy 
ADCTIP1 VRSN, sell ADCT, buy 
VRSNIP2 VRSN, <FONT 
color=#ff0000>nothingIP3 ERICY, <FONT 
color=#ff0000>sell VRSN, buy ERICYIP4 VRSN, <FONT 
color=#ff0000>sell ERICY, buy VRSNIP5 ERICY, <FONT 
color=#ff0000>sell VRSN, buy ERICYIP6 ERICY, <FONT 
color=#ff0000>nothingIP7 VRSN, <FONT 
color=#ff0000>sell ERICY, buy VRSNIP8 VRSN, <FONT 
color=#ff0000>nothingYou may see the critical IP7, when the 
system decided to sell the [red] ERICY and buy [again] the [green] 
VRSN
 
// Inspection Points and the xII 
systemSTART=DateNum()==1020227 
;per=Param("per",50,50,200,10);EVENT=BarsSince(START)%per==0;EXIT=Ref(EVENT,1);Plot(10000,"",Cum(1)%2,1);Plot(0,"",1,styleNoLine);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,colorIndigo);G=0;
NUM=254;list = GetCategorySymbols( categoryGroup, NUM 
);for( i = 0; ( sym = StrExtract( list, i ) ) != ""; i++ 
){SetForeign(SYM,True,True);global Buy;global Sell;global 
Short;global 
Cover;STARTBUY=DateNum()==1020222;STARTSELL=DateNum()==1020308;X=26;Y=24;Buy=BarsSince(STARTBuy)%X==0;Sell=BarsSince(STARTSell)%Y==0;Short=Sell;Cover=Buy;E1=Equity(1,0);E11=ValueWhen(EVENT,E1);G=IIf(G>E11,G,E11);}// 
Plot(G,"\nG",colorBlue,8);D=0;F=0;list = GetCategorySymbols( 
categoryGroup, NUM );for( i = 0; ( sym = StrExtract( list, i ) ) != ""; i++ 
){SetForeign(SYM,True,True);global Buy;global Sell;global 
Short;global 
Cover;STARTBUY=DateNum()==1020222;STARTSELL=DateNum()==1020308;X=26;Y=24;Buy=BarsSince(STARTBuy)%X==0;Sell=BarsSince(STARTSell)%Y==0;Short=Sell;Cover=Buy;E1=Equity(1,0);E11=ValueWhen(EVENT,E1);G11=ValueWhen(EVENT,G);D1=IIf(E11==G,i,0);D=D+D1;EE=IIf(E11==G,E1,0);F=F+EE;}
STEP=IIf(EVENT,F-Ref(F,-1),0);T=Cum(STEP);
<FONT 
size=2>Plot(F-T,"F-T",IIf(EVENT,colorRed,colorBlack),8);Changes=Cum(D!=Ref(D,-1));SettingsCommission=0.25/100;// 
FINAL=F-T-2*Settingscommission*Changes*(F-T);Plot(FINAL,"FINAL",2,1);
Title="System  xII for Group "+WriteVal(num,1.0)+", 
TopEquity Stock is # "+ 
"["+WriteVal(D,1.0)+"]"+WriteIf(EVENT,"*","");
<FONT 
size=2>SetForeign(StrExtract(LIST,95),True,True);STARTBUY=DateNum()==1020222;STARTSELL=DateNum()==1020308;X=26;Y=24;Buy=BarsSince(STARTBuy)%X==0;Sell=BarsSince(STARTSell)%Y==0;E0=Equity(1,0);Plot(E0,"VRSN",colorBrightGreen,1);SetForeign(StrExtract(LIST,33),True,True);STARTBUY=DateNum()==1020222;STARTSELL=DateNum()==1020308;X=26;Y=24;Buy=BarsSince(STARTBuy)%X==0;Sell=BarsSince(STARTSell)%Y==0;E0=Equity(1,0);Plot(E0,"ERICY",colorRed,1);GraphXSpace=2;
 
Note 1.The code needs amibroker 4.45.0, Oct19, 
2003Note 2.The database should be absolutely 
alignedNote 3. My N100 database is in Group254 
Note 4. I have not included the [ 11 ] commissions 
at the IPs changes.Uncomment the // FINAL... line to see them included
 
Dimitris Tsokakis
----- Original Message ----- 
From: <A 
title=tsokakis@xxxxxxxxx href="">Dimitris Tsokakis 

To: <A title=amibroker@xxxxxxxxxxxxxxx 
href="">amibroker@xxxxxxxxxxxxxxx 
Sent: Friday, October 17, 2003 12:13 PM
Subject: Fw: Inspection Points and Hi-pass Equity for the whole 
Market, part II

The 
systemBuy=Cross(StochD(),30);Sell=Cross(80,StochD());was applied 
over the N100 database from Jan2000 till now.The HiEquity-pass filter 
selected for various Inspection Points [IP] theNVDA, at IP0ADBE, at 
IP1CPWR, from IP2 to IP7 andSYMC at IP8.At each IP the [blue] ground 
level G is defined. It is the value of the Equity() for this date.See how it 
works.The black line is the Equity of the selected stock from IP to the next 
IP.At IP2 [point A] the system selected CPWR [ yellow Equity line] and, 
since CPWR was the top Equity stock for IP3, IP4, IP5, IP6 and IP7, there 
was no reason to change stock.The decision at A was to sell ADBE, buy CPWR 
and follow CPWR signals until the IP8. All this period SYMC Equity [red 
line] was growing up and, some days before IP8 [point B] crossed the CPRW equity 
lineabd became the top Equity stock.The IP8 decision was to sell CPRW, 
buy SYMC and follow SYMC trades until the next IP9.   These 
details come from the Ind. builder code
// A HiEquity-pass filterSTART=DateNum()==1000530 
;Title="TOP EQ 
STOCK";EVENT=BarsSince(START)%101==0;Plot(2000,"",1,1);Plot(10000,"",Cum(1)%2,1);PlotShapes(shapeCircle*EVENT,colorRed);G=0;CountER=0;list 
= GetCategorySymbols( categoryGroup, 254 );for( i = 0; ( sym = StrExtract( 
list, i ) ) != ""; i++ ){SetForeign(SYM,True,True);global Buy;global 
Sell;Buy=Cross(StochD(),30);Sell=Cross(80,StochD());E1=Equity(1,0);//Plot(E1,"\n["+WriteVal(CountER,1.0)+"]",Counter+40,1);E11=ValueWhen(EVENT,E1);T11=ValueWhen(EVENT,Cum(1));G=IIf(G>E11,G,E11);CountER=CountER+1;}Plot(G,"\nG",colorBlue,8);CountER1=0;D=0;list 
= GetCategorySymbols( categoryGroup, 254 );for( i = 0; ( sym = StrExtract( 
list, i ) ) != ""; i++ ){SetForeign(SYM,True,True);global Buy;global 
Sell;Buy=Cross(StochD(),30);Sell=Cross(80,StochD());E1=Equity(1,0);E11=ValueWhen(EVENT,E1);//Plot(E11,"\n["+WriteVal(CountER1,1.0)+"]",Counter1+40,1);G11=ValueWhen(EVENT,G);D1=IIf(E11==G,CountER1,0);D=D+D1;EE=IIf(E11==G,E1,-1E10);Plot(EE,"",1,1);CountER1=CountER1+1;}Title=Title+" 
["+WriteVal(D,1.0)+"]"+WriteIf(EVENT," * ","");
 
<FONT 
size=2>SetForeign(StrExtract(List,92),True,True);Buy=Cross(StochD(),30);Sell=Cross(80,StochD());E0=Equity(1,0);Plot(E0,"",4,8);SetForeign(StrExtract(List,25),True,True);Buy=Cross(StochD(),30);Sell=Cross(80,StochD());E0=Equity(1,0);Plot(E0,"",7,8);
 
Now, we should eliminate the [blue] G discontinuities and come 
closer to the real facts.This is done by the // Trade the top 
Equity stockSTART=DateNum()==1000530 
;per=Param("per",101,90,110,1);EVENT=BarsSince(START)%per==0;EXIT=Ref(EVENT,1);Plot(10000,"",Cum(1)%2,1);Plot(0,"",1,styleNoLine);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,colorIndigo);G=0;NUM=254;BuyLEVEL=Param("b",30,10,50,5);SellLEVEL=Param("s",80,50,95,5);list 
= GetCategorySymbols( categoryGroup, NUM );for( i = 0; ( sym = StrExtract( 
list, i ) ) != ""; i++ ){SetForeign(SYM,True,True);global Buy;global 
Sell;Buy=Cross(StochD(),BuyLEVEL);Sell=Cross(SellLEVEL,StochD());E1=Equity(1,0);E11=ValueWhen(EVENT,E1);T11=ValueWhen(EVENT,Cum(1));G=IIf(G>E11,G,E11);}D=0;F=0;list 
= GetCategorySymbols( categoryGroup, NUM );for( i = 0; ( sym = StrExtract( 
list, i ) ) != ""; i++ ){SetForeign(SYM,True,True);global Buy;global 
Sell;Buy=Cross(StochD(),BuyLEVEL) ;Sell=Cross(SellLEVEL,StochD()) 
;E1=Equity(1,0);E11=ValueWhen(EVENT,E1);G11=ValueWhen(EVENT,G);D1=IIf(E11==G,i,0);D=D+D1;EE=IIf(E11==G,E1,0);F=F+EE;}STEP=IIf(EVENT,F-Ref(F,-1),0);T=Cum(STEP);Plot(F-T,"",IIf(EVENT,colorRed,colorBlack),8);Title="Group 
"+WriteVal(num,1.0)+", TopEquity Stock is # "+ 
"["+WriteVal(D,1.0)+"]"+WriteIf(EVENT,"*","");
 
A STEP function was introduced to measure the discontinuity 
gap [positive or negative] and the T=Cum(STEP) will act for the whole range, 
adding or subtracting at each IP the respective STEP.The final Equity line 
is continuous and is closer to the reality [some commissions are missing, when, 
for examplethe system sells CPWR at IP8 without a regular Sell signal and 
Buys SYMC without the respective regular Buy signal]This method decisions 
wereIP0 : Buy and Trade NVDAIP1 : Sell NVDA, Buy and Trade ADBEIP2 : 
Sell ADBE, Buy and Trade CPWRIP3 to IP7 : Keep on trading CPWRIP8 : Sell 
CPWR, Buy and Trade SYMC 
Let us see now if it is interesting.The final Equity value 
is 41,114.5.The 
Buy=Cross(StochD(),30);Sell=Cross(80,StochD());over the whole N100 
for the same period and settings gives a total net profit -3.5%.41 stocks 
were profitable up to +390% and the rest 60 were loosing money [15 stocks were 
below -75%...]
 
Dimitris Tsokakis
----- Original Message ----- 
From: <A 
title=tsokakis@xxxxxxxxx href="">Dimitris Tsokakis 

To: <A title=amibroker@xxxxxxxxxxxxxxx 
href="">amibroker@xxxxxxxxxxxxxxx 
Sent: Thursday, October 16, 2003 11:17 AM
Subject: Inspection Points and Hi-pass Equity for the whole Market, 
part I

The code will choose the top Equity stock at the 
Inspection Point [IP] and will trade all its [individual] signals up to the next 
inspection.
The procedure will be repeated for every future 
inspection.
The Equities at an inspection point are counted from the 
beginning of the available data.
All stocks should be aligned, missing bars should be filled 
before the research.
The starting and ending date for all stocks should be the 
same
The application is effective from Amibroker 4.44.1, Oct12, 
2003, when the 
SetForeign( ticker, fixup = True, tradeprices = 
False)
was implemented *
The selected stock at IP had an Equity value G. It is the 
ground level for the next trades and is plotted as a blue thick 
line.
Up to the next IP we may see if the selected top stock was 
profitable [Eq>G] or not [Eq<G].
The black line is the Equity from IP to IP.
How does it work : At the Inspection point X, for 
example, PETM was the top Equity stock [see PETM red equity 
line]
The code selected PETM and followed its trades up to now [PETM 
was the top stock for the next two IPs too !!]
 
// A Hi-pass Equity filter at the Inspection 
PointsSTART=DateNum()==1000530 ;Title="TOP EQ 
STOCK";EVENT=BarsSince(START)%101==0;Plot(2000,"",1,1);Plot(10000,"",Cum(1)%2,1);PlotShapes(shapeCircle*EVENT,colorRed);G=0;CountER=0;list 
= GetCategorySymbols( categoryGroup, 254 );// group IDfor( i = 0; ( sym = 
StrExtract( list, i ) ) != ""; i++ 
){SetForeign(SYM,True,True);global Buy;global 
Sell;Buy=Cross(StochD(),30);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;}Plot(G,"\nG",colorBlue,8);CountER1=0;D=0;list 
= GetCategorySymbols( categoryGroup, 254 );// group IDfor( i = 0; ( sym = 
StrExtract( list, i ) ) != ""; i++ 
){SetForeign(SYM,True,True);global Buy;global 
Sell;Buy=Cross(StochD(),30);Sell=Cross(50,StochD());E1=Equity(1,0);E11=ValueWhen(EVENT,E1);G11=ValueWhen(EVENT,G);D1=IIf(E11==G,CountER1,0);D=D+D1;EE=IIf(E11==G,E1,-1E10);Plot(EE,"",1,1);CountER1=CountER1+1;}Title=Title+" 
["+WriteVal(D,1.0)+"]"+WriteIf(EVENT," * 
","");SetForeign("PETM",True,True);Buy=Cross(StochD(),30);Sell=Cross(50,StochD());E0=Equity(1,0);Plot(E0,"",4,8);//Plot(D,"",1,styleOwnScale);
 
Notes
1. The 100 N100 stocks and the index ^NDX are placed in my 
Group254.
If your stocks are in the WatchList5, for example, you should 
change the // group ID lines as follows
 
list = GetCategorySymbols( categorywatchList, 5 
);//
 
2. The
Buy=Cross(StochD(),30);Sell=Cross(50,StochD());was 
used as example of the trading system.
Settings were arranged in AA window 
Buy, Sell at Open
Delay +1
commission 0.25%
all stops disabled
initial equity 10000
3. G [thick blue line] is the ground level, the equity value 
for the selected stock at the IP.
As you see, even for the top stocks, the system was not quite 
profitable, the [black] individual Equity lines 
are frequently below their Ground level G.
4. D is the ordinal # of the stock in the database. You may 
uncomment the last line to see the top Ds.
If you place your cursor on some bar, you will read D in the 
title.
An asterisk * will appear at each IP bar. As you 
see, on Oct20, 2000 the system sold #67 [NVDA] to buy
the new top stock #2 [ADBE] 
5. The graph is universal and will not change as you move from 
ticker to ticker in your symbol tree.
 
This is the basic idea, to ride on the top equity 
stock.
The expectation is a follow up, at least up to the next IP. 

If negative, the inspector will search for the new rising star 
of the show, right at the next IP !!
More details in part II, hopefully today...
Dimitris Tsokakis 
 
* From the 4.44.1 Readme.html




SetForeign( ticker, fixup = True, tradeprices = False) and 
RestorePriceArrays( tradeprices = False ) have new flag now: tradeprices 
(False by default)



when tradeprices is set to TRUE, then not only OHLC, V, OI, 
Avg arrays are set to foreign symbol values, but also BuyPrice, SellPrice, 
ShortPrice, CoverPrice, PointValue, TickSize, RoundLotSize, MarginDeposit 
variables are set to correspond to foreign 
security.



This allows Equity() to work well with 
SetForeign.






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:
IP4.gif

Attachment: Description: "Description: GIF image"