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

Re: [amibroker] custom column to backtest results? passing value from exploration?



PureBytes Links

Trading Reference Links

Sorry to day this, but this method will not work.
1. you are using and array value within a bar loop, which will not
give you correct results
2. the symbol that is au8tomatically referred to in the custom
backtest code is the current value of account equity. Any reference to
other symbols needs to use the foreign functions and the function
referred to later in this response.
3. you have not given the variables for the trigger type any array
identification, so only the last value calculated will be passed out
of the loop, you may also find you need to initialise the variables
before the loop to give them default values.
4. the variables to be added to custom metric will need to be further
identified so that the loop through the trades at the end will know
which result to use

I will not give complete answers with full coding as the time for this
would be longer than I have to type this. Half the fun is the
frustration as you learn all the coding techniques, the other half is
the hours used in the many attempts to get it right. In some cases
many many many many attempts.

You will need to pass the values of the indicators for each symbol, or
at least the values of which signal condition prompted the trade entry
This can be done via a few methods of which the easiest has been the
use of composite symbols. Use of this also requires a function to read
the foreign composite symbol and return the value at that bar. Tomasz
has provided a basic function for this which can be utilised called
FindEquityAtDateTime. This has been posted somewhere so search for it.
If you are using a new beta I believe staticvarset allows for arrays
instead of single value. This may be able to be used to pass the
relevant values of signal type to the CBT from the normal AFL code
part.
One item to remember is that the Signal part of the CBT is the bar of
actual trade. So if you have a delay in your code between signal and
trade you will need to ensure your values are offset by this delay
amount so reading them matches the actual bar of trade.

3 & 4 above I find the best method is to use varset to identify the
variable against trade. I simply use something along these lines
in the singal loop
Varset( "VTrigger_"+sig.Symbol+"_"+dt[bar], FunctionToGetValue(inputs) )

in the trade loop
Varget( "VTrigger_"+trade.Symbol+"_"+trade.EntryDatetime )

I probably have not included everything you will need to know as that
would require a much longer response and time to put together all the
required items, but if you pull together avery example of code you can
find amidst the various sources of Ab code you will find enough to get
you started on the right path.

-- 
Cheers
Graham Kav
AFL Writing Service
http://www.aflwriting.com



2009/3/29 Aron <aron.groups@xxxxxxxxx>:
>
> SetCustomBacktestProc( "" );
>
> if ( Status( "action" ) == actionPortfolio )
> {
>     bo = GetBacktesterObject();
>     bo.PreProcess();
>
>     for ( bar = 0; bar < BarCount; bar++ )
>     {
>
>         for ( sig = bo.GetFirstSignal( bar ); sig; sig = bo.GetNextSignal(
> bar ) )
>         {
>             SetForeign( sig.Symbol );
>             array = RSI( 14 );
>             RSI_Trigger = array[bar] > 20;
>             array = V;
>             V_Trigger = array[bar] > 200000;
>             RestorePriceArrays();
>         }
>
>         bo.ProcessTradeSignals( bar );
>     }
>
>     for ( trade = bo.GetFirstTrade(); trade; trade = bo.GetNextTrade() )
>     {
>         trade.addcustommetric( "RSI_Triger", RSI_Trigger );
>         trade.addcustommetric( "V_Trigger", V_Trigger );
>     }
>
>     bo.PostProcess();
> }
>
>
>
>
>
>
>
> Radek Simcik wrote:
>
> Hi,
>
> I do know how to add calculated custom metrics to the backtest result
> but I did not get how to add column like I do in the exploration mode
> AddColumn( RSI(14), "RSI", 1.0, colorDefault, colorDefault,50); or
> better a value from my own variable.
>
> AddColumn( RSI(14)>20, "RSI trigger", 1.0, colorDefault, colorDefault,50);
> AddColumn( V>200000, "V trigger", 1.0, colorDefault, colorDefault,50);
>
> Why I need it? Let's say I am using more than one trigger and I want
> to know which one worked...
>
> I went through http://www.amibroker.com/guide/a_custommetrics.html but
> didn't find an answer.
>
> Any help is appreciated.
>
> Thank you,
>
> Radek
>


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

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