@Tomasz I am attempting to study the Custom Backtest Interface and write codes for a CBT. During the de-bugging of a simple mean reversion system, I noticed on the _Trace statements that my regular exits were given as “Reason = 1”. But in the User Guide the REASON specs show 0-regular exit, 1-max loss, 2-profit, etc.
Upon further review the reasons under the EXITTRADE method were displace by one. See screen captures from on-line user guide,
https://www.amibroker.com/guide/a_custombacktest.html
Is there a mistake I am making? Is the user guide confused?
And out of curiosity why is one value a long integer and the other a short integer?
The above also appears confirmed in this article,
http://www.amibroker.com/kb/2016/01/20/number-of-stopped-out-trades-as-a-custom-metric/
But later in the User Guide,
Image from Dbgview,
The Trace statement are from this code,
for( sig = bo.GetFirstSignal( bar ); sig; sig = bo.GetNextSignal( bar ) )
{
if( sig.IsExit() )
{
if( doTrace ) _TRACE( WriteVal( dt[bar], formatDateTime ) + ": Exiting trade for " + sig.Symbol + " Reason = " + sig.Reason );
bo.ExitTrade( bar, sig.Symbol, sig.Price, sig.Reason );
}
}