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

[amibroker] Re: T.J. Random exits on same bar in Exploration , WHY?



PureBytes Links

Trading Reference Links

 TJ

  A few more queries, 

  I run  backtest on eod data on 1 ticker,using a delay of 1 for the 
open and close,  

  The results  are o.k. "actually they are fantastic".

  Now i want to trade the system.
  I use an exploration to check when a buy or sell condition is true.

  Theres a buy so i buy the next days open,a few days later theres a 
sell signal in the exploration so i sell the next days close.

   a few days later theres a buy signal, so i buy the next day,

  But then there is a buy and sell signal on the same day.

  
  I am in a trade, do i place the same amount of equity into the 
trade again, and sell only the equity that was in the original trade, 
then sell the remainder equity when there is a sell,
to get the same profit results as in ami.


  Assume my system had great results, and the ticker i was buying had 
many of these days when it places a new buy on the day of a sell.

 Somehow i went back in time ( and the results in the backter, "ill 
be optimistic and say $5,000,000)and traded this system, selling 
either, when on a sell day there was only a sell trigger, or  selling 
if there was a new buy   
signal on the day of a sell signal, as i do not have any extra 
capital to invest.

   I then buy at the next buy signal.


What if by pure chance that the tickers main profit was coming from 
the buy i didnt take,
 due to there being a buy and sell trigger on the same day when 
already being in a trade.

 e.g.the day before  the sell day the value drops, I get a buy and 
sell trigger in my exploration,  the next day the value is still low, 
i ignore the buy trigger as i dont have any extra equity so i take 
the sell signal and sell at close at a loss.

  Suddenly the next day the price jumps, but i am not in the trade as 
i wait for my next buy signal,
 when the sell signal triggers the price has increased, but i was not 
in the trade and missed this profit oppurtunity.

  So i keep trading like this ( as i,m still in the past, as i went 
back in time) until today ,
  
 But my profits are not so great as in the ami backtest, even though 
i had an advantage of going back in time).
 

 The results in an ami backtest includes this result. 

 Is there a way to be able to exit on the same bar but not have an 
ami backtest getting an exit signal on the day of a sell signal.

 Peter. 


--- In amibroker@xxxxxxxxxxxxxxx, "amiabilityy" <amiabilityy@xxxx> 
wrote:
>   TJ,
>  Here are samples from the explorations and backtest.
> 
> The explorations and backtest are set to a delay of zero and  exit 
on 
> same bar is ticked.
> 
> 
> This exploration result uses exrem for buy and sell,
> 
> 1) why does exrem cancel the sell on the  920309 and not allow
> a buy and sell on the same bar, there was no previous buy signal. 
> 
> 2) as in a backtest, on the 920424 there was a buy 
> on the 920504 there was a sell,
> it placed a buy again on the 920504, before a sell as the buy is 
open 
> and sell is close,
> and sold this on 920507
> 
> I assume this makes it impossible to have the buy and sell dates 
and 
> other data to be placed in the 1 row of an exploration, if using 
>  
> AddColumn(IIf(sell,ValueWhen(Buy,Ref(DateNum
(),0),1),0),"buydate",1);
> AddColumn(IIf(Sell,ValueWhen(Sell,Ref
(DateNum),0),1),0),"selldate",1);
> 
> since it wont be able to differentiate what the actual true buy 
date 
> was when a buy is placed when in a buy.
> 
> 
>  I have placed B's and S's in the  exrembuy and exremsell columns
> B for buys and S for sells
> 
>  
> buy  sell   exrembuy exremsell 	buydate	selldate
> 1	1	B1	0	920309	0
> 0	1	0	S1	0	920313
> 1	0	B1	0	920323	0
> 0	1	0	S1	0	920327
> 1	0	B1	0	920413	0
> 1	1	0	S1	0	920421
> 1	1	B1	0	920424	0
> 1	1	B1	S1	920504	920504
> 0	1	0	S1	0	920507
> 1	0	B1	0	920529	0
> 0	1	0	S1	0	920603
> 
> 
> 
> 
> The exploration below uses the exrem at the buy but NOT at the sell.
> 
>  It will buy and sell on the same bar, if its not in a buy,
> or buys and sells on separate bars.
>  Does not place a new buy on the same bar on the sell day if in a 
> trade.
> 
> ( this seems more realistic to me). 
> 
> 					
> buy  sell   exrembuy  exremsell buydate	selldate
> 1	1	B1	S1	920309	920309
> 1	0	B1	0	920323	0
> 0	1	0	S1	0	920327
> 1	0	B1	0	920413	0
> 1	1	0	S1	0	920421
> 1	1	B1	S1	920424	920424
> 1	1	B1	S1	920504	920504
> 1	0	B1	0	920529	0
> 0	1	0	S1	0	920603
> 					
> 					
> below are the ami back test results, dates only.		
> 			
> 					
> buy		sell			
> Date	       Ex. date
> 3/9/1992	3/13/1992 sell on 3/9/1992, not triggered.
> 3/23/1992	3/27/1992
> 4/13/1992	4/21/1992
> 4/24/1992	5/4/1992 sell on the 5/4/1992
> 5/4/1992	5/7/1992  buy again on the 5/4/1992
> 5/29/1992	6/3/1992
> 6/10/1992	6/12/1992
> 6/12/1992	6/25/1992
> 					
> 					
> 					
> 					
> 
> 
> below is the exploration code, (have tried numerous codes),
> 
>  Thomas I hope  this is the correct way to code using equity(1) as 
> you posted in the previous post. 
> 
> all delays set to zero and tick allow exit on same bar.
> 
> buy is open sell is close. 
> 
> //ApplyStop(0,0,0,0,0);
> 
> Buy=Cross(C,MA(C,20));
> Sell=Cross(C,MA(C,2)); 
> AddColumn(Buy,"buy ");//buycolumnno exrem
> AddColumn(Sell,"sell ");//sellcolumn no exrem
> 
> 
> 
> //Short =
> //Cover = 
> //Buy=ExRem(Buy,Sell);//uncomment to test using exrem
> //Sell=ExRem(Sell,Buy);//uncomment to test using exrem
> AddColumn(Buy,"exrembuy ");//exrembuycolumn
> AddColumn(Sell,"exremsell ");//exremsellcolumn
> Equity(1);
> Filter=Buy OR Sell;
> AddColumn(IIf(Buy,ValueWhen(Buy,Ref(DateNum(),0),1),0),"buydate",1);
> AddColumn(IIf(Sell,ValueWhen(Sell,Ref(DateNum
> (),0),1),0),"selldate",1);				
> 					
> 					
> below is the backtest code.					
> 					
> 					
> Buy=Cross(C,MA(C,20));
> Sell=Cross(C,MA(C,2));
> Buy=ExRem(Buy,Sell);
> Sell=ExRem(Sell,Buy);
> 				
> 					
> 					
> Peter.


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Rent DVDs Online - Over 14,500 titles.
No Late Fees & Free Shipping.
Try Netflix for FREE!
http://us.click.yahoo.com/YoVfrB/XP.FAA/uetFAA/GHeqlB/TM
---------------------------------------------------------------------~->

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