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

Re: [amibroker] Trading and managing multiple position



PureBytes Links

Trading Reference Links

>main reason I believe Amibroker is not portfolio trading oriented is
 
What kind of BS is that ? AmiBroker *IS* Portfolio Trading oriented.
In fact it is MOST ADVANCED portfolio backtester available.
Custom backtest procedure capability is something that has no limit.

Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message -----
Sent: Thursday, March 08, 2007 8:33 AM
Subject: Re: [amibroker] Trading and managing multiple position

there is this code
 
// This is sample formula that allows
// to open multiple, separate positions on the same symbol

// without averaging effect (i.e. each position on the same
// symbol is completely independent).
//
// Sample code is provided for trading one symbol
// Enter symbol you want to trade below
Symbol =
"MSFT";

Buy=Sell=Short=Cover=0; // real rules are defined inside custom backtest proc


SetCustomBacktestProc(""); // enable custom backtest

if( Status("action") == actionPortfolio )
{
  
// actual backtest routine

  
// (low-level)

   bo =
GetBacktesterObject();

  
SetForeign
( Symbol );
  
// make sure to calculate actual buy and buyprice arrays for symbol we need to backtest

  
Buy = 1; // For testing purposes just enter new position every bar
  
BuyPrice = Open
;
  
RestorePriceArrays
();

  
// actual backtest loop

   bo.PreProcess();

  
for( i = 1; i < BarCount; i++ )
   {
      
// first update backtest stats and handle stops

       bo.UpdateStats( i,
0 );
       bo.HandleStops( i );
      
       bo.RawTextOutput(
"Bar "
+ i );
      
if( Buy[ i - 1 ] ) // if buy signal in previous bar

       {
         bo.EnterTrade( i, Symbol,
True, BuyPrice[ i ], 500 /* $5000 into one trade */);
       }

   
      
for
( OpenPos = bo.GetFirstOpenPos(); OpenPos; OpenPos = bo.GetNextOpenPos() )
       {
           
// exit positions if their age is > 5 bars and they are profitable

         
if( OpenPos.BarsInTrade > 5 AND OpenPos.GetProfit() > 0 )
          {
            
// HERE IS A NEW PART !!!

            
// WE ARE PASSING HANDLE instead of ticker symbol

            
// THIS ENSURES PROPER OPERATION even if we have multiple positions of the same

            
// stock
             bo.ExitTrade( i, OpenPos.Handle, OpenPos.GetPrice( i,
"O"
) );
           }
       }

       bo.RawTextOutput(
"Number of open positions: "
+ bo.GetOpenPosQty() );


       bo.UpdateStats( i,
2
);
   }
      
   bo.PostProcess();
}
 
 
 
 
This is the area I hope Amibroker will improve. Although it is said lots is possible in Amibroker and one can perform complex portfolio backtests it seems to me it is impossible to find out what is exactly possible and what is not. And if something is possible how to do it.  The main reason I believe Amibroker is not portfolio trading oriented is because Amibroker is built for speed and is very usefull for single symbols systems. But complex portfolio systems is where I feel the small trader can have an edge ...
 
rgds, Ed 
 
 
 
 
----- Original Message -----
From: chwinc2000
Sent: Thursday, March 08, 2007 2:00 AM
Subject: [amibroker] Trading and managing multiple position

Hello,

Does anyone know how to enter and manage multiple positions on the
same symbol?

For example:
Buy when C>O
Sell 10 days longer.

Obviously I can have up to 9 Long positions at once. I would like each
trade to show up separately on the Backtest report so I can't use
Scale In/ Scale Out.

Does anyone know how to do this?

Thanks for the help.

__._,_.___

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html





SPONSORED LINKS
Investment management software Investment property software Investment software
Investment tracking software Return on investment software

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___