Discussing the article: "How to build and optimize a cycle-based trading system (Detrended Price Oscillator - DPO)"
This is very interesting, but I have some difficulties correlating the theory with the code. If my understanding was correct, in order to calculate the SMA to be used for the current bar, one should shift back the considered period by N/2 + 1 bars, and then calculate the SMA using N bars back from there. I'm just a novice, so I don't pretend to have a good understanding of the indicator code, but from what I've been able to decipher, it looks to me like N is only used to set the name, but not in calculations, as the SMA period, and instead N/2 + 1 (maPeriod in code) is used as the SMA period, but not to perform any shifting. Forgive me if I got it all wrong, but please point to me where I'm not correct, so I can understand it better.

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Check out the new article: How to build and optimize a cycle-based trading system (Detrended Price Oscillator - DPO).
This article explains how to design and optimise a trading system using the Detrended Price Oscillator (DPO) in MQL5. It outlines the indicator's core logic, demonstrating how it identifies short-term cycles by filtering out long-term trends. Through a series of step-by-step examples and simple strategies, readers will learn how to code it, define entry and exit signals, and conduct backtesting. Finally, the article presents practical optimization methods to enhance performance and adapt the system to changing market conditions.
The Detrended Price Oscillator (DPO) is a tool that can be used to highlight price cycles. This is done through filtering out long-term trends. It focuses on short-term price cycles. The identification of overbought or oversold conditions and the location of turning points is possible with the use of this indicator.
The (DPO) indicator compares the current price to a moving average. This moving average is shifted back in time. This is to isolate shorter cycles. The period of the moving average is typically chosen based on the cycle length. The DPO is an oscillator indicator as it oscillates above and below zero, and this gives good insights, as reading positive values indicates that the price is trading above its shifted average, while negative values indicate that the price is below it.
This indicator can be used to detect cyclical highs and lows, as well as to time entries and exits. It can also be used in conjunction with other tools to enhance generated signals.
Author: Mohamed Abdelmaaboud