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

[amibroker] Re: Optimizing Max Open Positions



PureBytes Links

Trading Reference Links

I came out with the following results adding more code:

eq = Foreign("~~~EQUITY", "C");
cash = Foreign("~~~EQUITY", "L");
dr = eq - Highest(eq);
MR1 = 0.1;  
MR2 = 0.5;
MaxRisk = Optimize("MaxRisk",0.10,MR1,MR2,0.05);
Pd1=3;Pd2=12;LB1=1;LB2=17;
MaxOpenPos= LB = Optimize("MaxOpenPos",7,LB1,LB2,1);
//MaxOpenPos= LB = Param("MaxOpenPos",7,LB1,LB2,1);
GPS = (MaxRisk * eq)/dr;
PositionSize = GPS = -100/MaxOpenPos;
MaxOpenPos = 
SetOption("MaxOpenPositions", MaxOpenPos );
Period = Pd = Param("Period", 3, Pd1, Pd2, 1 );
//Period = Pd = Optimize("Period", 3, Pd1, Pd2, 1 );
OptStart = (Pd = 3) AND (LB = 1) AND (MR1 = 0.1);

It was interesting to find that there were a range of values for 
MaxRisk and the same MaxOpenPos for the highest CAR/MDD and UPI, but 
all the values in the optimization were the same for this range.  
Since, I want to minimize the Max% of the closed equity to 
risk/trade, I guess I need to use the minimum in this range, which is 
0.10 (10% Max risked/trade).  

Also, concidentally or optimally, the MaxOpenPos came out to be 7, 
which is also the same value I originally chose as part of the trader-
defined criteria.  Still the discrepancy with the MaxOpenPos and the 
Composite ~OpenPosCount through which I got 12 positions open now, 
(where I plot it in a indicator window), still exists.

rgds, Pal




--- In amibroker@xxxxxxxxxxxxxxx, "palsanand" <palsanand@xxxx> wrote:
> Thanks.  I optimized the Max Open Positions to 8.
> 
> Maxpos=Optimize("maxpos",8,1,20,1);
> PositionSize = -100/Maxpos;
> SetOption("MaxOpenPositions", Maxpos );
> 
> I am getting 8 positions open in the Results window:
> 
> 12/4/03							
	
> 			
> 	Entry signals(score):GU-9967=short(-1)	 UC-9967=buy(1)	 
> 								
> 	Exit signals:GU-9967=sell	 UC-9967=cover	 	
> 							
> 	Enter Short	 GU-9967	 Price: 1.7278	 Shares: 250
> 	 Commission: 0	 Rank: -1	 Equity 3712.71		
> 		
> 	Enter Long	 UC-9967	 Price: 1.3007	 Shares: 350
> 	 Commission: 0	 Rank: 1	 Equity 3712.71		
> 		
> 	8 Open Positions:$C-9967	 $E-9967	 AU-9967
> 	 AC-9967	 E$-9967	 EA-9967	 GU-9967
> 	 UC-9967	 Equity: 3718.23	 Cash: 317.445	
> 
> But I find a discrepancy with the Open position count using the 
> following code, where I got 11 positions open, when I plot it in a 
> indicator window using 
> 
> Graph1 = Foreign( "~OpenPosCount", "V"); 
> Plot(Graph1,"OpenPosCount",1,style=1,0,100);
> 
> The following is in Automatic Analysis:
> 
> /* the following line uses Flip function to get "1" after the buy 
> signal and reset it back to "0" after sell appears. */
> 
> in_trade = Flip( Buy, Sell );
> 
> AddToComposite( in_trade, "~OpenPosCount", "V" );
> 
> /* We use "~OpenPosCount" artificial ticker to store the results. 
> Again we should run just Scan of the formula AND 
the "~OpenPosCount" 
> ticker would become available. 
> 
> Use */ 
> 
> Graph0 = Foreign( "~OpenPosCount", "V"); 
> 
> /* in Indicator Builder after running the back-test to see the 
chart 
> of the number of Open positions of your system. */
> 
> Can somebody tell me why this discrepancy occurs.  TIA.
> 
> rgds, Pal
> 
> 
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "bvandyke" <bvandyke@xxxx> wrote:
> > Pal,
> > 
> > Try the following example and modify the # of positions as needed:
> > 
> > Maxpos=Optimize("maxpos",2,1,4,1);
> > PositionSize = -100/Maxpos;
> > SetOption("MaxOpenPositions", Maxpos );
> > 
> > Bill
> > 
> > --- In amibroker@xxxxxxxxxxxxxxx, "palsanand" <palsanand@xxxx> 
> wrote:
> > > Hi All,
> > > 
> > > Does anybody has the code for Optimizing Max Open Positions.  I 
> > > remember seeing it somewhere in AFL guides.  I can't seem to 
find 
> > it 
> > > now or remember how to do it.
> > > 
> > > TIA
> > > 
> > > rgds, Pal


------------------------ 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
---------------------------------------------------------------------~->

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/