Home › Forums › Trading System Mentor Course Community › AmiBroker and Data Setup › Strange backtest result?
- This topic is empty.
-
AuthorPosts
-
November 29, 2019 at 6:44 am #101956Nick RadgeKeymaster
Getting some weird stuff happening:
When I run a backtest for my MOC system for Nov I get net profit $2362 in the summary, yet on the monthly table I get +1.9%?
November 29, 2019 at 7:28 am #110615GlenPeakeParticipantHey Nick,
As a bit of a guess…. maybe a corrupt ‘Profit Table.afl’ file? Located in the folder
Program FilesAmiBrokerFormulasReport ChartsMine looks like this:
////////////////////////////////////////////////Code:EnableTextOutput( 3 ); // enable HTML output into report (Version 5.84 or higher!)eq = C;
yr = Year();
mo = Month();YearChange = yr != Ref( yr, 1 );
MonChange = mo != Ref( mo, 1 );FirstYr = 0;
LastYr = 0;startbar = 0;
////////////////////////////
// SKIP non-trading bars
////////////////////////////for ( i = 0; i < BarCount; i++ ) { if ( eq[ i ] ) { startbar = i; break; } } //////////////////////////// // collect yearly / monthly changes in equity // into dynamic variables //////////////////////////// LastYrValue = eq[ startbar ]; LastMoValue = eq[ startbar ]; MaxYrProfit = MinYrProfit = 0; MaxMoProfit = MinMoProfit = 0; for ( i = startbar + 1; i < BarCount; i++ ) { if ( YearChange[ i ] || i == BarCount - 1 ) { Chg = 100 * ( -1 + eq[ i ] / LastYrValue ); VarSet( "ChgYear" + yr[ i ], Chg ); MaxYrProfit = Max( MaxYrProfit, Chg ); MinYrProfit = Min( MinYrProfit, Chg ); if ( FirstYr == 0 ) FirstYr = yr[ i ]; LastYr = yr[ i ]; LastYrValue = eq[ i ]; } if ( MonChange [ i ] || i == BarCount - 1 ) { mon = mo[ i ]; Chg = 100 * ( -1 + eq[ i ] / LastMoValue ); VarSet( "ChgMon" + yr[ i ] + "-" + mon, Chg ); VarSet( "SumChgMon" + mon, Chg + Nz( VarGet( "SumChgMon" + mon ) ) ); VarSet( "SumMon" + mon, 1 + Nz( VarGet( "SumMon" + mon ) ) ); MaxMoProfit = Max( MaxMoProfit, Chg ); MinMoProfit = Min( MinMoProfit, Chg ); LastMoValue = eq[ i ]; } } MonthNames = "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec"; function GenProfitTableHTML( ) { printf( "
n” );
printf( “
n” ); Header = “Year,” + MonthNames + “,Yr%%”;
for ( Col = 0; ( Colname = StrExtract( Header, Col ) ) != “”; Col++ )
{
printf( “” + Colname + “ ” );
}printf( “
n” );
for ( y = FirstYr; y <= LastYr; y++ ) { //Color = ColorRGB( IIf( row == 0 || col == 0 || col == 13, 220, 255 ), 255, IIf( row % 2, 255, 220 ) ); // new row if ( y % 2 ) printf( "
n ” );
else
printf( “n ” ); printf( “%g
“, y );
for ( m = 1; m <= 12; m++ ) { Chg = VarGet( "ChgMon" + y + "-" + m ); if ( NOT IsNull( Chg ) ) { if ( Chg >= 0 )
printf( “%.1f%% “, Chg );
else
printf( “%.1f%% “, Chg );
}
else
printf( “N/A ” );
}if ( y % 2 )
printf( “” );
else
printf( “” ); x = VarGet( “ChgYear” + y );
if ( x >= 0 )
printf( “%.1f%%“, x );
else
printf( “%.1f%%“, x );
printf( “
n” ); // end row
}printf( “
n” ); // new row printf( “
Avg ” );
for ( m = 1; m <= 12; m++ ) { x = Nz( VarGet( "SumChgMon" + m ) / VarGet( "SumMon" + m ) ); if ( x >= 0 )
printf( “%.1f%% “, x );
else
printf( “%.1f%% “, x );
}printf( “
” );
printf( “
n” );
}
///////////////////////////
// This function checks if currently selected symbol
// is portfolio equity
//////////////////////////
function CheckSymbol()
{
if ( Name() != “~~~EQUITY” AND Name() != “~~~OSEQUITY” )
{
printf( “For accurate results switch to ~~~EQUITY symbol
” );
}
}CheckSymbol();
////////////////////////////
// Main program
////////////////////////////
GenProfitTableHTML();November 29, 2019 at 10:29 am #110616Nick RadgeKeymasterThanks Glen. Will take a look.
I have an old version loaded after upgrading my laptop. I think I need to go for the latest version. -
AuthorPosts
- You must be logged in to reply to this topic.