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.
Hello guys, I need some advice, I want to make an EA using this center of gravity indicator.
I want to use it as a function so I could call it anywhere in my EA.
If it's not too much, i'd prefer to start it with
Code:
double COG(int timeframe, int period, int shift)
I'm a newbie in programmer's world, and I find some difficulties in it.
Please someone help me, thank you.
Code:
//+------------------------------------------------------------------+
//| Center of Gravity.mq4 |
//+------------------------------------------------------------------+
#property copyright "Copyright 2002, Finware.ru Ltd."
#property link "http://www.finware.ru/"
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
extern int Per=10;
extern int CountBars=300;
//---- buffers
double val1[];
double val2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- indicator line
IndicatorBuffers(2);
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,val1);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,val2);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Center of Gravity |
//+------------------------------------------------------------------+
int start()
{
if (CountBars>=Bars) CountBars=Bars;
SetIndexDrawBegin(0,Bars-CountBars+Per+1);
SetIndexDrawBegin(1,Bars-CountBars+Per+1);
int i,cnt,counted_bars=IndicatorCounted();
double value1,sum,sum1;
//----
if(Bars<=38) return(0);
//---- initial zero
if(counted_bars<Per)
{
for(i=1;i<=0;i++) val1[CountBars-i]=0.0;
for(i=1;i<=0;i++) val2[CountBars-i]=0.0;
}
//----
i=CountBars-Per-1;
while(i>=0)
{
sum = 0.0;
for (cnt=0; cnt<=Per-1; cnt++)
{
sum = sum + (High[i+cnt]+Low[i+cnt])/2;
}
sum1=0.0;
for (cnt=0; cnt<=Per-1; cnt++)
{
sum1=sum1+((High[i+cnt]+Low[i+cnt])*(cnt+1)/2);
}
value1=sum/sum1;
val1[i]=value1;
if (i>0) val2[i-1]=value1;
i--;
}
return(0);
} //+------------------------------------------------------------------+
I have found this excellent article in another forum
As to our Mr. Ehlers, the situation is in fact as I explained in my (earlier) post . All of Ehlers concepts that I have seen come straight from Electrical Engineering / Digital Signal Processing theory, in which realm they are conceptually and mathematically solid, and are all established and widely accepted concepts that work very well. There is no problem with Ehlers theoretical foundations. The problem is in the domain of their applicability.
In the domains to which Ehlers concepts are widely applied (e.g. seismic geophysics, data transmission lines, telephone noise suppression, etc, etc), there may be more data sample points in just a few seconds or less, than there are for us in many years of stock market data, perhaps even more than in the entire history of the US stock-market. With regard to Ehlers ideas and trading, the problems that I can see, in order or importance, starting from the most significant, are basically as follows:
Firstly, in trading we have very much less data than is available in all the other areas where these signal processing ideas work so well.
Secondly, in most cases the signal processing is applied in situations where there is a lot of repetition or very near repetition (for example neighboring seismic wavelets and seismic traces from neighboring geophones).
Thirdly, contrary to the situation with markets, the signal processing methods are usually applied to non-sentient systems that are not composed of individuals who will strongly and quickly modify their behavior in response to anything that even starts to look like a repetitive cyclical price pattern.
I think there may also be a fourth reason that is more subtle. From the Nyquist criterion, for correct un-aliased digital sampling of any waveform, the sampling frequency must be at least 4 times the highest frequency component of the input signal. In electrical signal processing, we can usually satisfy this constraint either by increasing the sample rate, or alternatively by pre-filtering the signal with a suitable filter to remove any frequency components above that specified by the Nyquist criterion. In market data, the situation is much trickier. Large price changes can occur between one bar and the next. A price step from one bar to the next contains frequency components that correspond to wavelengths less than the bar spacing. To correctly represent these, we would need to decrease the sample spacing to less than 1 bar (equivalent to having to use intra-day data when you really only want EOD). The problem is that, because of the fractal noise (or, if you prefer to call it “Elliot wave”) nature of trading data at every timescale (whether weekly, daily, intraday, or whatever), the “correct” sampling rate (i.e. the necessary distance between bars) is never sufficient, unlike the relatively simpler case of non-fractal electrical signals.
Even if anyone doubts that items 3 & 4 are important, you can easily see the shortcomings of Ehlers' DSP ideas when applied to trading by doing the following experiment: Take a nice clean signal like a sinusoid, with LOTS of cycles, and also very closely spaced sampling compared to the wavelength (i.e. bar spacing << ¼ * wavelength, so as to satisfy the Nyquist criterion), then apply Ehlers filters and see how well they work. They should work brilliantly!! But then think how many cycles it would take in the market before someone started noticing them and acted on it, which would then modify the cycles and probably make them disappear. In the experiment, also increase the sample (bar) spacing to something consistent with EOD bars relative to the size of (whatever you realistically choose to retain of) your sinusoid. When I did this some years ago, I found that, with signal lengths and data sample spacings consistent with market data, the results started to look rather less convincing, although they continue to be potentially useful to some extent. But then remember that we still have an ideal noise-free input signal, so start adding random noise. Quite a bit of it in fact for realistic market data. This adds in a lot more high-frequency components that were not present in the original ideal signal. This means that our sample rate is now going to be too low once again, so we would need to go to more closely spaced bars to avoid the aliasing problem. If we are using EOD data, we can’t do this. The alternative is to try to pre-filter out the noise. There is no such thing as a perfect filter, so as soon as we try this pre-filtering, we no longer have our original signal preserved, because we have introduced phase shifts, lags, and distortions in the pre-filter that are probably quite significant, given the amount of pre-filtering that is required to reduce the (high level of) noise present in market data. Basically, we are stuck in a very non-ideal situation, at least most of the time anyway.
My conclusion is that Ehlers filters are definitely not useless. From time to time, they might even work very well in the market, but just like any other indicators, they are not universally reliable. It’s NOT because there is anything basically wrong with Ehlers ideas but just that, when applied to trading, they have been pushed quite a way beyond the domain for which they were originally intended.
An ideal candidate as an example on how well Digital Signal Processing (DSP) works on data with well-defined repetitive components. If only market data was similarly constructed...
Just found it on the other forum.
Many MetaStock formulas. Page #6 with formulas. To get the other page so change 206 to the other number, for example to get the page #2 with formulas so use 202 in web address instead of 206.
May be, usefull for the people who will convert some indicators to MT4.
Last edited by newdigital; 10-14-2007 at 08:29 AM.
I have found this excellent article in another forum
As to our Mr. Ehlers, the situation is in fact as I explained in my (earlier) post . All of Ehlers concepts that I have seen come straight from Electrical Engineering / Digital Signal Processing theory, in which realm they are conceptually and mathematically solid, and are all established and widely accepted concepts that work very well. There is no problem with Ehlers theoretical foundations. The problem is in the domain of their applicability.
In the domains to which Ehlers concepts are widely applied (e.g. seismic geophysics, data transmission lines, telephone noise suppression, etc, etc), there may be more data sample points in just a few seconds or less, than there are for us in many years of stock market data, perhaps even more than in the entire history of the US stock-market. With regard to Ehlers ideas and trading, the problems that I can see, in order or importance, starting from the most significant, are basically as follows:
Firstly, in trading we have very much less data than is available in all the other areas where these signal processing ideas work so well.
Secondly, in most cases the signal processing is applied in situations where there is a lot of repetition or very near repetition (for example neighboring seismic wavelets and seismic traces from neighboring geophones).
Thirdly, contrary to the situation with markets, the signal processing methods are usually applied to non-sentient systems that are not composed of individuals who will strongly and quickly modify their behavior in response to anything that even starts to look like a repetitive cyclical price pattern.
I think there may also be a fourth reason that is more subtle. From the Nyquist criterion, for correct un-aliased digital sampling of any waveform, the sampling frequency must be at least 4 times the highest frequency component of the input signal. In electrical signal processing, we can usually satisfy this constraint either by increasing the sample rate, or alternatively by pre-filtering the signal with a suitable filter to remove any frequency components above that specified by the Nyquist criterion. In market data, the situation is much trickier. Large price changes can occur between one bar and the next. A price step from one bar to the next contains frequency components that correspond to wavelengths less than the bar spacing. To correctly represent these, we would need to decrease the sample spacing to less than 1 bar (equivalent to having to use intra-day data when you really only want EOD). The problem is that, because of the fractal noise (or, if you prefer to call it “Elliot wave”) nature of trading data at every timescale (whether weekly, daily, intraday, or whatever), the “correct” sampling rate (i.e. the necessary distance between bars) is never sufficient, unlike the relatively simpler case of non-fractal electrical signals.
Even if anyone doubts that items 3 & 4 are important, you can easily see the shortcomings of Ehlers' DSP ideas when applied to trading by doing the following experiment: Take a nice clean signal like a sinusoid, with LOTS of cycles, and also very closely spaced sampling compared to the wavelength (i.e. bar spacing << ¼ * wavelength, so as to satisfy the Nyquist criterion), then apply Ehlers filters and see how well they work. They should work brilliantly!! But then think how many cycles it would take in the market before someone started noticing them and acted on it, which would then modify the cycles and probably make them disappear. In the experiment, also increase the sample (bar) spacing to something consistent with EOD bars relative to the size of (whatever you realistically choose to retain of) your sinusoid. When I did this some years ago, I found that, with signal lengths and data sample spacings consistent with market data, the results started to look rather less convincing, although they continue to be potentially useful to some extent. But then remember that we still have an ideal noise-free input signal, so start adding random noise. Quite a bit of it in fact for realistic market data. This adds in a lot more high-frequency components that were not present in the original ideal signal. This means that our sample rate is now going to be too low once again, so we would need to go to more closely spaced bars to avoid the aliasing problem. If we are using EOD data, we can’t do this. The alternative is to try to pre-filter out the noise. There is no such thing as a perfect filter, so as soon as we try this pre-filtering, we no longer have our original signal preserved, because we have introduced phase shifts, lags, and distortions in the pre-filter that are probably quite significant, given the amount of pre-filtering that is required to reduce the (high level of) noise present in market data. Basically, we are stuck in a very non-ideal situation, at least most of the time anyway.
My conclusion is that Ehlers filters are definitely not useless. From time to time, they might even work very well in the market, but just like any other indicators, they are not universally reliable. It’s NOT because there is anything basically wrong with Ehlers ideas but just that, when applied to trading, they have been pushed quite a way beyond the domain for which they were originally intended.
An ideal candidate as an example on how well Digital Signal Processing (DSP) works on data with well-defined repetitive components. If only market data was similarly constructed...
Hi Mystified.
As I understand your postulates are that the main difference between the data of a physical sources and the data of market sources is the emotion component. But I think all the efforts of the people that study the financial markets and the coders are into the knowledge of that the emotional component exist and the evolution of all these efforts are to translate all the components (including emotionals) into the indicators or techniques that permit us to understand how the markets works and how to predict movements. I think the indicators of Ehlers are good if they show us that they are efficient in order to work with the market data.
Hmmmm.... the Synthetic cycle generator(2) you used is an indicator of MetaStock ? Is it a drawing only?
As I understand your postulates are that the main difference between the data of a physical sources and the data of market sources is the emotion component. But I think all the efforts of the people that study the financial markets and the coders are into the knowledge of that the emotional component exist and the evolution of all these efforts are to translate all the components (including emotionals) into the indicators or techniques that permit us to understand how the markets works and how to predict movements. I think the indicators of Ehlers are good if they show us that they are efficient in order to work with the market data.
Hmmmm.... the Synthetic cycle generator(2) you used is an indicator of MetaStock ? Is it a drawing only?
Hi Mr Cattus,
Thank's for your Share Chart and Indicator, looks very nice.
Refering your chart, can I get The Systhetic cycle generator(2) from you Sir' ???
I have found this excellent article in another forum
As to our Mr. Ehlers, the situation is in fact as I explained in my (earlier) post . All of Ehlers concepts that I have seen come straight from Electrical Engineering / Digital Signal Processing theory, in which realm they are conceptually and mathematically solid, and are all established and widely accepted concepts that work very well. There is no problem with Ehlers theoretical foundations. The problem is in the domain of their applicability.
In the domains to which Ehlers concepts are widely applied (e.g. seismic geophysics, data transmission lines, telephone noise suppression, etc, etc), there may be more data sample points in just a few seconds or less, than there are for us in many years of stock market data, perhaps even more than in the entire history of the US stock-market. With regard to Ehlers ideas and trading, the problems that I can see, in order or importance, starting from the most significant, are basically as follows:
Firstly, in trading we have very much less data than is available in all the other areas where these signal processing ideas work so well.
Secondly, in most cases the signal processing is applied in situations where there is a lot of repetition or very near repetition (for example neighboring seismic wavelets and seismic traces from neighboring geophones).
Thirdly, contrary to the situation with markets, the signal processing methods are usually applied to non-sentient systems that are not composed of individuals who will strongly and quickly modify their behavior in response to anything that even starts to look like a repetitive cyclical price pattern.
I think there may also be a fourth reason that is more subtle. From the Nyquist criterion, for correct un-aliased digital sampling of any waveform, the sampling frequency must be at least 4 times the highest frequency component of the input signal. In electrical signal processing, we can usually satisfy this constraint either by increasing the sample rate, or alternatively by pre-filtering the signal with a suitable filter to remove any frequency components above that specified by the Nyquist criterion. In market data, the situation is much trickier. Large price changes can occur between one bar and the next. A price step from one bar to the next contains frequency components that correspond to wavelengths less than the bar spacing. To correctly represent these, we would need to decrease the sample spacing to less than 1 bar (equivalent to having to use intra-day data when you really only want EOD). The problem is that, because of the fractal noise (or, if you prefer to call it “Elliot wave”) nature of trading data at every timescale (whether weekly, daily, intraday, or whatever), the “correct” sampling rate (i.e. the necessary distance between bars) is never sufficient, unlike the relatively simpler case of non-fractal electrical signals.
Even if anyone doubts that items 3 & 4 are important, you can easily see the shortcomings of Ehlers' DSP ideas when applied to trading by doing the following experiment: Take a nice clean signal like a sinusoid, with LOTS of cycles, and also very closely spaced sampling compared to the wavelength (i.e. bar spacing << ¼ * wavelength, so as to satisfy the Nyquist criterion), then apply Ehlers filters and see how well they work. They should work brilliantly!! But then think how many cycles it would take in the market before someone started noticing them and acted on it, which would then modify the cycles and probably make them disappear. In the experiment, also increase the sample (bar) spacing to something consistent with EOD bars relative to the size of (whatever you realistically choose to retain of) your sinusoid. When I did this some years ago, I found that, with signal lengths and data sample spacings consistent with market data, the results started to look rather less convincing, although they continue to be potentially useful to some extent. But then remember that we still have an ideal noise-free input signal, so start adding random noise. Quite a bit of it in fact for realistic market data. This adds in a lot more high-frequency components that were not present in the original ideal signal. This means that our sample rate is now going to be too low once again, so we would need to go to more closely spaced bars to avoid the aliasing problem. If we are using EOD data, we can’t do this. The alternative is to try to pre-filter out the noise. There is no such thing as a perfect filter, so as soon as we try this pre-filtering, we no longer have our original signal preserved, because we have introduced phase shifts, lags, and distortions in the pre-filter that are probably quite significant, given the amount of pre-filtering that is required to reduce the (high level of) noise present in market data. Basically, we are stuck in a very non-ideal situation, at least most of the time anyway.
My conclusion is that Ehlers filters are definitely not useless. From time to time, they might even work very well in the market, but just like any other indicators, they are not universally reliable. It’s NOT because there is anything basically wrong with Ehlers ideas but just that, when applied to trading, they have been pushed quite a way beyond the domain for which they were originally intended.
An ideal candidate as an example on how well Digital Signal Processing (DSP) works on data with well-defined repetitive components. If only market data was similarly constructed...
This is what i call 'The Perfect Cycle' , unfortunately you wont see this 'Perfect Cycle' in todays market, todays market is full of noise and unstable data!, thats why there is no such thing 'The Perfect Cycle', but if you'll do your research on cycles you'll see that cycles are alway with us, not in the short therm but in the long run for sure, and not as perfect as the pic ofcourse...well, you have cycles in the short run to, but you wont be able to catch those cycles, because of the noise and the unstable data. its very hard, but if you have the right tools for the job like noise reduction and such.. it would make it more easy to catch, i know if i had the money for the tools i need, i would probbly was doing other things right now...but we try to do our best, and we will keep trying!
anyhow, stop dreaming and B-Real, thats how you'll make money..
cheers
__________________
Creativity is all you need, Its part of the BALANCE