calculateLots

Download script
Author: flourishing
calculateLots

This script is a specialized calculation tool designed for traders who need to audit their trading volume over a specific period. Its primary purpose is to automatically sum up the total number of "lots" traded between two chosen dates, providing a clear snapshot of historical activity.

How it Works

The logic follows a straightforward three-step process to gather and display your trading data:

1. Setting the Timeframe Before running the script, you define a specific starting point and an ending point in time. This allows you to isolate a particular month, a specific trading season, or any custom date range relevant to your analysis.

2. Historical Data Review Once activated, the script scans through your entire account's history. It looks at every completed trade and checks if the opening time of that trade falls within the boundaries you set in step one. If a trade was opened outside of those dates, the script ignores it; if it was opened inside, it proceeds to the next step.

3. Summation and Reporting The script identifies the "Lot" size for every valid trade found during its scan. It adds these values together into a grand total. Once the calculation is complete, it displays a clear notification on your screen showing the exact start and end dates used, followed by the final sum of all lots traded during that window.

Key Benefits

  • Accuracy: By automating the addition process, it eliminates the risk of human error when manually totaling large volumes of trades.
  • Customization: It gives you the flexibility to analyze any arbitrary period rather than being restricted to fixed monthly or yearly reports.
  • Simplicity: It provides a direct answer to the question "How much volume did I trade during this specific time?" without requiring any complex manual calculations.
Orders Execution
Checks for the total of closed orders
Miscellaneous
It opens Message Boxes to the user
8 Views
0 Downloads
0 Favorites
calculateLots
//+------------------------------------------------------------------+
//|                                                calculateLots.mq4 |
//|                                                      flourishing |
//|                                    http://www.tradesignal.com.cn |
//+------------------------------------------------------------------+
#property copyright "flourishing"
#property link      "http://www.tradesignal.com.cn"
#include <WinUser32.mqh>

#property show_inputs
//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
extern  string starttime = "2009.1.1 00:00";
extern string  endtime = "2009.2.30 00:00";

int start()
  {
//----
   double totallots;
   int i ,cnt;
   cnt = OrdersHistoryTotal();
   for(i =0;i<cnt;i++)
     if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))
       if( OrderOpenTime()>StrToTime(starttime) && OrderOpenTime()<StrToTime(endtime))
         totallots = OrderLots()+totallots;
         
   MessageBox("From "+starttime+" To "+endtime+" \n\nTotal Lots: "+DoubleToStr(totallots,2)+ " Lots");
         
         
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments