| / | Forum |
|
walb99
2008.01.22 19:29
Hi everyone! Need some help to code a double smoothed EMA. The derfinition is: Double Exponential Smoothing (DES) applies Single Exponential Smoothing twice. My code has still a mistake, hope somebody can find it: //+------------------------------------------------------------------+ #property indicator_chart_window extern int MA_Period=14;
double tempbuffer[]; int init()
int start() ( for (int i=limit;i>=0;i--){ ----------------------------------------------------------------------------- Thank you and best regards walb99 |
|
Testing of Expert Advisors in the MetaTrader 4 Client Terminal: An Outward Glance What happens after you have clicked on the "Start" button? The article answers this and many other questions. |
|
phy
2008.01.22 19:57
What's with all the extraneous parenthesis and braces? |
|
walb99
2008.01.22 20:01
Can you corect the code? I m really lost with it. |
|
phy
2008.01.22 21:27
If you use a { (brace) you have to have one and only on } to go with it. If you use a ( (parenthesis) you have to have one and only one ) to go with it, also. Same for [ and ]. {} encloses a block of code () encloses a list of paramters, which may be empty [] encloses the index for an array |
|
walb99
2008.01.22 21:50
phy wrote: in my editor the braces and the parenthesis look the same, how can I change this?
I found the answer: I changed the fond to courier, befor it was courier new, which
downot make a difference in the display of braces and parenthesisl.If you use a { (brace) you have to have one and only on } to go with it. If you use a ( (parenthesis) you have to have one and only one ) to go with it, also. Same for [ and ]. {} encloses a block of code () encloses a list of paramters, which may be empty [] encloses the index for an array |
|
walb99
2008.01.22 22:17
The code looks like this now, but there is still one mistake in it, compiler says, unbalance parenthesis: ---------------------------------------------------------------------------------------------------------------------------- //+------------------------------------------------------------------+ #property indicator_chart_window extern int MA_Period=14;
double tempbuffer[]; int init()
int start() { for (int i=limit;i>=0;i--){ |
|
phy
2008.01.23 02:29
One { needs one } You must master this. |
|
walb99
2008.01.23 08:43
phy wrote: One { needs one } You must master this. OK, I got it, thank you for your help!!! |
|
walb99
2008.01.23 08:57
The code looks like this now: -------------------------------------------------------------------------------- //+------------------------------------------------------------------+ #property indicator_chart_window extern int MA_Period=14;
double tempbuffer[]; int init()
int start() { for (int i=limit;i>=0;i--){ -------------------------------- The compiler does not report any errors, but the indicator displays nothing on the chart window. There must be still a bug in it. |
|
phy
2008.01.23 09:36
You haven't declared the size of tempBuffer. You must specify a size for your array tempbuffer, in this case, at least as big as the current number of Bars. MT4 automatically handles this for indicator index buffers. Also, ArraySetAsSeries is not to be used on the index array, but should be used to prepare tempbuffer array. |
|
walb99
2008.01.23 09:53
OK. This version is working now as it should do. Thank you for your help. This problem is solved now. //+------------------------------------------------------------------+ #property indicator_chart_window extern int MA_Period=14;
double tempbuffer[500]; int init()
int start() for (int i=limit;i>=0;i--){ |