Two possibilties I can think of are to either use dynamic variables to
save the reason values for each sell signal, and then read those
variables in the custom backtester, or implement the stop algorithm in
the custom backtester. That would require using the low-level
interface though.

If you use dynamic variables, you'll need to use the date as part of
the variable name, as bar numbers will be different in the custom
backtester. For example, as you set the Sell array indication, and
assuming you have used "dt = DateTime()" somewhere, add:

VarSet("Ex"+Name()+DateTimeToStr(dt[i]), <your reason code>);

Then in the custom backtester, something like:

reason = VarGet("Ex"+trade.Symbol+DateTimeToStr(trade.ExitDateTime));
trade.AddCustomMetric("Exit Reason", reason);

I haven't tried this, so can't guarantee it will work, and you may
need to play around with exact dates depending on your trade delays,
as the exit date may not match the Sell signal date. Also not sure if
you can use ordinary dynamic variables or you have to use static ones.
If you can't get it to work, add _TRACE statements and use DebugView
to see exactly what dates you're getting in both places.

Regards,
GP


--- In [email protected], "davemabe2000" <[EMAIL PROTECTED]> wrote:
>
> I'm implementing my own stops via the loop as described in the "Coding
> your own custom stop types" section of this page:
> 
> http://www.amibroker.com/guide/h_backtest.html
> 
> I'd like to add a column to the backtest report for "Reason For Exit"
> depending on which branch of my custom exit strategy was invoked. 
> I've seen the examples in the help file for "Adding custom backtest
> metrics".  The problem is that there is no way to determine what
> happened in my custom stop loop using anything in the Trade object
> from the backtester.
> 
> http://www.amibroker.com/guide/a_custombacktest.html
> 
> Is there some way I can store information from within my stop loop
> that can be easily retrieved from within the loop in the backtest
> section of code that loops through the closed trades so my custom
> metric can be added?
>


Reply via email to