Guarda come scaricare robot di trading gratuitamente
Ci trovi su Facebook!
Unisciti alla nostra fan page
Script interessante?
Pubblica il link!
lasciare che altri lo valutino
Ti è piaciuto lo script? Provalo nel Terminale MetaTrader 5
Indicatori

Why Your Indicator Gives Different Values on Another Broker - indicatore per MetaTrader 5

Visualizzazioni:
134
Valutazioni:
(1)
Pubblicato:
Freelance MQL5 Hai bisogno di un robot o indicatore basato su questo codice? Ordinalo su Freelance Vai a Freelance

Why Your Indicator Gives Different Values on Another Broker

OVERVIEW

The same indicator on the same symbol and timeframe gives different values on two brokers, and the usual first guess is a bug in the code. Very often the code is fine and the history is different. An indicator can only be as good as the bars that it reads, and bar history is not the same everywhere: some brokers have holes in it, some have bars that were made up to fill the holes, and a few have bars with prices that cannot be real.

The indicator reads the bars that the terminal holds for the chart and looks for six defects. It does not request any other data, and it does not change anything:

  • HOLE. Bars are missing. The time between two bars is longer than one bar but not long enough to be a session break. The number of missing bars is the step divided by the bar length, minus one. Holes shorten moving averages, shift every value that depends on a count of bars, and change every pattern that uses "the previous bar".
  • BAD. The bar has impossible values: a price that is zero, negative or not a number, a high below the low, a high below the open or the close, a low above the open or the close (with a tolerance of half a point), or a time that is the same as or earlier than the time of the bar before it.
  • FILLER. A flat bar (high and low equal) that opens at the previous close and has no more than InpFillerTicks ticks. This is how tools that repair history often fill a hole. The bar is there, but no market was behind it.
  • REPEAT. All four prices are equal to the prices of the previous bar, and the bar is not flat. Two real bars are almost never identical, so this is usually a copy.
  • NOTICKS. The tick volume of the bar is 0. A real bar has at least one tick.
  • SPIKE. A wick (high above the body, or low below the body) longer than InpSpikeAtr times the ATR of the bars before it. Bad ticks in the feed leave exactly this kind of mark. A real news bar can look the same, so a spike is a suspect and not a proof.

A step in time longer than InpBreakMinutes (two hours by default) is called a session break, not a hole: weekends, holidays and the daily break of an index are not missing data. Breaks are counted separately and do not lower the score. Set the limit just above the longest break that is normal for your symbol.

The result is a score that is easy to compare between brokers: completeness (bars present divided by bars present plus bars missing in holes) multiplied by the clean share (bars without any defect divided by all bars analysed). A score of 99% or more is GOOD, below InpPoorScore it is POOR, and in between FAIR. Fewer than 100 bars give no verdict.

The calculation is incremental. On every call only the new bars and the bar that was still forming are judged, each bar is judged against the bar before it and never against a later bar, and all totals come from a table of running counts, so the history is never rescanned and nothing is sorted. The newest bar is judged while it forms, so its flags can change until it closes. A hole is decided once its bar exists and is counted exactly once.

How to interpret it

  • Histogram (indicator window). One bar per defective chart bar. The height is the number of defects in the bar, and the color is the most important of them, in this order: white HOLE, silver BAD, light gray FILLER, gray REPEAT, dark gray NOTICKS, darkest gray SPIKE. Clean bars have no histogram bar. A hole is drawn at the first bar after the gap, because the missing bars have no place on the chart.
  • Data Window. "Defects in bar" is the number of defects. "Clean bars, rolling (%)" is the share of clean bars in the last InpWindowBars bars, shown once a full window exists. "Missing bars before this bar" is the size of the hole in front of the bar. "Defect mask" adds up 1 for HOLE, 2 for BAD, 4 for FILLER, 8 for REPEAT, 16 for NOTICKS and 32 for SPIKE.
  • Panel (top left of the chart).
    • Line 1: symbol, timeframe, the number of bars analysed and the length of a session break.
    • Line 2: the verdict and the score with its two parts, completeness and clean bars.
    • Line 3: the same figures for the newest InpWindowBars bars, because old history is often worse than recent history.
    • Line 4: the number of holes (gaps), the number of bars missing in them and the number of session breaks.
    • Line 5: the number of bars with each of the other five defects. A check that is switched off shows "off".
    • Line 6: the three largest holes, with their size in bars and the time of the bar after the hole.
    • Line 7: the flags of the newest bar.
    • Line 8: one line with symbol, timeframe, bars, score, holes and the five counts, ready to be copied.


Fig. 1. The last 90 bars of an M5 chart with one bar of each defect: BAD (silver), HOLE of six bars (white), FILLER (light gray), REPEAT (gray), NOTICKS (dark gray) and SPIKE (darkest gray, with the long wick in the chart). The panel counts the whole analysed history, not only the visible bars. Black and white screenshot, per the Code Base image guidelines.

External variables (inputs)

