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

[amibroker] Re: How do I get the price and indicator values in the custom backtester?



PureBytes Links

Trading Reference Links

Mike

Thanks for your help with my previous question.

Return to this thread. Yesterday I was testing codes. I found 
incidently that if removing  setforeign() and RestorePriceArrays() in 
the codes, the backtest shows the same result. I was testing upon a 
group of symbols. 

I think as to the question of the original poster, the key answer ( 
which you have pointed out previously ) may be that  the property 
sig.PosSize is the positionsize value for that bar only, thus a 
single number,therefor we cannot assign an array (yesterday close / 
ATR10) to it.  (It was a coding mistake that I also made at first.)
Thus we have to assgin the postionsize value in a bar-to-bar manner.


best regards/huanyan


--- In amibroker@xxxxxxxxxxxxxxx, "Mike" <sfclimbers@xxx> wrote:
>
> Huanyan,
> 
> The backtester code is only run after all symbols have been 
> processed. In custom backtester code there is no "current" symbol 
> (actually there is, it's ~~~Equity).
> 
> The list of signals contains all the signals on a bar by bar basis. 
> So, if 4 different symbols all resulted in a signal for a given 
bar, 
> then the signal list of the custom backtester will contain a signal 
> for each of them at that bar. Therefore, in order to access the 
> arrays for each respective symbol, you must use Foreign or 
SetForeign 
> using the symbol name held by that signal.
> 
> Mike
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "huanyanlu" <joesan99@> wrote:
> >
> > 
> > Hi, Mike
> > Sorry for my silly question, but why do you use setforeign() 
> function 
> > here. There is no other symbol here. The only symbol  is the one 
> that 
> > yielded the previous trading signals here.
> > 
> > thanks/ huanyan  
> > 
> > 
> > --- In amibroker@xxxxxxxxxxxxxxx, "Mike" <sfclimbers@> wrote:
> > >
> > > Hi,
> > > 
> > > Sorry, the SetForeign advice was good. But, my example 
propogated 
> > > another error in your original code. sig.PosSize is a scaler, 
not 
> > an 
> > > array. As such, you cannot pass the result of an array 
> calculation 
> > as 
> > > value. Instead, you must calculate the value for the given bar. 
> > Your 
> > > original example thus becomes:
> > > 
> > > SetCustomBacktestProc("");
> > > 
> > > if ( Status( "action" ) == actionPortfolio )
> > > {
> > >     bo = GetBacktesterObject();
> > >     bo.PreProcess();
> > > 
> > >     for ( bar = 0; bar < BarCount; bar++ )
> > >     {
> > >         CurrentEquity = bo.Equity;
> > > 
> > >         for ( sig = bo.GetFirstSignal( bar ); sig; sig = 
> > > bo.GetNextSignal( bar ) )
> > >         {
> > >             SetForeign( sig.Symbol );
> > >             YesterdayClose = Ref(C, -1);
> > >             YesterdayATR = Ref(ATR(10), -1);
> > >             sig.PosSize = CurrentEquity * YesterdayClose[bar] / 
> > > YesterdayATR[bar];
> > >             RestorePriceArrays();
> > >         }
> > > 
> > >         bo.ProcessTradeSignals( bar );
> > >     }
> > > 
> > >     bo.PostProcess();
> > > }
> > > 
> > > Note also that you should be calling bo.PostProcess instead of 
> > > bo.ListTrades.
> > > 
> > > Mike
> > > 
> > > --- In amibroker@xxxxxxxxxxxxxxx, "ezbentley" <ezbentley@> 
wrote:
> > > >
> > > > Hi Mike, 
> > > > 
> > > > Thanks for the attempt to help. However, I still get an error 
> > with 
> > > the following code:
> > > > 
> > > > SetForeign(sig.Symbol);
> > > > sig.PosSize = CurrentEquity * AccountRiskPercent * ref(C, -
1) / 
> > 100;
> > > > RestorePriceArrays();
> > > > 
> > > > Error 19. COM method/function 'PosSize' call failed. 
> > > > 
> > > > Thanks,
> > > >
> > >
> >
>



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

**** 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/