//+------------------------------------------------------------------+
//| Lesson 12 - Dump Strategy Tester statistics |
//| Run this FROM INSIDE the Strategy Tester, not on a live chart. |
//+------------------------------------------------------------------+
#property copyright "Strategist Academy"
#property version "1.00"
void OnStart()
{
if(!MQLInfoInteger(MQL_TESTER))
{
Print("This script only reports inside the Strategy Tester. ");
Print("Open the tester, pick this script, and run it.");
return;
}
Print("========== Strategy Tester report ==========");
Print("Initial deposit: ", DoubleToString(TesterStatistics(STAT_INITIAL_DEPOSIT), 2));
Print("Net profit: ", DoubleToString(TesterStatistics(STAT_PROFIT), 2));
Print("Gross profit: ", DoubleToString(TesterStatistics(STAT_GROSS_PROFIT), 2));
Print("Gross loss: ", DoubleToString(TesterStatistics(STAT_GROSS_LOSS), 2));
Print("Profit factor: ", DoubleToString(TesterStatistics(STAT_PROFIT_FACTOR), 3));
Print("Expected payoff: ", DoubleToString(TesterStatistics(STAT_EXPECTED_PAYOFF), 2));
Print("Recovery factor: ", DoubleToString(TesterStatistics(STAT_RECOVERY_FACTOR), 3));
Print("Sharpe ratio: ", DoubleToString(TesterStatistics(STAT_SHARPE_RATIO), 3));
Print("");
Print("Max drawdown: ", DoubleToString(TesterStatistics(STAT_EQUITY_DD), 2),
" (", DoubleToString(TesterStatistics(STAT_EQUITY_DDREL_PERCENT), 2), "%)");
Print("");
Print("Total trades: ", (int)TesterStatistics(STAT_TRADES));
Print("Win rate: ", DoubleToString(TesterStatistics(STAT_PROFIT_TRADES) /
MathMax(1.0, TesterStatistics(STAT_TRADES)) * 100.0, 1), "%");
Print("Largest win: ", DoubleToString(TesterStatistics(STAT_LARGEST_PROFIT_TRADE), 2));
Print("Largest loss: ", DoubleToString(TesterStatistics(STAT_LARGEST_LOSS_TRADE), 2));
Print("Average bars held: ", DoubleToString(TesterStatistics(STAT_BARS_HOLD_TOTAL) /
MathMax(1.0, TesterStatistics(STAT_TRADES)), 1));
Print("===========================================");
Print("Sanity checks:");
Print(" - Fewer than ~100 trades? Treat every figure above as noise.");
Print(" - Profit factor under 1.2? Costs will likely erase it live.");
Print(" - Equity curve too smooth? Suspect a curve-fit.");
}