Thursday, August 5, 2021

Center of Gravity

Real author:


Center of Gravity actually has a zero lag and allows to define turning points precisely. This indicator is the result of Ehler’s study of adaptive filters.

The indicator Center of Gravity allows to identify main pivot points almost without any lag.

The idea of calculating a center of gravity appeared from the investigation of lags of different filters with the finite impulse response (FIR) in accordance with the relative amplitude of filter coefficients. SMA (Simple Moving Average) is a FIR-filter, in which all coefficients have one and the same value. As a result the center of gravity of SMA is an exact center of the filter. WMA (Weighted Moving Average) is a FIR-filter, in which the last price change is weighted through the filter length, and so on.

The values of weighting are coefficients of filters. Coefficients of WMA filters can be presented as contours of a triangle. The center of gravity is on the 1/3 of the triangle base length. Thus WMA gravity center is shifted to the right with respect to the center of gravitation of SMA of the same length, which gives us a smaller lag. For all examples with FIR filters the sum of productions of coefficients and the price must be divided by the sum of coefficients for preservation of original prices.

The most famous of such FIR filters is Ehlers filter that can be presented the following way:

The quote from the article:

“The coefficients of the Ehlers Filter can be almost any measure of variability. I have looked at momentum, signal to noise ratio, volatility, and even Stochastics and RSI values as filter coefficients. One of the most adaptive set of coefficients arose from video edge detection filters, and was the sum of the square of the differences of each price to each previous price. In any event, the result of using different filter coefficients is to make the filter adaptive by moving the CG of the coefficients.

While I was debugging the code of an adaptive FIR filter I noticed that the CG, itself, moved in exact opposition to the price swings. The CG moves to the right when prices go up and moves to the left when prices go down. Measured as the distance from the most recent price, the CG decreased when prices rose and increased when they fell. All I had to do was to invert the sign of the CG to get a smoothed oscillator that was both in phase with the price swings and had essentially zero lag.”

The Center of Gravity is calculated as Ehlers filter using the formula:

In this indicator Period_ parameter sets the period for the indicator calculation, AppliedPrice parameter sets the price type, based on which the indicator is calculated – thus we get the main line of the indicator (with changing color).

For the signal line (blue dot-dash line) the SmoothPeriod parameter sets the period of smoothing the main indicator line, the SmoothType parameter denotes the type of smoothing. The interpretation of the values of parameters is given in the form of comments in the indicator code.

Indicator uses the СMoving_Average class of the SmoothAlgorithms.mqh library. Working with that class was described in details in the article “Averaging Price Series for Intermediate Calculations Without Using Additional Buffers”.

This indicator was first implemented in MQL4 and published in CodeBase 20.02.2007.


Installing indicators on MT5 comes down to:

  1. Downloading the files (.ex5 and .mq5 formats)
  2. Placing them in the MT5 “Indicators” Data Folder
  3. Closing and re-starting your MT5 terminal
  4. Dragging you indicator from the Navigator to the Forex Chart

Downloading the indicator.

Download and prepare the MT5 indicator file(s) so they are ready to go on your computer. (Please note that some custom indicators will come in a .rar file, so make sure to extract the .ex5 and .mq5 files).

Go back to your Metatrader 5 platform, click the File Tab and select “Open Data Folder” to get access to the system folders for the MT5 program:

Placing them in the MT5 “Indicators” Data Folder.

Go to the “MQL5” folder and the “Indicator” subfolder and open the folder.

Drag or copy and paste the custom indicators files to the “Indicators” subfolder.

Restart the MT5 program. When MT5 loads again, you should see your custom indicator added to the directory in the navigation window.

Go to the navigation window and scroll down the menu to “Indicators”, pick the one you want to use and drag it to your chart.

For a video on how to install you MT5 indicators please visit our Youtube channel.

Peppperstone is an award winning broker with a No Dealing Desk, Pure ECN model. Their cutting edge technology coupled with pricing from 22 Tier 1 banks ensures that traders will receive the fastest execution at the most competitive pricing available. 


Pepperstone is authorized to do business in many different countries around the world.  The two main regulatory bodies that are responsible for oversight of Pepperstone’s operations is the Australia Securities and Investment Commission (ASIC) and UK’s Financial Conduct Authority (FCA).

Trading Platforms

There are two primary choices of trading platforms that Pepperstone supports. The first is the industry standard Metatrader platform and the second is the ECN based cTrader platform.

Trading Instruments

Pepperstone offers 100+ trading interments, with a primary specialization in Forex and CFDs (Contracts for Difference).  There are over 70 currency pairs available to trade, everything from the majors, to the minors and exotic pairs. With access to the interbank market for razor thin dealing spreads starting at 0 pips, forex traders will find Pepperstone to an excellent choice.

Commissions and Spreads

As an ECN broker, Pepperstone offers extremely tight dealing spreads. The actual trading cost will depend on the type of account chosen. Pepperstone offers two primary account types – Razor Account and the Standard Account. The Razor Account is a true ECN based broker account with Interbank pricing and a commission charged to the trader.

Open your account. Trade within minutes. Full Review here



Risk Disclaimer for Forex Trading. Trading foreign exchange on margin carries a high level of risk, and may not be suitable for all investors. Past performance is not indicative of future results. The high degree of leverage can work against you as well as for you. is a trade signal service.  You understand that none of the strategies or indicators that we make availible constitutes a recommendation that any particular trade is suitable. By downloading an indicator or strategy, you are confirming that you have read and agree to all of the terms and conditions posted on our terms and conditions page. We are not responsible for the content of any sites that may be linked to or from the Site or any message board (referred to on the Site as the “forum”) associated with us or the Site. These links are provided for your convenience only and you access them at your own risk. Unless otherwise noted, any other website accessed from the Site is independent from us, and we have no control over the content of that other website. We do not own the indicators available for download. All indicators are freely available on other websites and forums. If you are the owner of an indicator or strategy that we have made available for download, and you are wanting us to cease promoting it, please sent us an email and we will delete the post. If you would like the description modified, please contact us. In addition, a link to any other web site does not imply that we endorse or accept any responsibility for the content or use of such other website.

Previous articleHorizontal Grid Lines
Next articlePearson Correlation
Metatrader Indicators was developed by Forex traders for traders. We wasted hours, probably years, looking for indicators, software and Forex broker reviews. is a hub for technical traders. It represents years of work, knowledge and experience. Enjoy and stay true to your passion.

top forex brokers