PureBytes Links
Trading Reference Links
|
yes using foreign function can work, but I have found in the few afl I
have written that straight foreign does not always give the right
values.
Therefore I tend to always use the custom function on basis of better
safe than sorry.
--
Cheers
Graham
AB-Write >< Professional AFL Writing Service
Yes, I write AFL code to your requirements
http://www.aflwriting.com
On 23/06/07, gp_sydney <gp.investment@xxxxxxxxx> wrote:
> Graham,
>
> Thanks for that comment. It highlights a problem in one of my examples
> in the CBT document which I'll have to fix.
>
> Is there any info anywhere about the use of external symbols in custom
> backtest procedures? I've searched the AmiBroker site and can't come
> up with anything.
>
> However, I've also done some experimentation with passing composite
> symbols to the CBT and your code here, and from what I've seen,
> searching for date and time doesn't seem to be necessary. If in the
> main code the data is saved to a composite symbol, and then in the CBT
> it is read back with Foreign, directly indexing it gives exactly the
> same results as your function (I've played around with this using
> DebugView and a couple of symbols where one has many more bars than
> the other).
>
> From what I can see with that function, all it does is search the
> DateTime array for the value passed to it from the same DateTime
> array, which will always find it at the same index as the value was
> originally taken from. This seems completely redundant to me.
>
> In my test example, which passes the 100 day volume EMA to the CBT, I
> have the following code:
>
> AddToComposite(EMA(Volume,100), "~evol_"+Name(), "V");
>
> then in the CBT I reference those values with:
>
> evol = Foreign("~evol_"+sig.Symbol, "V");
> evi = evol[i];
>
> This seems to work correctly and gives exactly the same result as
> including a call to that FindValueAtDateTime function.
>
> Regards,
> GP
>
>
> --- In amibroker@xxxxxxxxxxxxxxx, Graham <kavemanperth@xxx> wrote:
> >
> > How do you store the values?
> > Normal variables do not pass directly from the base AFL to the CBT.
> > You need to use either staticvarset or save them to a composite symbol
> > and then read these as foreign symbols within the CBT. Of course you
> > could always save them to a text file, but this would be slower than
> > using compsoites
> > Sorry I ahve not read through the CBT document fully that was created
> > but you have to remember that the bars used in the loop in CBT is not
> > that same barindex values as per the base symbols. The bars counted in
> > the loops are based on the backtest bars. So reference to foreign
> > symbols needs to be done using datetime values. Tomasz has written a
> > function to allow easy referencing for this. This is slightly
> > different to the original
> >
> > function FindValueAtDateTime( eq, dt, Value )
> > {
> > found = -1;
> > for( i=0; i<BarCount AND found==-1; i++ )
> > {
> > if( dt[i]==Value ) found = i;
> > }
> > return IIf( found != -1, eq[found], Null );
> > }
> > the function is located after SetCustomBacktestProc(""); and before
> > if( Status("action") == actionPortfolio )
> > ie
> > SetCustomBacktestProc("");
> > function FindValueAtDateTime( eq, dtm, Value )
> > {
> > found = -1;
> > for( i=0; i<BarCount AND found==-1; i++ )
> > {
> > if( dtm[i]==Value ) found = i;
> > }
> > return IIf( found != -1, eq[found], Null );
> > }
> > if( Status("action") == actionPortfolio )
> > {
> > ...........................................................
> >
> > In this Value is the datetime of the bar you want to reference the
> > appropriate foreign symbol
> > eq should be the Foreign function where your required data is stored
> >
> > Here is an example that is within the open positions part inside the
> loop
> >
> > dt = DateTime();
> > for(bar=1; bar<BarCount; bar++)
> > {
> > for( OpenPos = bo.GetFirstOpenPos(); OpenPos; OpenPos =
> bo.GetNextOpenPos() )
> > {
> > SellStop[bar] = FindValueAtDateTime(
> > Foreign("~Stops_"+OpenPos.Symbol,"O"), dt, dt[bar] );
> >
> >
> >
> >
> > --
> > Cheers
> > Graham
> > AB-Write >< Professional AFL Writing Service
> > Yes, I write AFL code to your requirements
> > http://www.aflwriting.com
> >
> >
> > On 23/06/07, Grant Noble <gruntus@xxx> wrote:
> > > Thx for the reply. I've read your wonderful docs on the CBT but am
> struggling with how to get the
> > > CBT to use values calculated outside of it's loops. I store the
> correct margin value at the time I
> > > generate my signals but, at CBT signal level I'm not actually
> dealing with a symbol/date paradigm am
> > > I ? Whenever I try to access my array I just get zero values.
> Any idea what I can do about this ? G
> > >
> > > gp_sydney wrote:
> > > > I've never used MarginDeposit, but it is a property of the Signal
> > > > object in the CBT which means it could be adjusted on a per-trade
> > > > basis using the mid-level custom backtester interface.
> > > >
> > > > GP
> > > >
> > > >
> > > > --- In amibroker@xxxxxxxxxxxxxxx, Grant Noble <gruntus@> wrote:
> > > >> Anyone using MarginDeposit ??
> > > >>
> > > >> gruntusnomore wrote:
> > > >>> I need to modify MarginDeposit on a trade-by-trade basis as it is
> > > >>> calculated using order level & stop points.
> > > >>> The backtester always uses the last value of MarginDeposit
> calculated
> > > >>> for any test range - and will use this value for all trades of the
> > > > same
> > > >>> symbol.
> > > >>> Can anyone advise how I can get around this ? Is it something
> that can
> > > >>> be done w/ CBT additions ?
> > > >>> Regards, GRANT
> > > >>> :-)
> > > >>>
> > > >>>
> > > >>>
> > > >>>
> > > >>> 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
> > > >>>
> > > >>> Yahoo! Groups Links
> > > >>>
> > > >>>
> > > >>>
> > > >>>
> > > >>>
> > > >
> > > >
> > > >
> > > >
> > > > 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
> > > >
> > > > Yahoo! Groups Links
> > > >
> > > >
> > > >
> > > >
> > > >
> > >
> > >
> > > 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
> > >
> > > Yahoo! Groups Links
> > >
> > >
> > >
> > >
> >
>
>
>
>
> 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
>
> Yahoo! Groups Links
>
>
>
>
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
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/
|