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

Re: [amibroker] Hedging with PositionScore?



PureBytes Links

Trading Reference Links

I think I answered my own question in case you are interested. It seems to work.
 
rgds, Ed
 
 
/*

Number of positions: do not allow more than "maxLong" LONG positions

*/


SetCustomBacktestProc(""
);

maxLong =
7
;

if( Status("action") == actionPortfolio
) {

   bo =
GetBacktesterObject
();
   bo.PreProcess();
   
   
for( i = 0; i < BarCount
; i++ ) {
   
   
      cntLongOpen =
0
;
   
      
// scan through open positions and count the number of long positions

      
for
( openpos = bo.GetFirstOpenPos(); openpos; openpos = bo.GetNextOpenPos() ) {
         
         
// check for entry signal and long signal

         
if( openpos.IsOpen AND
openpos.IsLong ) {
         
            cntLongOpen = cntLongOpen +
1
;
            
         }
      
      }
   
   
      
// look at new signals and exclude Long signals if they exceed maxLong

      
for
( sig = bo.GetFirstSignal(i); sig; sig = bo.GetNextSignal(i) ) {
      
         
// check for entry signal and long signal

         
if( sig.IsEntry() AND
sig.IsLong() ) {
         
            
if
( cntLongOpen > maxLong ) {  
            
               sig.PosSize =
0
;
               
            }
else
{
            
               cntLongOpen = cntLongOpen +
1
;
               
            
            }
            
         
         }
      
      }

      bo.ProcessTradeSignals( i );
   }

   bo.PostProcess();

}
 
 
 
 
 
----- Original Message -----
From: ed nl
Sent: Tuesday, March 01, 2005 7:36 AM
Subject: Re: [amibroker] Hedging with PositionScore?

I was wondering about that also .... but don't know the answer unfortunately. Guess you need the new backtester interface for that.
 
I have a similar question:  since my system seems to work fine in practice I was planning to use some margin. Not 100% but maybe 25 or 50%.  However, being 50% on the margin with long positions must feel pretty uncomfortable (a crash may come unexpected ...). So my idea was to test using margin only for short positions (I do not expect a crash to the upside).  If I set PositionSize = -15 then MaxOpenPositions for Long positions should not exceed 7 while for Short positions MaxOpenPositions may be chosen freely until the available funds (including margin) are used up.
 
I guess this can be done with the new backtester interface as well but it seems like an idea to be hardcoded into AFL? MaxOpenLongPositions and MaxOpenShortPositions. Or is there an other way to do this?
 
regards, Ed 
 
 
 
----- Original Message -----
Sent: Monday, February 28, 2005 11:36 PM
Subject: [amibroker] Hedging with PositionScore?

I have a short-term trading system that trades a fixed set of stocks (10-20) from a Watchlist (20-40). The system generates both Long and Short signals at the same time, i.e. i am usually Long and Short at the same time on different stocks. 
 
How do i use PositionScore or PositionSize to maintain equal investment in Long and Short positions at all times? The idea is to create some system immunity against overall market movements.
 
many thanks for any idea you may have,
herman.
 
 
 


Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html





Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html





Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html



Yahoo! Groups Sponsor
ADVERTISEMENT
click here


Yahoo! Groups Links