Loading…

Revenge Trading Pattern Finder

Revenge trading is easy to recognise afterwards and easy to deny in the moment. This script defines it precisely enough to check for automatically: a trade opened within a chosen number of minutes of a loss closing, sized larger than that loss was, and totals the net result of every trade that matches. The timing is measured from the loss's CLOSE time to the next trade's OPEN time, not between two open times or two close times. Revenge trading is a reaction to a loss actually landing on the account - a trade that was already running when the earlier loss closed was not opened because of it, and comparing open times to open times would flag exactly that case by mistake. History is sorted by open time before the scan runs, because MT4's own history pool is ordered by close time. A short losing scalp can close after a longer position that was opened earlier in the day and is still running, and scanning in close-time order would put trades next to each other in an order the trader never actually experienced. Sorting by open time first fixes that before the adjacent-pair comparison begins. Only the trade immediately following a loss is compared against it - this finds the reaction to a specific loss, not every trade that happens to follow a losing stretch somewhere earlier in the file. Notes and limitations - Market trades only. Balance operations and pending orders are excluded from the comparison entirely. - Only the single trade immediately after a loss is tested against it. A losing streak of several trades in a row, each followed only after the window has passed, produces no flags - the pattern this script looks for is specifically the fast, larger reaction, not every trade after a bad day. - A trade that opened before the prior loss actually closed is never flagged, even if the two overlap heavily in time, because it cannot have been opened in reaction to a loss that had not landed yet. - Only what MT4's Account History tab has loaded is scanned. Choose "All History" first if a known instance is missing from the report. - The combined net result includes every flagged trade's own outcome, win or loss - a flagged trade that happened to win is still counted, because the pattern being measured is the behaviour, not whether it worked this time.

Script · MT4 · v1.0 · Free

About Revenge Trading Pattern Finder

Revenge Trading Pattern Finder is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 6 settings, such as From date, To date and Max minutes after loss. MQL source code included.

Files in the download: RevengeTradingPatternFinder.ex4, RevengeTradingPatternFinder.mq4, RevengeTradingPatternFinder.txt.

Settings

SettingDefaultWhat it does
From date0From close time (1970.01.01 = no lower bound)
To date0To close time (1970.01.01 = up to now)
Max minutes after loss30Flag only trades opened within this many minutes of the loss closing
Min size increase percent0.0Minimum lot size increase vs the loss to count (0 = any increase)
Same symbol onlyfalseOnly compare trades on the same symbol
DelimiterDelimiterCommaCSV column separator

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the script onto a chart to run it once.

Download the PDF guide

Tags: Alerts · MT4 Script · MQL4 Source Code

MQL4 & MQL5 scripts · PolyMaria