Detrended Price Oscillator

Detrended Price Oscillator (MetaTrader indicator) — a version of the price oscillator based on the difference between the current price and the simple moving average shifted by (Period / 2) + 1 bars. Unlike the stochastic oscillator, this indicator aims to show the short-term trend changes (price waves inside the long-term trend). The indicator is displayed in the separate window of the chart. You can use this Detrended Price Oscillator (DPO) indicator in both MT4 and MT5 versions of the platform.

The formula to calculate the detrended price oscillator at the bar i is the following:

where:

The present implementation of the DPO can also issue alerts on a cross of the zero level. It supports native alerts, email alerts, and push-notifications.

Interpretation

From the mathematical point of view, the current DPO value is the difference between the current Close value and the average of the Close values over n bars ½n + 1 bars ago. Therefore, when the DPO is at the zero level, it means that the current Close value is the same as the average of the Close values over n bars ½n + 1 bars ago. This implies that the price returned to some previously visited range. If the zero line is crossed by the DPO from above, it means that the price declined to reach that range, whereas if zero line is crossed by the DPO from below, it means that the price rose to reach the earlier range.

Considering the above, the divergence between the DPO and the price chart can be interpreted as following:

  • A higher high followed by a new higher high on the price chart with the DPO printing a higher high followed by a lower high — the price failing to surpass the earlier average by the same amount as it did on the previous higher high — i.e., the uptrend was steeper during the period ½n + 1 bars ago.
  • A lower low followed by a new lower low on the price chart with the DPO printing a lower low followed by a higher low — the price failing to go down below the earlier average by the same amount as it did during the previous lower low — i.e., the downtrend was steeper during the period ½n + 1 bars ago.
  • A higher high followed by a lower high on the price chart with the DPO printing a higher high followed by another higher high — the price trend is reversing to the downside but still surpassing the earlier average by the same or greater amount as it did on the previous higher high — i.e., the uptrend was weaker during the period ½n + 1 bars ago.
  • A lower low followed by a higher low on the price chart with the DPO printing a lower low followed by another lower low — the price trend is reversing to the upside but still going below the earlier average by the same amount as it did during the previous lower low — i.e., the downtrend was weaker during the period ½n + 1 bars ago.

Evidently, these notions alone do not constitute any particular trading signals, but they provide testable patterns for analysis or use with confirmation signals.

Input parameters

  • MA_Period (default = 14) — the period of the simple moving average used in the indicator.
  • BarsToCount (default = 400) — for how many bars to calculate the indicator.
  • EnableNativeAlerts (default = false) — if true, indicator will use MetaTrader's native pop-up alerts.
  • EnableEmailAlerts (default = false) — if true, indicator will use MetaTrader's email alerts. Email should be properly configured in MetaTrader via Tools->Options->Email.
  • EnablePushAlerts (default = false) — if true, indicator will use MetaTrader's push notification alerts. Notifications should be properly configured in MetaTrader via Tools->Options->Notifications.
  • TriggerCandle (default = Previous) — the candle to issue alerts on: Previous — the most recently closed candle or Current — the yet unfinished candle.

Strategy

Trend changes are signaled by the cross of the indicator and the zero level. However, because the indicator is lagging, predicting such crosses can be a better technique. It is not quite a very accurate indicator for direct trading purposes, but it still can be used for short-term trend confirmation.

Another possibility with the Detrended Price Oscillator is to use detect divergences with the price chart. As you can see on the chart below, the major trend reversal could be spotted by comparing the double top demonstrated by the price and the lower high on the DPO chart.

Detrended Price Oscillator Indicator - Example MetaTrader Chart

Downloads (ver. 1.01, 2022-09-24)

Detrended Price Oscillator for MetaTrader 4 in .zip

Detrended Price Oscillator for MetaTrader 4 in .mq4

Detrended Price Oscillator for MetaTrader 5 in .zip

Detrended Price Oscillator for MetaTrader 5 in .mq5

Discussion

Warning! If you do not know how to install this indicator, please read the MetaTrader Indicators Tutorial.

Do you have any suggestions or questions regarding this indicator? You can always discuss Detrended Price Oscillator with the other traders and MQL programmers on the indicators forums.

Changelog

1.01 - 2022-09-24

  • Added alerts.
  • Added zero level marking.
  • Refactored the source code.

1.00 - 2010-11-29

  • Initial release of the Detrended Price Oscillator.

© 2005–2023

EarnForex.com

Design — Mart Studio

Forex trading bears intrinsic risks of loss. You must understand that Forex trading, while potentially profitable, can make you lose your money. Never trade with the money that you cannot afford to lose! Trading with leverage can wipe your account even faster.

CFDs are leveraged products and as such loses may be more than the initial invested capital. Trading in CFDs carry a high level of risk thus may not be appropriate for all investors.