Hello,

In the User's Guide Backtester Interface section, Stat object is says, 

"Metrics are usually calculated once backtest is completed but it is also 
possible to calculate metrics during backtest. To calculate current metrics and 
get the access to them simply call GetPerformanceStats method of Backtester 
object. Please note that if you calculate statistics in the middle of the 
backtest they will include only closed trades."

I was hoping I could get access to the current long and short capital stats.  
The following code produces the correct results in AA window following 
optimization, but does not plot on the chart (values remain 0 ).  

Is this feasible in any way? Or do I have to figure out (not likely at my skill 
level) how to control trades in the backtester procedure?

TIA,

Joe

//////////////////////////////////////////////////////////
Sp = Lp = 0;

SetCustomBacktestProc( "" ); 
if ( Status( "action" ) == actionPortfolio )
 { 
        bo = GetBacktesterObject();  
        bo.Backtest(); 
  
        stats = bo.GetPerformanceStats( 0 );  
        stats_long = bo.GetPerformanceStats( 1 );
        stats_short = bo.GetPerformanceStats( 2 );

        Longprofit = stats_long.getvalue( "EndingCapital" ) 
        - stats.GetValue( "InitialCapital"  );

        bo.AddCustomMetric( "Long profit", Longprofit );
        
        Shortprofit = stats_short.getvalue( "EndingCapital" ) 
        - stats.GetValue( "InitialCapital"  );

        bo.AddCustomMetric( "Short profit", Shortprofit );

        for ( i = 0; i < BarCount - 1; i++ ) 
        { 
                Lp[ i ] = Longprofit;   
                Sp[ i ] = Shortprofit;
        }
}

Plot( Lp, "Long profit", colorBlack );
Plot( Sp, "Short profit", colorBlack );




Reply via email to