Register
Welcome to Forex-TSD! , one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.
From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.
Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
Elite Section
Get access to private discussions, specialized support, indicators and trading systems reported every week.
Advanced Elite Section
For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
See more
11-04-2005, 01:18 PM
Administrator
Join Date: Sep 2005
Posts: 299
GC Oscillator
http://www.forex-tsd.com/showpost.ph...0&postcount=23
I think this oscillator (documented in Ehlers section), is a very good exercise for this section.
In fact I think we could develop as much indicators from Ehlers as possible.
Figure 1. Easy Language Code to Compute the CG Oscillator
Inputs: Price((H+L)/2),
Length(10);
Vars: count(0),
Num(0),
Denom(0),
CG(0);
Num = 0;
Denom = 0;
For count = 0 to Length - 1 begin
Num = Num + (1 + count)*(Price[count]);
Denom = Denom + (Price[count]);
End;
If Denom <> 0 then CG = -Num/Denom;
Plot1(CG, "CG");
Plot2(CG[1], "CG1");
11-04-2005, 06:13 PM
Senior Member
Join Date: Oct 2005
Posts: 994
It's a great example!
Quote:
Originally Posted by forexts
http://www.forex-tsd.com/showpost.ph...0&postcount=23
I think this oscillator (documented in Ehlers section), is a very good exercise for this section.
In fact I think we could develop as much indicators from Ehlers as possible.
Figure 1. Easy Language Code to Compute the CG Oscillator
Inputs: Price((H+L)/2),
Length(10);
Vars: count(0),
Num(0),
Denom(0),
CG(0);
Num = 0;
Denom = 0;
For count = 0 to Length - 1 begin
Num = Num + (1 + count)*(Price[count]);
Denom = Denom + (Price[count]);
End;
If Denom <> 0 then CG = -Num/Denom;
Plot1(CG, "CG");
Plot2(CG[1], "CG1");
Forexts,
Thank you very much for your suggestion; it's really a very good exercise.
It will be our next lesson.
At the same time the Oscillator's name starts with my name's first letters CG (Center of Gravity) (Coders' Guru)
07-21-2006, 03:17 AM
Junior Member
Join Date: Jul 2006
Posts: 8
Cog
I do not yet have access to the Elite section, anyone care to critique my COG indicator for MQL4?
Code:
//+------------------------------------------------------------------+
//| Ehlers COG.mq4 |
//+------------------------------------------------------------------+
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue
extern int COGPeriod = 10;
double COG[], COG1[], wrkArray[];
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(2);
IndicatorDigits( MarketInfo( Symbol(), MODE_DIGITS ));
SetIndexStyle(0, DRAW_LINE);
SetIndexStyle(1, DRAW_LINE);
if( !SetIndexBuffer( 0, COG ) &&
!SetIndexBuffer( 1, COG1 ))
Print( "cannot set indicator buffers!" );
SetIndexDrawBegin( 0, COGPeriod );
SetIndexDrawBegin( 1, COGPeriod );
IndicatorShortName( "Ehlers COG" );
return(0);
}
//+------------------------------------------------------------------+
// Calculating Ehlers Center of Gravity
//+------------------------------------------------------------------+
// COG = -1 * (NUM / DENOM)
// NUM = the sum of [PRICE[i] * (i + 1)] from 0 to N
// DENOM = the sum of PRICE[i] from 0 to N
// where N equals the number of periods (COGPeriod)
// PRICE[0] equals the current bar
// PRICE[1] equals the previous bar
// PRICE[n] equals the price from n bars previous
//+------------------------------------------------------------------+
int start()
{
int i, j, limit, iWrk00;
int countedBars = IndicatorCounted();
double dWrk00, num, denom;
limit = Bars - countedBars;
for( i = 0; i < limit; i++ )
{
if((i >= COGPeriod) || (limit < 10))
{
num = 0;
denom = 0;
for( j = 0; j < COGPeriod; j++)
{
if(limit < 10)
iWrk00 = i + j;
else
iWrk00 = i - COGPeriod + j;
dWrk00 = (High[iWrk00] + Low[iWrk00]) / 2;
num = num + (1 + j) * dWrk00;
denom = denom + dWrk00;
}
if(limit < 10)
iWrk00 = i;
else
iWrk00 = i - COGPeriod;
COG[iWrk00] = -num / denom;
if(iWrk00 > 0)
COG1[iWrk00 - 1] = COG[iWrk00];
}
}
return(0);
}
//+------------------------------------------------------------------+
It doesn't seem to be charting out for me
07-21-2006, 10:02 AM
Administrator
Join Date: Sep 2005
Posts: 20,058
First COG I found inside my computer. The second indicator on the image is yours.
Attached Images
Attached Files
07-21-2006, 02:03 PM
Junior Member
Join Date: Jul 2006
Posts: 8
Yes, they do look nearly identical.
And I am able to get the display now. I must have placed an invalid character somewhere while viewing in the editor.
Thanks NewDigital!
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools
Display Modes
Linear Mode
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Stochastic Oscillator
newdigital
Setup Questions
321
11-19-2009 08:40 PM
WESS-Oscillator
McDuck
Suggestions for Trading Systems
12
04-02-2007 03:43 AM
Awesome oscillator
trevman
Metatrader 4
0
12-15-2006 04:32 PM
Oscillator Indicator
babarmughal
Indicators - Metatrader 4
5
05-07-2006 09:38 AM
Oscillator
006
Expert Advisors - Metatrader 4
2
01-28-2006 05:49 PM
All times are GMT. The time now is 11:43 AM .