거래 로봇을 무료로 다운로드 하는 법을 시청해보세요
당사를 Facebook에서 찾아주십시오!
당사 팬 페이지에 가입하십시오
스크립트가 흥미로우신가요?
그렇다면 링크 to it -
하셔서 다른 이들이 평가할 수 있도록 해보세요
스크립트가 마음에 드시나요? MetaTrader 5 터미널에서 시도해보십시오
지표

Divergence Detector without repaint: RSI, MACD, Stochastic, CCI, Momentum - MetaTrader 5용 지표

Muhammad Muqeem Korejo
Muhammad Muqeem Korejo
Hi, I'm Muhammad Muqeem Korejo, an MQL4/MQL5 developer from Pakistan with 1.5 years of trading experience.
I build and fix trading tools for MetaTrader 4 and MetaTrader 5:
• Expert Advisors (EAs) built from your strategy rules
• Custom indicators, alerts and on-chart panels
조회수:
194
게시됨:
MQL5 프리랜스 이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동

A divergence happens when price makes a new high but the oscillator does not (or price makes a new low and the oscillator does not). Many divergence indicators look perfect on old charts and disappoint in real time, for two reasons: they draw the signal back on the swing although the swing was only known some bars later, and they delete or move signals when new bars come. This indicator is built so that what you see on an old chart is exactly what you would have seen in real time.

Divergence Detector on a EURUSD H1 chart: regular bullish divergences with RSI, lines on the oscillator and the price

What is drawn

  • The oscillator in its own window (RSI by default; MACD histogram or line, Stochastic %K, CCI or Momentum can be chosen).
  • A line between the two oscillator swings and, optionally, a line between the two price swings on the main chart. Regular divergences: solid lines. Hidden divergences: dotted lines.
  • An arrow on the bar where the divergence was confirmed, in the oscillator window and (optionally) on the price chart.

The four kinds

  • Regular bullish: price makes a lower low, the oscillator a higher low.
  • Regular bearish: price makes a higher high, the oscillator a lower high.
  • Hidden bullish: price makes a higher low, the oscillator a lower low (often seen in an uptrend).
  • Hidden bearish: price makes a lower high, the oscillator a higher high (often seen in a downtrend).

Regular divergences are on by default, hidden ones can be switched on.

No repaint

  • A swing counts only after 3 bars (an input) have closed after it. It never changes after that.
  • The arrow and the alert come on the bar where the second swing is confirmed, not back on the swing. That is the bar an Expert Advisor or an alert sees it.
  • Only closed bars are examined. A divergence, once shown, is never moved or deleted.

Checks against false divergences

  • Price swings and oscillator swings must both exist, at most 2 bars apart (an input). Values are not simply read from the oscillator at the price swing.
  • Neither price nor the oscillator may cross the straight line between the two swings.
  • The two swings must be 5 to 60 bars apart (inputs), and each new swing is compared with up to 5 earlier swings.
  • Optional zone filter for RSI and Stochastic: bearish divergences only above 50, bullish only below 50.
  • Price swings from highs and lows (wicks) or from closes.

For Expert Advisors (5 buffers)

0 the oscillator, 1 regular bullish, 2 regular bearish, 3 hidden bullish, 4 hidden bearish. Buffers 1 to 4 hold a value only on the bar where that divergence was confirmed. Read bar 1 (the last closed bar): if the buffer is not EMPTY_VALUE, a divergence was confirmed there.

When you call the indicator with iCustom, each "input group" counts as one parameter: pass a string for it, for example iCustom(_Symbol, _Period, "DivergenceNoRepaint", "Oscillator", 0, 14, 12, 26, 9, ...).

Inputs: oscillator and its periods, price source, bars to the left and to the right of a swing, minimum and maximum distance, alignment of the swings, earlier swings to compare, regular / hidden, zone filter, bars to calculate, lines and arrows on the price chart, two colours, alerts (pop-up and push).

How it was tested

  • An independent calculation in Python (own code) rebuilt all swings and divergences from the exported bars and the oscillator, for EURUSD H1 with RSI, XAUUSD M15 with the MACD histogram and GBPUSD M30 with Stochastic, regular and hidden divergences on: 98 signals, 0 differences. The RSI values were also checked against Wilder's formula: identical.
  • Repaint test: on every new bar, a test Expert Advisor saved all buffers of the bar that had just closed. At the end of the test the same bars were read again. 42,000 values compared, 0 changed.
  • Validator-style runs in the Strategy Tester: EURUSD H1, XAUUSD D1, GBPUSD M30 and EURUSD M1 (663,241 bars): no errors. Nothing is drawn in a Strategy Tester run without visualization, but all buffers are calculated.
  • The screenshot is a real EURUSD H1 chart of a demo account.

A divergence is a sign that a move is losing strength, not a trading system by itself. Use it together with your own levels, trend and risk rules.

Key Levels: PDH/PDL, weekly and monthly levels, midnight open, Asian range, sweeps Key Levels: PDH/PDL, weekly and monthly levels, midnight open, Asian range, sweeps

Previous day, week and month high and low, New York midnight open, period opens and the Asian range, with sweep marks and one alert per level. Day from broker or New York time. No repaint, buffers for EAs.

OrderGuard - restart-safe order sending for EAs (no duplicate trades) OrderGuard - restart-safe order sending for EAs (no duplicate trades)

An include file that makes the way an EA sends its orders safe: the same signal is never traded twice. It has no trading strategy inside and comes with a small example EA.

StrictJson: RFC 8259 JSON parser and writer for MQL5 StrictJson: RFC 8259 JSON parser and writer for MQL5

One include file that reads and writes JSON in MQL5 and MQL4. It refuses broken JSON and tells you the line and column of the mistake, keeps numbers exact, reads and writes UTF-8 files, and saves your EA's settings to a file and loads them back.

Currency Strength Free MT5 - Eight Currency Scanner Currency Strength Free MT5 - Eight Currency Scanner

Free MT5 dashboard comparing eight major-currency strengths and ranking up to 28 FX pairs from completed candles. Includes broker-prefix/suffix detection, synchronization checks, chart navigation and eight output buffers. Independent MIT-licensed source; no trading operations.