Adjusted Trade History for Splits and Dividends Price Adjusted Chart.

 

In Metatrader 5, by activating the trade history in chart menu, the information of the past buy and sale trades are displayed on the chart. it is a very simple and useful option which helps to have a better understanding of the trade performance. However, it is a little bit inconvenient when price adjusted chart is used, just because, the trade history data are not located on the price adjusted line.

Actually, I have no idea whether this is the broker responsibility to adjust the trades historical data when are applied on an adjusted price chart or there is an option or any workaround to do it manually in mt5.

any idea?

 

Well it looks this is something probably no one needed in MT5 or perhaps there is another way that actually fulfills this.

I made an excel file and collected all my trade histories from different brokers. Then, I modified the data base of splits and dividends information for each instrument. I exported them to a CSV file with this arrangement: 

Date, Price, Volume, Fill Rate, Order Type

The Date format is  "YYYY.MM.DD HH:MI:SS" and I considered a default value of 100 percent (1 in the excel cell) for fill rate if it was not avaiable. OrderType is "Buy" or "Sell". As a sample, the first line of a csv file looks something as below:

         2020.08.01 12:38:57,220.0,200.0,1.0,Sell  

The file name is the SYMBOL_ISIN of the instrument. Say  xxxzzz0001.csv . it must be copy in the "Files" folder of MT5. (.\MQL5\Files)

this is the code:

    //+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   ObjectsDeleteAll(0,0,OBJ_ARROW_BUY);
   ObjectsDeleteAll(0,0,OBJ_ARROW_SELL);


   fileHandle = FileOpen(SymbolInfoString(Symbol(),SYMBOL_ISIN)+".csv",FILE_READ|FILE_CSV|FILE_ANSI,",",CP_ACP);
   int i=0;
   if(fileHandle!=INVALID_HANDLE)
     {
      while(FileIsEnding(fileHandle) == false)
        {


         ArrayResize(tradeHistory,ArraySize(tradeHistory) +1);
         tradeHistory[i].date = FileReadDatetime(fileHandle);
         tradeHistory[i].price = FileReadNumber(fileHandle);
         tradeHistory[i].volume = FileReadNumber(fileHandle);
         tradeHistory[i].fillRate = FileReadNumber(fileHandle);
         tradeHistory[i].type = FileReadString(fileHandle);

         i++;
        }
     }
   
   for(i=0; i< ArraySize(tradeHistory); i++)
     {
      if(tradeHistory[i].type=="Buy")
        {
         ObjectCreate(0,"Arrow"+i,OBJ_ARROW_BUY,0,tradeHistory[i].date,tradeHistory[i].price);
         ObjectSetString(0,"Arrow"+i,OBJPROP_TOOLTIP,
                         "Buy:"+tradeHistory[i].volume+" @"+tradeHistory[i].price+" On "+tradeHistory[i].date);
        }
      else
        {
         ObjectCreate(0,"Arrow"+i,OBJ_ARROW_SELL,0,tradeHistory[i].date,tradeHistory[i].price);
         ObjectSetString(0,"Arrow"+i,OBJPROP_TOOLTIP,
                         "Sell:"+tradeHistory[i].volume+" @"+tradeHistory[i].price+" On "+tradeHistory[i].date);

        }
     }
   
   FileClose(fileHandle);
   Comment(SymbolInfoString(Symbol(),SYMBOL_ISIN));

//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
//Do Nothing
//---
   return(rates_total);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnDeinit()
  {
   ObjectsDeleteAll(0,0,OBJ_ARROW_BUY);
   ObjectsDeleteAll(0,0,OBJ_ARROW_SELL);
  }
//+------------------------------------------------------------------+