Author: Copyright � 2006, Alex Sidd (Executer)
ExAccount

This script is designed to act as a visual reporting tool for traders who conduct backtesting on the MetaTrader 4 platform. Its primary purpose is to take the raw data generated by the strategy tester and convert it into a visual map on your trading chart, making it much easier to see where and why specific trades were executed.

How the Logic Works

1. Data Retrieval The script begins by looking for a specific report file named StrategyTester.htm. This is the standard HTML file that MetaTrader creates to summarize the results of a backtest. If the script cannot find this file, it will alert you with a notification.

2. Information Parsing Once it accesses the report, the script "reads" through the text line by line. It specifically scans for key trading actions such as:

  • Buy orders
  • Sell orders
  • Close positions
  • Stop Loss (s/l)
  • Take Profit (t/p)
  • Modifications

For every action it finds, it extracts three critical pieces of information: the exact date and time the trade occurred, the type of action performed, and the unique order number.

3. Chart Mapping After identifying a trade event in the report, the script searches your current chart to find the specific price candle that matches that date and time. Once it finds the correct spot, it places a visual marker (an arrow or symbol) directly on the chart:

  • Buy orders appear as Blue Up-Arrows.
  • Sell orders appear as Red Down-Arrows.
  • Close positions appear as Black Stop Signs.
  • Take Profit/Stop Loss and other modifications are marked with specific symbols and colors (like Green for profit or Red for stop limits) to help you distinguish between different types of price targets.

Summary of Benefit

Instead of having to manually scroll through a long, text-heavy HTML report to understand your strategy's performance, this script automatically "paints" those results onto your chart. It allows you to see the lifecycle of your trades—from entry to exit and every adjustment in between—visually aligned with the price action.

