Chande Mommentum and the division mistery - page 2

 
I analysed your code and found some interesting things about mql4.

1. Flat line in the begining of the indicator.

You did not used the SetIndexDrawBegin function and you shold becouse CMO calculates current values using CMO_Period number of previous bars. So somewhere in init() function you should put line:

   SetIndexDrawBegin(0,CMO_Period);
2. You do not used the standard Indexes but dynamic arrays. I not completely sure but I think current algorytm may give wrong resluts. When the new bar is formed standard buffers are automatically resized and your dynamic arrays are not so it is potencial risk. You would better use standard buffers.

   IndicatorBuffers(5);
   SetIndexBuffer(0,cmo);
   SetIndexBuffer(1,cmo1);
   SetIndexBuffer(2,cmo2);
   SetIndexBuffer(3,scmo1);
   SetIndexBuffer(4,scmo2);
3. Calculation of cmo1 and cmo2 should be carried from limit+CMO_Period-1 till 0 not from limit till 0 becouse while calculating smo1 and scmo2 you itereate over cmo1[] and cmo2[] till limit+CMO_Period-1.

   for(i = limit+CMO_Period; i >= 0; i--)
     {
       dif1 = Close[i]-Close[i+1];
       if(dif1>=0){
         Tcmo1 = dif1;
         Tcmo2 = 0;
       } 
       else {
         Tcmo1 = 0;
         Tcmo2 = -dif1;
       } 
       cmo1[i] = Tcmo1;
       cmo2[i] = Tcmo2;
     }
Files:
icmogt_2.mq4  3 kb
 
scalony:
I analysed your code and found some interesting things about mql4.

1. Flat line in the begining of the indicator.

You did not used the SetIndexDrawBegin function and you shold becouse CMO calculates current values using CMO_Period number of previous bars. So somewhere in init() function you should put line:

   SetIndexDrawBegin(0,CMO_Period);
2. You do not used the standard Indexes but dynamic arrays. I not completely sure but I think current algorytm may give wrong resluts. When the new bar is formed standard buffers are automatically resized and your dynamic arrays are not so it is potencial risk. You would better use standard buffers.

   IndicatorBuffers(5);
   SetIndexBuffer(0,cmo);
   SetIndexBuffer(1,cmo1);
   SetIndexBuffer(2,cmo2);
   SetIndexBuffer(3,scmo1);
   SetIndexBuffer(4,scmo2);
3. Calculation of cmo1 and cmo2 should be carried from limit+CMO_Period-1 till 0 not from limit till 0 becouse while calculating smo1 and scmo2 you itereate over cmo1[] and cmo2[] till limit+CMO_Period-1.

   for(i = limit+CMO_Period; i >= 0; i--)
     {
       dif1 = Close[i]-Close[i+1];
       if(dif1>=0){
         Tcmo1 = dif1;
         Tcmo2 = 0;
       } 
       else {
         Tcmo1 = 0;
         Tcmo2 = -dif1;
       } 
       cmo1[i] = Tcmo1;
       cmo2[i] = Tcmo2;
     }


Scalony,


Congratulations!!!


You solved the three issues with a single shot!!


It is very rewarding to complete this indicator after so many troubles.


I learned a lot of MQL4 with this experience.


What do you think of putting this indicator in the code base? I believe that you deserve this honor, so if you want, please, put it there.


Thank you very much for your collaboration!

 

Thank you for your collaboration too!


Now I am testing this indicator on my account and it seems to work quite well, and profitable.
I also added some color coding, you may find it usefull.

Before putting it to code base we should do some more cleaning and put comments.

Files:
icmo_1.mq4  4 kb
 
scalony:

Thank you for your collaboration too!


Now I am testing this indicator on my account and it seems to work quite well, and profitable.
I also added some color coding, you may find it usefull.

Before putting it to code base we should do some more cleaning and put comments.










Ok, I agree.


I have one sujestion for the code:
if(cmo4 == 0)cmo4=0.0001;
cmo[i] = (cmo3/cmo4)*100;
What do you think?

About the colors, it is very good but I found something interesting about the buy and sell signals:

Chande Momentum Oscilador (CMO)
Abstract:
The Chande Momentum Oscillator is a momentum advanced oscillator derived from a linear regression.
Interpretation:
The growing movement in the value of the CMO may indicate a strong bull movement of the price. On the other hand, falls in the value of the CMO may indicate a strong bear movement. CMO is related to the MACD and the Price Rate of Change (ROC Price).
If the CMO is greater than the upper trigger, then a signal of sell is triggered. If the CMO is greater than the lower trigger, then a buy signal is triggered.
The recommended triggers are -50 and 50.

Cheers,

 

Has this indicator been perfected yet? If not, where can I find a CMO indicator that is useable?

Thanks

Darcy

 
Hello, I too would like to use your Chande oscillator. Do you perhaps have a newer version of the code you posted above (iCMO_1)?
Thank you very much!
Pieter
Reason: