[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,
 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 from home.
Over 14,500 titles. Free Shipping
& No Late Fees. Try Netflix for FREE!
http://us.click.yahoo.com/BVVfoB/hP.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/