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

[amibroker] Re: Backtster - signal utilization?



PureBytes Links

Trading Reference Links

Mike,

Don't worry.  I know is not your code or instructions. I will work it
out. I must be doing something different. Thanks again for your help.
I have a better understanding on how to manage or interpret backtester
signals.

Regards
Richard

--- In amibroker@xxxxxxxxxxxxxxx, "Mike" <sfclimbers@xxx> wrote:
>
> Richard,
> 
> I don't know what to tell you. It works for me on both my paid 
> AmiBroker installation using a paid data provider (on one machine), 
> and on the trial version of AmiBroker 5.20 rc1 using the default 
> database (on another machine).
> 
> Try this:
> 
> Copy to clipboard the code that I posted.
> Create a new blank chart in AmiBroker.
> Drag drop Price onto the chart.
> Right click on the chart and select edit formula.
> Select the entire formula (Edit | Select All).
> Paste the clipboard contents overtop of the formula (Edit | Paste).
> Click the ! icon to load the formula into the AA window
> Backtest a watchlist for some period.
> 
> You should see the plot. If you don't, then I don't know why :(
> 
> Mike
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "richpach2" <richpach2@> wrote:
> >
> > Mike, 
> > 
> > I have a chart open and run the backtester for the period of 
> 1/1/07 -
> > 12/31/07 and I do not see a red line plot on the open chart. I get 
> an
> > entry for ~Signals under Symbols tab list which, opens a series of
> > dash lines but not a red line on the open chart.
> > 
> > Regards
> > Richard
> > 
> > --- In amibroker@xxxxxxxxxxxxxxx, "Mike" <sfclimbers@> wrote:
> > >
> > > Richard,
> > > 
> > > If you display the code in a chart, it should plot the signals 
> for 
> > > the period backtested (e.g. 1/1/07 - 12/31/07). It is working for 
> me. 
> > > Do you have a chart open on the code? Did you run the backtest at 
> > > least once over a period?
> > > 
> > > As for number of signals using N-bar stop vs. cross; That's 
> comparing 
> > > apples to oranges. I believe that if you are holding a position, 
> > > there will be no further signals generated in later days until 
> the 
> > > position is liquidated (unless using backtester mode to allow 
> > > multiple signals per symbol). As such, I believe that it would be 
> > > false to expect the same number of signals from the two different 
> > > systems. The portfolio contents would be completely different.
> > > 
> > > Basically, you should substitute your own trading strategy in 
> place 
> > > of the cross provided, then see what the signals look like for 
> your 
> > > strategy (as opposed to some arbitrary strategy).
> > > 
> > > Mike
> > > 
> > > --- In amibroker@xxxxxxxxxxxxxxx, "richpach2" <richpach2@> wrote:
> > > >
> > > > Hello Mike,
> > > > 
> > > > Thank you for your answer. This makes it a bit clearer. I used 
> a 
> > > more
> > > > primitive method to count signals. I would set max open 
> positions 
> > > to 2
> > > > x of the watchlist content (say 200) and set the N-Bar Stop to 
> 1 
> > > bar.
> > > > This (I thought) should have given me a max. number of signals.
> > > > 
> > > > I tested the AFL you posted with SetOption( "MaxOpenPositions", 
> > > 200 );
> > > > It worked OK, but I can not see PlotForeign line after running 
> it in
> > > > backtester. Is there a trick to plot "~Signals" from composite 
> > > array?
> > > > 
> > > > Also if I set N-Bar Stop =1, I get different results. About 
> twice as
> > > > many signals with the N-Bar stop set in comparison 
> to "disabled" 
> > > where
> > > > sell signal is given by Sell = Cross( slow, fast );
> > > > 
> > > > Regards
> > > > Richard
> > > > 
> > > > 
> > > > 
> > > > --- In amibroker@xxxxxxxxxxxxxxx, "Mike" <sfclimbers@> wrote:
> > > > >
> > > > > 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@> 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/