Loading…

Same Bar Churn Detector

A trade opened and closed within the same bar was never given the timeframe's setup time to play out - at best it is a scalp that worked, at worst it is spread and commission paid for no real edge expressed. This script walks closed order history, uses iBarShift on a chosen timeframe to test whether each trade's open and close time fall on the same bar, and reports per symbol how many trades did, what fraction of that symbol's total that represents, and the cumulative net result of just the same-bar trades. "Same bar" is deliberately checked against the chosen timeframe rather than a fixed time gap: two trades five minutes apart are the same bar on H1 but different bars on M1, and that difference is the entire point of making the timeframe a user input rather than baking in an assumption. A trade whose window falls outside locally available history on that timeframe is counted separately as unresolved, never guessed at either way. A symbol whose same-bar count reaches InpChurnAlertCount is flagged explicitly in the log, making it easy to scan a long report for the pattern worth acting on rather than reading every row by eye. Notes and limitations Requires local history on the chosen timeframe for every symbol being measured; trades whose window falls outside that coverage are reported as unresolved and excluded from both the same-bar and total counts for that symbol. A same-bar trade is not automatically a mistake - a genuine scalping strategy is expected to show up here - the report is a measurement, not a verdict, and the net-result line is what actually says whether the pattern is worth keeping.

Script · MT4 · v1.0 · Free

About Same Bar Churn Detector

Same Bar Churn Detector 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 Bar timeframe, Symbol filter and Magic filter. MQL source code included.

Files in the download: SameBarChurnDetector.mq4, SameBarChurnDetector.txt.

Settings

SettingDefaultWhat it does
Bar timeframePERIOD_M15Timeframe whose bars define "same bar"
Symbol filterSymbol filter ("" = every symbol)
Magic filter-1Magic number filter (-1 = every magic)
From date0Earliest open time (0 = all loaded history)
To date0Latest open time (0 = up to now)
Churn alert count5Same-bar trade count that triggers the churn alert

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: Scalping · Alerts · MT4 Script · MQL4 Source Code

MQL4 & MQL5 scripts · PolyMaria