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

[amibroker] Re: Artificial Intelligence, an introduction, ^N225 2003


  • To: amibroker@xxxxxxxxxxxxxxx
  • Subject: [amibroker] Re: Artificial Intelligence, an introduction, ^N225 2003
  • From: TSOKAKIS@xxxxxxxxx
  • Date: Wed, 17 Dec 2003 10:34:12 -0800
  • In-reply-to: <031e01c3c4ca$f0939eb0$3f3ffea9@xxxxxxxx>

PureBytes Links

Trading Reference Links

John,
Since I have already posted the analytic report, you may see the 
settings:Delays +1, trades at Open, commission 0.5%, all stops 
disabled.
Dimitris Tsokakis
--- In amibroker@xxxxxxxxxxxxxxx, "john gibb" <jgibb1@xxxx> wrote:
> Hi DT,
> 
> thanks for all the labor!
> 
> My report results, using the old backtester, are identical to 
yours! (with Yahoo EOD data(unpurified) and Amibroker 4.50.4.)
> 
> Slightly different(see attached), however, are my:
>    a) equity plot Whereas your Title values are identical to the 
right-side labels, mine are not. ( I use what I believe to be the 
standard Equity Line code* that comes with Amibroker) 
>    b) indicator plot (the numerical values in the Title are 
slightly lower than yours)
> 
> Can anyone think of anything that explains the differences?
> 
> thanks
> 
> -john
> 
> *Equity Line code:
> //--equity-plot-- do not remove this line
> 
> MaxGraph=0;GraphXSpace=5;
> 
> GraphZOrder=1;
> 
> Plot( Equity( 0, -2 ), "Equity", -8, styleArea );
> 
> /* now buy and hold simulation */
> 
> Short=Cover=0;
> 
> Buy=Status("firstbarintest");
> 
> Sell=Status("lastbarintest");
> 
> SetTradeDelays(0,0,0,0); PositionSize = -100;
> 
> ApplyStop(0,0,0,0);
> 
> ApplyStop(1,0,0,0);
> 
> ApplyStop(2,0,0,0);
> 
> Plot( Equity( 0, -2 ), "Buy&Hold", -9 );
> 
> 
>   ----- Original Message ----- 
>   From: Dimitris Tsokakis 
>   To: amibroker@xxxxxxxxxxxxxxx 
>   Sent: Wednesday, December 17, 2003 5:17 AM
>   Subject: [amibroker] Artificial Intelligence, an introduction, 
^N225 2003
> 
> 
>   Yuki wrote at 
http://groups.yahoo.com/group/amibroker/message/54931
>   "...There are a lot of people who missed the move this year, 
and..."
> 
>   What could we do not to miss the move ? Here is the elementary AI 
proposal:
> 
>   The first significant ^N225 trough was on Jan31, 2003 and the 
very next significant peak was on Feb17.
>   Suppose we follow this pattern and then buy every x1 days after 
the first buy and sell every x2 days after the first sell.
>   By the end of the first 6 months we try to learn the rhythm of 
the market and trade it for the next 6 months.
>   The initial rhythm may need corrections as the market changes, 
inspections every 15-20 days are necessary.
>   The results are interesting:
>   There were 3 main rhythm combinations [x1,x2], the [29,24] for 34 
days, the [26,33] for the next 34 days and, finally, 
>   a potential combination [25,28] was detected around mid September 
and it is valid untill now.
>   Another important issue : The system "understood" around mid July 
that x1 should be < x2. 
>   It means buys should be more frequent than sells, a 
characteristic of bullish markets 
>   [the more you delay a Sell, the more part of the bullish trend 
you enjoy...]
>   The black [29,24] equity line was a nice solution up to the end 
of July, the white [26,33] up to the middle of August.
>   The red [25,28] was the most tenacious all year long.
>   The trading parameters are
> 
>         Settings 
>           
>         Initial Equity: 10000  Periodicity/Positions:  Daily/Long 
Short 
>         Commissions: 0.50 %  Annual interest rate: 0.00% 
>         Range: 30/5/2003 00:00:00 - 17/12/2003  Apply to: Current 
Symbol 
>         Margin requirement: 100  Futures mode: No 
>         Def. round lot size: 0  Def. Tick Size 0 
>         Drawdowns based on: Open prices      
>         Long trades 
>         Buy price: Open  Sell price:  Open 
>         Buy delay: 1  Sell delay:  1 
>         Short trades 
>         Short price: Open  Cover price:  Open 
>         Short delay: 1  Cover delay:  1 
>         Stops 
>         Maximum loss: disabled  Profit target:  disabled 
>         Value: 30.00  Value:  20.00 
>         Exit at stop? yes  Exit at stop?  no 
>           
>         Trailing stop: disabled       
>         Value: 5.00       
>         Exit at stop? no       
> 
>         Formula 
> 
> 
> SYM="^N225";in=DateNum()>=1030530; 
> STARTBUY=DateNum()==1030131; 
> STARTSELL=DateNum()==1030217; 
> startIP=DateNum()==1030530; 
> x=17; 
> // A Hi-pass filter 
> EVENT=BarsSince(startIP)%x==0; 
> k0=20;Plot(k0,"k0",Cum(1)%2,1);s0=60; 
> shape=33+2*(Cum(event)%10); 
> PlotShapes(shape*EVENT,colorRed); 
> Plot(0,"",1,1);Plot(100,"",1,1);Slevel=80; 
> G=0; 
> for(BuyFREQ=10;BuyFREQ<40;BuyFREQ++) 
> { 
> for(SellFREQ=10;SellFREQ<40;SellFREQ++) 
> { 
> Buy=BarsSince(STARTBuy)%Buyfreq ==0;Sell=BarsSince(STARTSell)%
Sellfreq==0;Short=Sell;Cover=Buy; 
> Buy=ExRem(Buy,Sell);Sell=ExRem(Sell,Buy);Short=ExRem
(Short,Cover);Cover=ExRem(Cover,Short); 
> e1=Equity(1,0);E11=ValueWhen(EVENT,E1);G=IIf(G>E11,G,E11); 
> }} 
> BFpass=0;SFpass=0; 
> for(BuyFREQ=10;BuyFREQ<40;BuyFREQ++) 
> { 
> for(SellFREQ=10;SellFREQ<40;SellFREQ++) 
> { 
> Buy=BarsSince(STARTBuy)%Buyfreq ==0;Sell=BarsSince(STARTSell)%
Sellfreq==0;Short=Sell;Cover=Buy; 
> Buy=ExRem(Buy,Sell);Sell=ExRem(Sell,Buy);Short=ExRem
(Short,Cover);Cover=ExRem(Cover,Short); 
> e1=Equity(1,0); 
> E11=ValueWhen(EVENT,E1); 
> BF1=IIf(E11==G,BuyFREQ,0);BFpass=BFpass+BF1; 
> SF1=IIf(E11==G,SellFREQ,0);SFpass=SFpass+SF1; 
> G=IIf(E11==G,0,G); 
> }} 
>  
> Buy=BarsSince(STARTBuy)%bfpass ==0;Sell=BarsSince(STARTSell)%
sfpass==0;Short=Sell;Cover=Buy; 
> Buy=ExRem(Buy,Sell);Sell=ExRem(Sell,Buy);Short=ExRem
(Short,Cover);Cover=ExRem(Cover,Short);
> Overall performance summary 
>           
>         Total net profit: 4079.56   Total commissions paid: 895.39 
>         Return on account: 40.80 %    Open position gain/loss -
34.86 
>         Buy&Hold profit: 2121.88   Bars (avg. days) in test: 137 
(201) 
>         Buy&Hold % return: 21.22%   System to Buy&Hold index: 
92.26% 
>           
>         Annual system % return:  86.13%   Annual B&H % return: 
41.83% 
>           
>         System drawdown: -339.32   B&H drawdown: 0.00 
>         Max. system drawdown: -961.08   B&H max. drawdown: -1793.58 
>         Max. system % drawdown: -8.11%   B&H max. % drawdown: -
13.39% 
>         Max. trade drawdown: -961.08       
>         Max. trade % drawdown: -8.11%       
>         Trade drawdown: -484.71       
>           
>         Total number of trades: 8   Percent profitable: 75.0% 
>         Number winning trades: 6   Number losing trades: 2 
>         Profit of winners: 4696.27   Loss of losers: -719.72 
>         Total # of bars in winners: 117   Total # of bars in 
losers: 15 
>         Commissions paid in winners: 677.37   Commissions paid in 
losers: 218.01 
>           
>         Largest winning trade: 1390.45   Largest losing trade: -
380.40 
>         # of bars in largest winner: 23   # bars in largest loser: 
9 
>         Commission paid in largest winner: 110.42   Commission paid 
in largest loser: 117.32 
>           
>         Average winning trade: 782.71   Average losing trade: -
359.86 
>         Avg. # of bars in winners: 19.5   Avg. # bars in losers: 
7.5 
>         Avg. commission paid in winner: 112.90   Avg. commission 
paid in loser: 109.01 
>         Max consec. winners: 3   Max consec. losers: 1 
>           
>         Bars out of the market: 2   Interest earned: 0.00 
>           
>         Exposure: 98.5%   Risk adjusted ann. return: 87.41% 
>         Ratio avg win/avg loss: 2.18   Avg. trade (win & loss): 
497.07 
>         Profit factor: 6.53     
> 
> 
>         Performance for ^N225  
>           
>         Total net profit: 4079.56   Total commissions paid: 895.39 
>         Return on account: 40.80 %    Open position gain/loss -
34.86 
>         Buy&Hold profit: 2121.88   Bars (days) in test: 137 (201) 
>         Buy&Hold % return: 21.22%   System to Buy&Hold index: 
92.26% 
>           
>         Annual system % return:  86.13%   Annual B&H % return: 
41.83% 
>           
>         System drawdown: -339.32   B&H drawdown: 0.00 
>         Max. system drawdown: -961.08   B&H max. drawdown: -1793.58 
>         Max. system % drawdown: -8.11%   B&H max. % drawdown: -
13.39% 
>         Max. trade drawdown: -961.08       
>         Max. trade % drawdown: -8.11%       
>         Trade drawdown: -484.71       
>           
>         Total number of trades: 8   Percent profitable: 75.0% 
>         Number winning trades: 6   Number losing trades: 2 
>         Profit of winners: 4696.27   Loss of losers: -719.72 
>         Total # of bars in winners: 117   Total # of bars in 
losers: 15 
>         Commissions paid in winners: 677.37   Commissions paid in 
losers: 218.01 
>           
>         Largest winning trade: 1390.45   Largest losing trade: -
380.40 
>         # of bars in largest winner: 23   # bars in largest loser: 
9 
>         Commission paid in largest winner: 110.42   Commission paid 
in largest loser: 117.32 
>           
>         Average winning trade: 782.71   Average losing trade: -
359.86 
>         Avg. # of bars in winners: 19.5   Avg. # bars in losers: 
7.5 
>         Avg. commission paid in winner: 112.90   Avg. commission 
paid in loser: 109.01 
>         Max consec. winners: 3   Max consec. losers: 1 
>           
>         Bars out of the market: 2   Interest earned: 0.00 
>           
>         Exposure: 98.5%   Risk adjusted ann. return: 87.41% 
>         Ratio avg win/avg loss: 2.18   Avg. trade (win & loss): 
497.07 
>         Profit factor: 6.53 
> 
> 
> 
> 
>   For Indicator builder see the timing coefficients variations and 
the more important equity lines with the code
> 
> 
>   // ^N225 timing for 2003
>   STARTBUY=DateNum()==1030131;// first trough
>   STARTSELL=DateNum()==1030217;// first peak
>   startIP=DateNum()==1030530;// inspections and trading start
>   x=17;
>   // The Hi-pass filter
>   EVENT=BarsSince(startIP)%x==0;
>   k0=10;Plot(k0,"k0",Cum(1)%2,1);
>   s0=60;
>   shape=33+2*(Cum(event)%10);
>   PlotShapes(shape*EVENT,colorIndigo);
>   Plot(0,"",1,1);
>   Plot(50,"",1,1);
>   G=0;
>   for(BuyFREQ=10;BuyFREQ<40;BuyFREQ++)
>   {
>   for(SellFREQ=10;SellFREQ<40;SellFREQ++)
>   {
>   Buy=BarsSince(STARTBuy)%Buyfreq ==0;Sell=BarsSince(STARTSell)%
Sellfreq==0;Short=Sell;Cover=Buy;
>   Buy=ExRem(Buy,Sell);Sell=ExRem(Sell,Buy);Short=ExRem
(Short,Cover);Cover=ExRem(Cover,Short);
>   e1=Equity(1,0);E11=ValueWhen(EVENT,E1);G=IIf(G>E11,G,E11);
>   }}
>   BFpass=0;SFpass=0;
>   for(BuyFREQ=10;BuyFREQ<40;BuyFREQ++)
>   {
>   for(SellFREQ=10;SellFREQ<40;SellFREQ++)
>   {
>   Buy=BarsSince(STARTBuy)%Buyfreq ==0;Sell=BarsSince(STARTSell)%
Sellfreq==0;Short=Sell;Cover=Buy;
>   Buy=ExRem(Buy,Sell);Sell=ExRem(Sell,Buy);Short=ExRem
(Short,Cover);Cover=ExRem(Cover,Short);
>   e1=Equity(1,0);
>   E11=ValueWhen(EVENT,E1);
>   BF1=IIf(E11==G,BuyFREQ,0);BFpass=BFpass+BF1;
>   SF1=IIf(E11==G,SellFREQ,0);SFpass=SFpass+SF1;
>   G=IIf(E11==G,0,G);
>   }}
>   Plot(BFPASS,"\nBFpass",colorBlack,8);Plot
(SFPASS,"SFpass",colorBlue,8);
>   // the 3 main equity lines
>   BuyFREQ=29;SellFREQ=24;
>   Buy=BarsSince(STARTBuy)%Buyfreq ==0;Sell=BarsSince(STARTSell)%
Sellfreq==0;Short=Sell;Cover=Buy;
>   Buy=ExRem(Buy,Sell);Sell=ExRem(Sell,Buy);Short=ExRem
(Short,Cover);Cover=ExRem(Cover,Short);
>   e1=Equity(1,0);
>   Plot(E1,"["+WriteVal(Buyfreq,1.0)+","+WriteVal(Sellfreq,1.0)
+"]",colorblack,8+styleLeftAxisScale);
> 
>   BuyFREQ=26;SellFREQ=33;
>   Buy=BarsSince(STARTBuy)%Buyfreq ==0;Sell=BarsSince(STARTSell)%
Sellfreq==0;Short=Sell;Cover=Buy;
>   Buy=ExRem(Buy,Sell);Sell=ExRem(Sell,Buy);Short=ExRem
(Short,Cover);Cover=ExRem(Cover,Short);
>   e1=Equity(1,0);
>   Plot(E1,"["+WriteVal(Buyfreq,1.0)+","+WriteVal(Sellfreq,1.0)
+"]",colorwhite,8+styleLeftAxisScale);
> 
>   BuyFREQ=25;SellFREQ=28;
>   Buy=BarsSince(STARTBuy)%Buyfreq ==0;Sell=BarsSince(STARTSell)%
Sellfreq==0;Short=Sell;Cover=Buy;
>   Buy=ExRem(Buy,Sell);Sell=ExRem(Sell,Buy);Short=ExRem
(Short,Cover);Cover=ExRem(Cover,Short);
>   e1=Equity(1,0);
>   Plot(E1,"["+WriteVal(Buyfreq,1.0)+","+WriteVal(Sellfreq,1.0)
+"]",colorred,8+styleLeftAxisScale);
> 
>   Dimitris Tsokakis
> 
> 
>   Send BUG REPORTS to bugs@xxxx
>   Send SUGGESTIONS to suggest@xxxx
>   -----------------------------------------
>   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
> 
>     a.. To visit your group on the web, go to:
>     http://groups.yahoo.com/group/amibroker/
>       
>     b.. To unsubscribe from this group, send an email to:
>     amibroker-unsubscribe@xxxxxxxxxxxxxxx
>       
>     c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of 
Service.


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 Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->

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:
 http://docs.yahoo.com/info/terms/