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

[amibroker] Re: Passing array to Backtester



PureBytes Links

Trading Reference Links

Nick / Mike -

I stopped by to make a post and was glancing at this.  A simple error kind of jumps off the page given your description - that should solve the problem.  Your ATC to write MSL is -

AddToComposite( MSL,"~MSL","V", atcFlagDeleteValues |  
atcFlagEnableInBacktest);   // if i plot this it looks fine

That's fine - odd to write it in the Volume field of ~MSL, but OK.  And you said that you verified the data.

You need to read it from the same field in the CBT pass.  You had -

MSL = Foreign("~MSL", "X",0);

Check the help file (ALWAYS!) and I don't think you'll find a "X", and its not reading volume.

Hope that helps

-- BruceR


--- In amibroker@xxxxxxxxxxxxxxx, "Mike" <sfclimbers@xxx> wrote:
>
> This is a popular topic lately. Van Tharp must be doing well with his new book ;)
> 
> See my earlier post on the subject for how to calculate the risk anyway you see fit. Note that the expectancy shown in that post was the formula provided by the original poster, it is not the formula used by Van Tharp, so refer to the methodology, but not the formula:
> 
> http://finance.groups.yahoo.com/group/amibroker/message/139969
> 
> Mike
> 
> --- In amibroker@xxxxxxxxxxxxxxx, Nick Willemse <nick.willemse@> wrote:
> >
> > Hi Everyone,
> > 
> > I'm trying to add Risk and R-Multiples to the TradeList.  I've looked  
> > at the example using MaxLossPercent to add r-multiples and that is  
> > pretty straight forward.  However, my risk per trade is based on some  
> > multiple of the ATR.  So I put the risk points per trade in an array,  
> > then I tried using the addtocomposite and Foreign functions to get  
> > this array to the backtester section, but it seems that all the data  
> > is zero when it gets to the backtester.  Is there any other way to  
> > make this array holding the risks per trade available to the  
> > backtester to output this for each trade?
> > 
> > Here's some of the code:-
> > 
> > 
> > Risk = 2.5 * ATR(14);
> > i = 0;
> > MSL = 0;
> > for( bar=1; bar < BarCount; bar++)
> > {
> > 	if (Buy[bar] == 1 OR Short[bar] == 1)
> > 	{
> > 		MSL[i] = Risk[bar];
> > //		_TRACE("MSL = " + MSL[i]);  //this outputs correct values
> > 		i++;
> > 	}
> > }
> > AddToComposite( MSL,"~MSL","V", atcFlagDeleteValues |  
> > atcFlagEnableInBacktest);   // if i plot this it looks fine
> > 
> > ...
> > 
> > if(AAAction == actionPortfolio)
> > {
> > 	MSL = Foreign("~MSL", "X",0);
> > 	_TRACE("MSL=" + MSL[0]);   // this output 0 for every index in the  
> > array
> > 	...
> > 
> > }
> > 
> > 
> > 
> > Nick
> >
>




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

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

TO GET TECHNICAL SUPPORT send an e-mail directly to 
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

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

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/