Input Default Purpose
InpMinMissing 1 Fewest missing bars in a row that count as a hole (1-100). Raise it to ignore single missing bars.
InpBreakMinutes 120 A step in time longer than this is a session break, not a hole (1-10080 minutes). It is raised so that it is never shorter than a hole of InpMinMissing bars.
InpUseFiller true Look for filler bars.
InpFillerTicks 1 Most ticks that a flat bar may have to be called a filler bar (0-10).
InpUseRepeat true Look for bars identical to the previous bar.
InpUseZeroVolume true Look for bars without ticks. Switch it off for symbols whose history carries no tick volume.
InpUseSpike true Look for price spikes.
InpSpikeAtr 6.0 Wick length that counts as a spike, in ATR (2-50). It also limits the range that one bar adds to the ATR, so one spike does not hide the next one.
InpAtrPeriod 14 Period of the ATR used for the spike test (2-100). The first bars of the analysis are used to build the ATR and are not tested for spikes.
InpHistoryBars 50000 Newest bars analysed when the indicator loads or is fully recalculated. 0 analyses all bars. New bars are added as they arrive.
InpWindowBars 1000 Bars in the recent window of panel line 3 and in the rolling clean share (50-20000).
InpGoodScore 99.0 Score from which the history is called GOOD, in percent.
InpPoorScore 95.0 Score below which the history is called POOR, in percent. It is kept at or below InpGoodScore .
InpShowPanel true Show the statistics panel.
InpTextColor clrSilver Panel text color.
InpFontSize 8 Panel font size (Consolas). The line height follows the size.
InpPanelX , InpPanelY 8, 14 Panel offset from the upper left corner of the chart, in pixels.

Recommended use

  • Timeframes. Any intraday timeframe from M1 to H4. On D1 and longer a missing bar cannot be told from a closed market, and the indicator shows a message and draws nothing. Start on M1 when you can: higher timeframes are normally built from the M1 history, so a hole there usually comes from M1.
  • Comparing brokers. Put the indicator with the same inputs on the same symbol and timeframe on both terminals, and compare the report line of the panel. A score is only comparable under the same inputs, the same number of bars and the same session break limit. Compare symbols of the same kind, because an index with a daily break and a 24-hour currency pair do not have the same holes.
  • Set the break limit for the symbol. The default of 120 minutes suits most currency pairs. For an index or a stock CFD with a daily break, set InpBreakMinutes just above that break, or every break shows up as a hole. A small limit makes the check strict, a large limit makes it forgiving.
  • It counts what the terminal holds. Only the bars that have been downloaded are analysed. Holes can disappear after more history is loaded, and a short history gives few bars. Read the number of bars analysed in line 1 before you trust a score.
  • Suspects, not proofs. A spike can be a real news bar. Zero tick volume or a repeated bar can be normal on custom symbols and on very thin markets, especially on M1. A hole can be a real stop of trading, for example a holiday that is shorter than the break limit. The indicator tells you where to look. It cannot tell you what the correct history is.
  • A clean history is not a correct history. The checks look for defects that can be seen inside the bars. A broker whose prices are consistently a little different from another broker's has no defects by these tests.
  • Bar content. The indicator reads time, open, high, low, close and tick volume of the bars. It does not read ticks or spreads.
  • Performance and memory. Each bar is judged once, and later ticks only judge the newest bar and update the panel. The table of running counts takes about 36 bytes per bar, so 50,000 bars use about 2 MB.
  • Chart objects. The only objects are the panel lines in the main chart window, named with the prefix HH_ . They are removed in OnDeinit() .
  • Account types. The indicator does not trade and does not depend on netting or hedging accounts.
  • Your turn: post your score. Attach the indicator to a chart you trade, copy the last line of the panel and post it in the comments together with the name of your broker, for example EURUSD M5 | 50000 bars | score 99.31% | holes 3 | BAD 0 FILLER 0 REPEAT 1 NOTICKS 0 SPIKE 4 . If you have two brokers, post both lines. Tell me which defect surprised you, and which symbols you found with the worst history.
Indicator Doctor: Find Out Why Your MT5 Indicator Shows Nothing on the Chart Indicator Doctor: Find Out Why Your MT5 Indicator Shows Nothing on the Chart

finds out why an indicator shows nothing on the chart. It reads the buffers of every other indicator on the chart and gives each one a verdict: not calculated, all values empty, values only in the newest bars, all values zero, no values in the visible bars, or values outside the visible scale. A panel lists the problems first, gives one line of advice and prints a report line that can be pasted into a comment.

EzoO Trade Manager - break-even and trailing stop for open positions (manual or any EA) EzoO Trade Manager - break-even and trailing stop for open positions (manual or any EA)

Moves the stop loss of already open positions (manual or from any EA) to break-even and then trails it by points or ATR. Never opens or closes trades, only moves the SL in your favour.

Account Settings Sync - Bidirectional EA Settings Across Charts Account Settings Sync - Bidirectional EA Settings Across Charts

Small MQL5 library that shares an EA's own runtime settings between charts of the same account, with edits from either chart, a file lock and per-field merge.

Swing Level Breaks Graded by Volume Swing Level Breaks Graded by Volume

Draws support and resistance from confirmed swing points and keeps each level live, with its price on the chart, until a close breaks it. Every break is graded on the spot: an arrow when volume surges, a diamond when the candle shows a rejection wick, a hollow circle when price slipped through without either.