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

[amibroker] Re: Backtster - signal utilization?



PureBytes Links

Trading Reference Links

Note that in the code originally posted, the signal position size 
will be set to a tiny value when there are many many signals. You 
would need to correct for that to be at least some minimum size, with 
the realization that it would imply that some signals would go 
unfilled due to lack of resources.

Mike

--- In amibroker@xxxxxxxxxxxxxxx, "Mike" <sfclimbers@xxx> wrote:
>
> 
> Hi,
> 
> Your question is actually a bit of a trick question, since AmiBroker
> will cap the number of signals to be not more than 2 x the maximum
> permitted open positions (as per your AA settings or in code). To 
get
> around that, set the max positions to some large number (e.g. 500).
> 
> That being said, you can count (and even chart) the number of 
signals at
> each bar. Similarly, you can evenly divide your equity among all 
signals
> such that all signals will be taken (up to max permitted).
> 
> Have a look at the following (untested) code for some ideas. Run a
> backtest against it, then look at the resulting plot to see how many
> signals are generated at each bar.
> 
> Mike
> 
> 
> SetOption( "MaxOpenPositions", 2 );
> 
> fast = MA( Close, 5 );
> slow = MA( Close, 25 );
> 
> Buy = Cross( fast, slow );
> Sell = Cross( slow, fast );
> 
> AddToComposite( 0, "~Signals", "X", atcFlagDefaults |
> atcFlagEnableInPortfolio );
> PlotForeign( "~Signals", "Signals", colorRed, styleLine );
> 
> SetCustomBacktestProc( "" );
> 
> if ( Status( "action" ) == actionPortfolio )
> {
>      maxPositions = GetOption( "MaxOpenPositions" );
>      signals[0] = 0;
> 
>      bo = GetBacktesterObject();
>      bo.PreProcess();
> 
>      for ( bar = 0; bar < BarCount; bar++ )
>      {
>          count = 0;
> 
>          for ( sig = bo.GetFirstSignal( bar ); sig; sig =
> bo.GetNextSignal( bar ) )
>          {
>              if ( sig.IsEntry() )
>              {
>                  count++;  // AmiBroker tracks as many as 2 x
> maxPositions
>              }
>          }
> 
>          signals[bar] = count;  // Preserve signal count for 
charting
>          count = min( count, maxPositions ); // Do not exceed
> maxPositions
> 
>          if ( count > 0 )
>          {
>              size = -100 / count; // Divide evenly among candidates
>          }
>          else
>          {
>              size = -100;  // Prevent divide by zero error.
>          }
> 
>          size = max( size, -5 );   // Max 5% of equity (or whatever 
makes
> sense to you)
> 
>          for ( sig = bo.GetFirstSignal( bar ); sig; sig =
> bo.GetNextSignal( bar ) )
>          {
>              if ( sig.IsEntry() )
>              {
>                  sig.PosSize = size;
>              }
>          }
> 
>          bo.ProcessTradeSignals( bar );
>      }
> 
>      bo.PostProcess();
> 
>      AddToComposite( signals, "~Signals", "X", atcFlagDefaults |
> atcFlagEnableInPortfolio );
> }
> 
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "richpach2" <richpach2@> wrote:
> >
> > A portfolio backtester outputs a long list of system metrics but, 
I
> > was not able to find a metric which describes a value of cash / 
system
> > utilization. What I mean by that is, do I have enough cash to 
take all
> > the signals? After all most systems work on the principle that one
> > must take ALL signals. Not some not a few but ALL. I know I can
> > control it by positionscore, positionsize and number of open 
positions
> > as a percentage of portfolio (cash). I want to be able to use my 
cash
> > in most efficient way by matching a number of signals the system
> > generates on the portfolio with number of available positions. At
> > least, I want to know how many signals are generated for the given
> > period in test and compare it to total number of trades taken 
during
> > the test period.
> > I can see that, there are visual (Green bars) on the equity 
display
> > that show available cash but I can not see anything in the 
backtester
> > which will measure number of signals compared a number of 
positions.
> > Portfolio backtester interface reference guide shows that one can 
use
> > "cash" property in FindSignal and FindOpenPositions but, I do not 
know
> > how to construct my metric using these methods.
> > Can someone please comment on this question or point me to the
> > examples on how to use custom methods in backtester?
> >
> > Regards
> > Richard
> >
>



------------------------------------

**** IMPORTANT ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

*********************
TO GET TECHNICAL 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

*********************************
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/