The Detrended Price Oscillator (DPO) is a technical momentum indicator used for financial analysis, it was developed by William Blau in 1991, and designed to help traders and analysts identify short-term price cycles and potential overbought or oversold conditions in a symbols price.
The indicator serves as a valuable tool for evaluating price cycles within the symbol you are trading, including the peaks and troughs, as well as time spans. While the DPO can be effectively employed in the Forex, spot and futures markets, it is not suitable for analyzing option prices.
Detrended Price Oscillator Overview
The first step in calculating the DPO is to determine the simple moving average (SMA) of the symbol's price over a specified period of time. the most common periods used for the SMA include 20, 50, or 200 days, but this can vary depending on the trader's preference and the time frame being analyzed.
This modified version of the cBot allows the option to select 8 different types of moving averages for experimentation, these are: simple, exponential, time series, triangular, VIDYA, weighted, wilder smoothing & hull.
Once the Simple Moving Average is calculated, the DPO is calculated by subtracting the SMA from the price of the symbol at a specific time in the past which is typically half of the SMA period.
DPO = Price (X days ago) - SMA (n)
- Price (X days ago) is the closing price of the symbol X days ago.
- SMA (n) is the simple moving average calculated over a period of n days.
How to Trade Using the DPO cBot
The Detrended Price Oscillator strategy opens trades based on the DPO price being above or below to zero line, you simply configure your parameters and start the cBot.
Microsoft C# Code Snippet
(_detrendedPriceOscillator.Result.Last(1) > 0 && _detrendedPriceOscillator.Result.Last(2) <= 0
_detrendedPriceOscillator.Result.Last(1) < 0 && _detrendedPriceOscillator.Result.Last(2) >= 0
We have added a few extra cBot settings to this example by Spotware to help you get started creating a usable automated trading system, These are as follows:
- Label - allows you to manage only the trades opened by the cBot.
- Volume - the trade size in lots.
- Stop loss & take profit values in pips.
- DPO periods - the period value used in the detrended price indicator.
- DPO MA Type - 8 different moving average types to experiment with.
- Close on reverse - option to close trades on the opposite signal.
How to Improve this Strategy
There are many ways to improve this cBot, The first one is to add additional indicators for confirmation or additional risk management like market hours, trailing stop losses etc. If you cannot add these extra features yourself contact us.
Stop Loss & Take Profit Calculation
A standard stop loss and take profit as well as position size can be set from the cBots parameter settings.
You can add risk management and other trade rules yourself or by contacting our development team.
How to Optimise the Settings
We have also created a simple video showing how you can find the optimal parameter values, it uses another cBot as an example.
How to Attach Indicator to Chart
You do not need to attach the Donchian Channel indicator to your chart when you run the cBot, but it is a good idea to visually see the indicator to check your trade rules for opening and closing trades and any risk management.
How To View The Source Code
To view the source code for this cBot, you will first need to make sure you have downloaded and installed cTrader Desktop, You can also scroll to the bottom of this page for instructions on how to install the cBot. Once installed you will have the cTrader application open, You need to navigate to the Automate application and click on the name of the cBot, the source should show in the right-hand window.
If you need more help watch a video tutorial on how to use cTrader Automate.
Learn Algorithmic Trading
In this instructional guide, we aim to assist you in acquiring the necessary skills to engage in market trading through automated trading strategies (cBots) using the cTrader Desktop trading platform. By the conclusion of this tutorial, you will gain the confidence to employ a cTrader cBot alongside the Algo application of cTrader, enabling you to automatically execute and handle your market orders. This course is designed to familiarize novice traders with the fundamental principles of algorithmic trading utilizing the cTrader platform.
Learn Microsoft C# for Algo Trading
If you are new to coding your own cTrader cBot for automated trading the following Microsoft C# course will help you modify the starter kit cBot in this download to add new features for your own personal trading strategy.
Algorithmic Trading Facts
A significant number of traders venture into algorithmic trading with the misconception that they have discovered a foolproof strategy that guarantees effortless wealth. However, this notion is far from reality. It is crucial to read this article, as it can save you valuable time and money.
How To Install & Remove
First, make sure you have the cTrader trading platform installed and then simply unzip the file and double-click on it to install it onto the platform automatically.
If you have any questions, please first search our coding help forum for the answer, if you cannot find it, post a new question.
Need Coding Help?
We can help you modify this cBot for your own personal trading strategy, Contact our team for a quote.
Need a Broker
If you are still looking for a broker you can trust, take a look at our best cTrader broker site.