Miscellaneous
Uses files from the file systemIt opens Message Boxes to the userIt reads information from a file
12 Views
0 Downloads
0 Favorites
ExAccount
//+------------------------------------------------------------------+
//|                                                    ExAccount.mq4 |
//|                           Copyright © 2006, Alex Sidd (Executer) |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Alex Sidd (Executer)"
#property link      "mailto:work_st@mail.ru"
#property show_inputs
//----
#include <WinUser32.mqh>
//+------------------------------------------------------------------+
//| Executer Account Script                                          |
//+------------------------------------------------------------------+
int start()
  {
   int i, j = 0, counted_bars = IndicatorCounted();
   i = Bars - 1;
   string m_buf, m_data, m_type, m_order;
   datetime tim;
   int handle, m_find, count = 0;
   handle = FileOpen("StrategyTester.htm", FILE_READ, ';');
   if(handle < 1)
     {
       MessageBox("File StrategyTester.htm not found", "Script", MB_OK);
       return(false);
     }
   while(FileIsEnding(handle)!=true)
     { 
       m_buf = FileReadString(handle, 0);
       m_find = StringFind(m_buf, "<td class=msdate>", 0);
       if(m_find != -1)
         { 
           m_data = StringSubstr(m_buf, m_find + 17, 16);
           if(StringFind(m_buf, "buy", 0) != -1) 
             {
               m_type = "buy";
               m_find = StringFind(m_buf, "buy</td><td>", 0);
               if(m_find != -1)
                 {  
                   count = StringFind(m_buf, "<", m_find + 12);
                   m_order = StringSubstr(m_buf, m_find + 12, count - m_find - 12);
                 }
             }
           if(StringFind(m_buf, "sell", 0) != -1) 
             {
               m_type = "sell";
               m_find = StringFind(m_buf, "sell</td><td>", 0);
               if(m_find != -1)
                 {  
                   count = StringFind(m_buf, "<", m_find + 13);
                   m_order = StringSubstr(m_buf, m_find + 13, count - m_find - 13);
                 }
             }
           if(StringFind(m_buf, "close", 0) != -1) 
             {
               m_type = "close";
               m_find = StringFind(m_buf, "close</td><td>", 0);
               if(m_find != -1)
                 {  
                   count = StringFind(m_buf, "<", m_find + 14);
                   m_order = StringSubstr(m_buf, m_find + 14, count - m_find - 14);
                 }
             }
           if(StringFind(m_buf, "modify", 0) != -1)
             { 
               m_type = "modify";
               m_find = StringFind(m_buf, "modify</td><td>", 0);
               if(m_find != -1)
                 {  
                   count = StringFind(m_buf, "<", m_find + 15);
                   m_order = StringSubstr(m_buf, m_find + 15, count - m_find - 15);
                 }
             }
           if(StringFind(m_buf, "s/l", 0) != -1) 
             {
               m_type = "s/l";
               m_find = StringFind(m_buf, "s/l</td><td>", 0);
               if(m_find != -1)
                 {  
                   count = StringFind(m_buf, "<", m_find + 12);
                   m_order = StringSubstr(m_buf, m_find + 12, count - m_find - 12);
                 }
             }
           if(StringFind(m_buf, "t/p", 0) != -1) 
             {
               m_type = "t/p";
               m_find = StringFind(m_buf, "t/p</td><td>", 0);
               if(m_find != -1)
                 {  
                    count = StringFind(m_buf, "<", m_find + 12);
                    m_order = StringSubstr(m_buf, m_find + 12, count - m_find - 12);
                 }
             }
           if(StringFind(m_buf, "close at stop", 0) != -1) 
             {
               m_type = "close at stop";
               m_find = StringFind(m_buf, "close at stop</td><td>", 0);
               if(m_find != -1)
                 {  
                   count = StringFind(m_buf, "<", m_find + 22);
                   m_order = StringSubstr(m_buf, m_find + 22, count - m_find - 22);
                 }
             }
           //-----------
           tim = StrToTime(m_data);
           //  if(tim>Time[i]&&tim<Time[i-1]) tim = 
           i = Bars - 1;
           while(i >= 0)
             {
               if(tim >= Time[i] && tim < Time[i-1])
                 {
                   if(m_type == "sell")
                     {
                       ObjectCreate("Sell" + m_order, OBJ_ARROW, 0, tim, High[i] + 20*Point);
                       ObjectSet("Sell" + m_order, OBJPROP_ARROWCODE, SYMBOL_ARROWDOWN);
                       ObjectSet("Sell" + m_order, OBJPROP_COLOR, Red);
                     }
                   if(m_type == "buy")
                     {
                       ObjectCreate("Buy" + m_order, OBJ_ARROW, 0, tim, Low[i] - 20*Point);
                       ObjectSet("Buy" + m_order, OBJPROP_ARROWCODE, SYMBOL_ARROWUP);
                       ObjectSet("Buy" + m_order, OBJPROP_COLOR, Blue);

                     }
                   if(m_type == "close")
                     {
                       ObjectCreate("Close" + m_order, OBJ_ARROW, 0, tim, High[i] + 10*Point);
                       ObjectSet("Close" + m_order, OBJPROP_ARROWCODE, SYMBOL_STOPSIGN);
                       ObjectSet("Close" + m_order, OBJPROP_COLOR, Black);

                     }
                   if(m_type == "s/l")
                     {
                       ObjectCreate("Stop Limit" + m_order, OBJ_ARROW, 0, tim, High[i] + 
                                    15*Point);
                       ObjectSet("Stop Limit" + m_order, OBJPROP_ARROWCODE, SYMBOL_CHECKSIGN);
                       ObjectSet("Stop Limit" + m_order, OBJPROP_COLOR, Red);

                     }
                   if(m_type == "t/p")
                     {
                       ObjectCreate("Take Profit" + m_order, OBJ_ARROW, 0, tim, High[i] + 
                                    15*Point);
                       ObjectSet("Take Profit" + m_order, OBJPROP_ARROWCODE, SYMBOL_CHECKSIGN);
                       ObjectSet("Take Profit" + m_order, OBJPROP_COLOR, Green);
                     }
                   if(m_type == "modify")
                     {
                       ObjectCreate("Modify" + m_order, OBJ_ARROW, 0, tim, High[i] + 5*Point);
                       ObjectSet("Modify" + m_order, OBJPROP_ARROWCODE, 4);
                       ObjectSet("Modify" + m_order, OBJPROP_COLOR, Blue);
                     }
                   break;
                 }
               i--;  
             }
           //-----------
         }
       //   MessageBox(m_data+" "+m_type+" "+m_order,"Script",MB_OK);
       j++;
     }
   FileClose(handle);
   return(0);
  }
//+------------------------------------------------------------------+

Comments