Last updated: 2017-Jul-04. Posted new V14 Update.
I get so much from this forum I want to give something back to it. I re-wrote a script called OrderHistory.mq4 that someone else created that goes through your trade history records and plots them on a chart window. You can graphically review the trades that you made and evaluate them for the quality of entries and exits.
Often it is said that traders regret when they let a profitable trade slip away, yet many also say they wish they would let their profits run longer. Sometimes we pull the buy or sell trigger too soon or too late, either upon entry or exit.
Just how often would you be helped or hurt by altering your strategy? With the ability to see your trades graphically, you can get a much better feel for how things might have turned out if you did.
While the original script was a good start, I added trendlines to mark each trades entry and exit. I improved the placement of texts for readability, and tweaked around with all the code to add features which I think will be well appreciated. Even so, I've described a long enhancement list for more ideas that anyone could help implement if you would like. Actually, I'm a hacker, not a professional programmer but I think this is pretty well documented and it works pretty well. Still, if you find any bugs, please report them, and if you have a suggested fix, even better!
Attached is the script, and I will post an example of a chart. Open the script in MetaEditor to review the instructions, options, and features.
With appreciation for all the forum contributors,
Individually, we only know a little. Collectively, what we know is mind boggling!
NEW Comments (2010-Jan-11):
Two-and-a-half years later, I have a lot more programming experience with MT4 and I decided to update the old version in a big way.
A major new version is available: "P4L OrderHistory.mq4" (V4).
The new features are listed below, but read a full description inside the script.
This is a script, not an indicator! Therefore, install it under:
As a script, it runs only once, but can be added over-and-over, each time with different user variable settings.
This script will display on a chart your open trades, and/or closed trades that are within the Custom Period range you choose in the Terminal->AccountHistory tab!
In addition, you can export/import trade history data to combine history from multiple brokers!
2007-09-13: First version "OrderHistory V2.mq4" released. (Downloaded 1045 times before next version update).
(Deleted from Post #1 due to major new version replacement).
2010-01-11: New "P4L OrderHistory.mq4" (V3) released.
* Renamed from "OrderHistory V2.mq4" to "P4L OrderHistory.mq4"
* Input variables now changeable by popup when added to chart
* Trade History can be OUTPUT and/or INPUT from CSV files!
* Easily read by Excel for external analysis
* History from multiple brokers can be combined onto one MT4
* DisplayText now "false" by default to reduce clutter (easily changed)
* More information reported about the trade.
* Extra-digit brokers supported! Pips automatically adjusted by 1/10th.
* Trade-time (from Open->Close) calculated and displayed.
* Objects easily deleted from chart.
* Colors slightly modified to work on Black OR White backgrounds.
* SLIPPAGE is calculated and noted if >= 1 pip tolerance. (SLslip is negative-slip; TPadd is positive-slip).
* New StartDate and EndDate to specify a date range (Useful when importing data from other brokers)
* Alert messages added, plus many other changes to improve useability
2010-01-11: New "P4L OrderHistory.mq4" (V4) released. (Downloaded 348 times before next version update).
(I thought support for Open trades would take longer...)
* Added support for Open (active) trades. Show_ClosedOpenAll_Trades_123 = 3 (default,All trades)
* Added "closed", "demo", and 4 placeholder columns to the database format
* Demo trades are marked with a prefix "*" in profit string (e.g. "*Net:$ xx.xx")
* Fixed bug to exit when output file = input file (infinite loop)
2010-08-23: New "P4L OrderHistory.mq4" (V5) released. (Downloaded 1022 times before next version update).
* The input/output file format (column order) was changed but files created by previous versions ARE still compatible as input files. The benefit is that standard MT4 Statements (reports) can be read into Excel, then converted and written out as a tab-delimited file (with 14 data columns) and used as an input file. (Detailed instructions).
* Added variables Input_File_Delimiter and OUTPUT_File_Delimiter with default of "Tab". (Comma or Semicolon or other specific characters can be specified).
* Added "DrawMostObjectsAsBackground" (true). Normal use-model assumes F8 "Chart on Foreground" is OFF but user can experiment and can change this variable to "false" if desired.
* To suppress trades from AccountHistory and just show those from input file(s), the user can specify input as "ONLY filename1 ...". Alternatively, the user can change new variable "IncludeTradesFromAccountHistory" to "false".
* This version calls a private-author library routine that can read the trades taken by any EA in the StrategyTester and convert the format into a standard input-file format to display the EA-simulated trades on a chart. This library file has not been provided for free/public use, but the missing library file is ignored when using standard input files.
2011-05-18: New "P4L OrderHistory.mq4" (V6) released. (Downloaded 951 times before next version update).
* Fixes a problem with split orders. Either MT4 changed, or perhaps only certain brokers have this new problem. When an order is split by closing only a portion of the original order, the buy/sell arrows and trendlines for each part of the split should still originate from the same open-time & price of the original order. This version fixes a problem where the time of the split was used instead of the original OpenOrderTime.
2011-11-04: New "P4L OrderHistory.mq4" (V7) released. (Downloaded 5848 times before next version update).
* Fixed a bug (reported by MauriceW) with Output columns that incorrectly reported "pips" for some of the currency pairs (It was related to 2-digit vs. 4-digit pairs). The wrong values were off by x100.
* The StartDate and EndDate variables were renamed to "Start_Date_OR_Number_of_weeks" and "End_Date_OR_Number_of_weeks". The default is to display (and/or output) the most recent 8 weeks of trades. Change the Start_Date... to "0" to get ALL trade history, or enter specific date(s) of interest.
* New variable "Make_Dollars_and_LotSize_SECRET" (false) can be set to True if the user wants to keep the Dollar amounts and LotSize secret. Profitable trades simply show a profit of "1.00", and unprofitable trades show "-1.00". "Break-even" trades show a profit of either 0.01 or -0.01. The LotSize is set to "1.0" for every trade. This affects all the created objects, AND it affects the values in the Output file. The benefit of this option is to allow a user to share the Output file (or possibly a Template file with the objects) with another person that shows the trades taken but gives no private details with respect to the profit/loss or the size of the trades. FYI, Swap and Commissions are also set to zero, since these indirectly indicate the LotSize. (NOTE: The User must VERIFY the Output file content to insure that private details are not inadvertantly left in the file! Especially check the Comments column. Open a blank Excel worksheet and import the Output file to inspect the details.)
* New variable "OUTPUT_SuppressBlankSymbolLines" (false) can be set to True if the user wants to suppress from the OUTPUT file all transactions which have a blank symbol name. These include account deposits, withdrawals, transfers, adjustments, commissions charged after-the-trade, etc. (FYI, this variable is auto-forced to True if Make_Dollars_and_LotSize_SECRET=True).
2014-Jul-04: New "P4L OrderHistory.mq4" (V9) released. (Downloaded 5146 times before next version update).
* Minor updates due to new "MQL45" (MT4 build>=600)
2016-Mar-29: New "P4L OrderHistory.mq4" (V12) released. (Downloaded 1806 times before next version update).
- Fixed significant bug related to use of Input Files. Mixed-case symbol names are now supported (e.g. "EURUSDc", "EURUSDpro", etc.)
- New "DEBUG_inputfiles" (false) option. Set to "true" to help a little when input files don't work as expected.
- Default input/output delimiter is now "Comma", for ease of directly opening it with MS Excel.
- Auto-force-mapping of any output-delimiter-string occurring in the "Comments" field to be a literal "." instead.
- NOTE: OLDER files with "Tab" delimiter work fine, but be sure to specify the input delimiter accordingly.
- A few more updates due to new "MQL45" (MT4 build>=600), including filename path corrections to /.../MQL4/Files/in_out_name
- Renamed an option to: Make_Dollars_LotSize_Etc_SECRET (false).
- New minor options: Comments_Are_Considered_SECRET (false). If you want "SECRET" to suppress the trade comment field, make this true.
- OrderTicket_nums_Are_Considered_SECRET (false). (Use "true" to replace with a simple counter; also, any comment with "#" (usually followed by an OrderTicket number) is suppressed without forcing all other comments to be suppressed).
- The AccountNumber field is forced to "1234" when using SECRET.
- Note: The purpose of the "SECRET" options is to encourage traders to SHARE their trade history (symbol, entry, exit) without having to disclose private trade details like size/$/acct#. (DOUBLE-CHECK the output file to ensure that private details have been removed before you share the output; report any details I may have missed that you expect should have been kept SECRET but weren't).
2016-Oct-08: New "P4L OrderHistory.mq4" (V13) released. (Downloaded 2572 times before next version update).
- Per request, new option LimitToMagicNumber_GtEq_0 (default -1, not_limited). Specify a number >=0 if you want to restrict matching trades to the specific magic number. (Note: This new feature has not been rigorously tested but ought to work. Report any problems.)
- New option StartByRemovingPreviousObjects (true). Set to "false" if you intend to add to existing matches. It is most useful if you desire to see >=2 magic numbers displayed on the chart, because otherwise the usual default would be to remove the previous matches.
2017-Jul-04: New "P4L OrderHistory.mq4" (V14) released.
- Per request for a way to suppress cancelled orders from display and/or the output, there are two new options:
DONT_DisplayCancelledOrders (false), and
OUTPUT_SuppressCancelledOrders (false). Change 1-or-both to "true" to suppress cancelled orders.
- Changed default for Start_Date_OR_Number_of_weeks="ALL" (ALL *visibile* Account_History. Previous default was 8 weeks).
- New variable, TextAnchor = "Upper" (aka CenterUpper), same as old default. Now user has control over which anchor
to use for the TextLabels, and "UL" or "UR" might be easier-to-read alternatives, since the text edge will better line up with the trade itself.
- New variables for user control over the Line Style/Width. Same settings as before:
ProfitLineStyle = STYLE_SOLID; //SOLID=0//
ProfitLineWidth = 3; // ANY non-SOLID style choice *MUST* use Width=1. This MT4 rule is enforced in start().
LossLineStyle = STYLE_DASH; // MOST likely choice to change, to "STYLE_SOLID" (0)
LossLineWidth = 1; // If above changed to STYLE_SOLID, then likely use "3" also, or maybe "4" for Profit line.
CancelledLineStyle = STYLE_SOLID;
CancelledLineWidth = 1;
Note: The Loss lines, if STYLE_DASH, are harder to see, but currently, all SOLID lines indicate Profit-or-BE. It's your choice to customize or not.
- Fixed potential bug when using an INPUT file, that if the Symbol() name differed only by case but not spelling, it would not display trades. However, usually when an INPUT file (from another broker) is used, the user should manually edit the symbol names to match the current broker, editing case/prefix/suffix so the INPUT file matches your current broker. (Examples: EURUSD, EURUSDpro, EurUsd, EURUSDc, xEURUSD. Make the input file consistent with the broker you intend to display trades on)
P.S. Until I get around to modifying my own versions (which given time constraints, maybe never or quite a long time later), then...
My script was adapted and made into an indicator here. (Thanks robots4me)
Both the script and indicator versions were converted to MT4 here. (Thanks getch)
(Check the thread history to see if any further updates or adaptations have been posted by others).
FYI, the latest version will always be posted here in post #1:
FYI, see also: Collection of programs by pips4life