Forex Factory (https://www.forexfactory.com/)
-   Platform Tech (https://www.forexfactory.com/forum/69-platform-tech)
-   -   Center of Gravity (COG) Indicator (https://www.forexfactory.com/thread/651904-center-of-gravity-cog-indicator)

lukeb Mar 26, 2017 3:00pm | Post# 1

Center of Gravity (COG) Indicator
 
4 Attachment(s)
In ancient history, there seems to have been considerable interest in the COG indicator - here's a link to one such thread:
https://www.forexfactory.com/showthread.php?t=187468

There are many publishers of COG indicators, no idea who was first but they all have their own author information.
The COG is an indicator that re-paints, and seems to be always written from present to past (see JB cog for a non-repainter, I haven't looked at it yet). Never-the-less, it is an 'honest' indicator - it attempts to do a form fitted curve to give you an indication of the center of the market, that is, where the market may be returning to, and redraws the form with each new bar.

Attached is a rewrite of cog that uses the updated mq4 event managers, and is broken into functional units (a good programming practice), that likely has some efficiency gains over the source code it came from.

The 2nd file is the goal of the re-write - it trails the history of the COG, so you can see 'where the ends were' for the chart's history.
--- input bool HideOld = false; // Hide old bar display
--- input bool ShowCogHistory = true; // show history of COG values at the creation of each bar
if you turn those off, you will just get a regular old COG display. It takes my laptop 8 seconds to do the 65K bar history from starting the indicator. The most entertaining thing to do is run it in the strategy tester and watch the lines trail off the COG.... Jump forward so there are enough bars to run it when the strategy tester starts.

Anyone trading using COG?
Updated COG_History to allow displaying the 'COG' at any chosen time, or run to the newest time. Fixed a display bug.
Attachment 2249442Attachment 2249444
COG_History.mq4
Center_Of_Gravity.mq4

mladen Mar 26, 2017 3:36pm | Post# 2

That is no "center of gravity"
That is regression channel. You can find more info on it here : https://en.wikipedia.org/wiki/Regression_analysis
Regression analysis as is exists for a couple of centuries but it seems that mt renamers succeeded to hide that fact quite well Better to use it's real name in order to avoid confusion of what it is and what it never was- and when search is done using the real name, a lot more results can be found

shaileshm Mar 26, 2017 4:12pm | Post# 3

how can you use this indicator to trade reversals?
What are the things you would watch out for once the price touches the outer bands?

lukeb Mar 28, 2017 11:54pm | Post# 4

That is no "center of gravity" That is regression channel.
I don't see that naming a 'bars_back' regression channel made in a particular way a 'COG' is inappropriate, as long as there is no deception involved.
Anyway it was easy for me to break the code up into 'work units' and put each into its own function to see its dependencies, but would take much longer and be a lot of work to figure out the why and what is accomplished to properly comment each of those functions. From what I've seen, you have the background to be able to make those comments in the source file - would you mind doing that?

If you have a different regression tool that you think is better and more deserving of attention, I'd really be interested in your opinion.

lukeb Mar 28, 2017 11:55pm | Post# 5

how can you use this indicator to trade reversals? What are the things you would watch out for once the price touches the outer bands?
I'd just have to refer you to some of the other discussions on trading with 'the COG', like the one here: https://www.forexfactory.com/showthread.php?t=187468. I'd certainly be interested in any ideas anyone has or good discussions someone wants to point me to.

hanover Mar 29, 2017 2:13am | Post# 6

Just for the record, mladen (post #2) is correct, the indy plots a polynomial regression channel.
It was originally released as iRegr, but somebody apparently changed the name at some point.
Just a warning note: for better or worse, regression channels tend to repaint.

lukeb Mar 29, 2017 10:45pm | Post# 7

Just for the record, mladen (post #2) is correct, the indy plots a polynomial regression channel. It was originally released as iRegr, but somebody apparently changed the name at some point. Just a warning note: for better or worse, regression channels tend to repaint.
Thanks - I updated the files to show the original code came from iRegr.
As far as repaints - A regression curve must redraw with each new data point added, or that's not what it would be. That's why I added the dotted lines to show the history of 'what it was'. That way, the user can see the history of what the indicator was at when each bar opened (when a new data point added - the close of the previous bar).

hanover Mar 30, 2017 1:13am | Post# 8

As far as repaints - A regression curve must redraw with each new data point added, or that's not what it would be.
Yes, exactly.
That's why I added the dotted lines to show the history of 'what it was'. That way, the user can see the history of what the indicator was at when each bar opened (when a new data point added - the close of the previous bar).
Nice work!

mladen Mar 30, 2017 3:45am | Post# 9

Just some additional words from me too (probably needed)

Regression analysis is probably one of the most widely used methods in all sorts of analysis (I would like to see an EEG without being filtered by regression analysis, or a simplest PC without the same thing done : I guess we would still shout from one hill to another without it, and so on, and soo on, we could show thousands of examples here ...) and nobody can dispute the usefulness of it - least of all me. It recalculates but fitting/estimating calculations must do that in order to produce the results expected from the underlying mathematical model, but that does not change the fact that it is one of the best mathematical models for filtering and estimation (extrapolation)
__________________________________

What I wanted to point out that the "center of gravity" name has nothing to do with what it actually is. And yes, it was renamed on purpose : to the extent that the "author" (not going to name him, but ...) claims copyright and was even awarded some awards at some Paris IT fairs "for breaks in technological advance" (whatever that means) - and all that for a stolen/renamed code

The story of "center of gravity" is all the usual that we all have seen so many times and is, after all, rather sad, than anything else
__________________________________

PS: I really would like to make a distinction between "repainting" and recalculating : recalculating is a perfectly valid calculating method usually based on a solid mathematical models. "Repainting" is nothing but a coding error and should be treated like that.

shaileshm Apr 2, 2017 12:25am | Post# 10

i did some test with the COG indicator this. It is only as best as any other regression channel. Trading reversal blindly when price touches the boundary does not work. but since its a reainting, the past always looks perfect. I wouldnt recommend using this indicator. I real time the price touching the boundary means nothing at all.

ramzam Jul 26, 2018 9:08am | Post# 11

2 Attachment(s)
is this center of gravity is diff from extreambinary channal
xtreme_binary_robot_channel.ex4
xtreme_binary_robot_channel.mq4

sunny2way Jul 28, 2018 11:23am | Post# 12

is this center of gravity is diff from extreambinary channal {file} {file}
Love this your extreambinary channel on my platform please does it repaint and how does it work ?

saidi123 Jul 28, 2018 12:22pm | Post# 13

1 Attachment(s)
Please, If anyone could help me to change the colors between levels in the MACD like I did it with triangles, I would be so thankful and grateful
Click to Enlarge

Name: 112223.JPG
Size: 139 KB

Namor Jul 28, 2018 12:34pm | Post# 14

{quote} Love this your extreambinary channel on my platform please does it repaint and how does it work ?
It repaints.

sunny2way Jul 28, 2018 6:03pm | Post# 15

{quote} It repaints.
Thanks

mrtools Jul 29, 2018 2:58am | Post# 16

2 Attachment(s)
This is a real Ehlers center of gravity, or at least closer to it.
Ehlers center of gravity.mq4
Click to Enlarge

Name: ehlers center of gravity.png
Size: 35 KB

SanghoonKim Oct 21, 2019 5:06am | Post# 17

Hi ! lukeb


Teach me how to run on a strategy tester and track lines in COG! Bars will continue to be zero.
Can't you teach me with screen capture?
Teach me how to run on a strategy tester and track lines in COG! Bars will continue to be zero. Can't you teach me with screen capture?

ramonrly Jul 10, 2020 1:10pm | Post# 18

1 Attachment(s)
Hi

Please, somebody could add arrow and alert on this Center Of Gravity indicator, it is very good if you use in combination with support and resistence after the green lines. it does not repaint, if you add arrow and alert will be very handle to backtest too.
JB_Center_of_Gravity.mq4

foodaa Oct 7, 2020 11:38pm | Post# 19

1 Attachment(s)
Hi Please, somebody could add arrow and alert on this Center Of Gravity indicator, it is very good if you use in combination with support and resistence after the green lines. it does not repaint, if you add arrow and alert will be very handle to backtest too. {file}
here for you arrows for directions
Belkhayate system.zip

mrtools Nov 3, 2020 12:50pm | Post# 20

2 Attachment(s)
This is a fisher stochastic center of gravity arrows, alerts and mtf, the alerts, arrows, and coloring are on signal cross.
fisher stochastic cg (mtf + alerts + arrows).ex4
Click to Enlarge

Name: EURUSDM15.png
Size: 60 KB


© Forex Factory