Download MetaTrader 5
To add comments, please log in or register
Publish your task in Freelance service and developers will execute your order.
philipngcc 2014.08.01 20:24 

Help needed ,

I have a Expert advisor that need to read the crossing of Moving Average from a CCI[14] . I have two Moving average of 2 and 7 which i applied using  first indicator's data to the CCI[14].

From this link the only way to read the MA value is to create a custoCCIm indicator and then use iCustom to read the value.

I having problem creating the custom indicator where the lines draw not the same as original. Refer to the diagram below




 I have attached my custom indicator coding below. Anyone can enlighten me what is wrong. How come my Moving average value not the same as the built in original which i drag from Navigator 




//|                                                       CCI_MA.mq4 |

//|                      Copyright © 2009, MetaQuotes Software Corp. |

//|                               |


#property copyright "Copyright © 2009, MetaQuotes Software Corp."

#property link      ""

#property indicator_separate_window

#property indicator_buffers 3

#property indicator_color1 MediumSpringGreen

#property indicator_color2 Red

#property indicator_color3 Yellow

#property indicator_level1 -100

#property indicator_level2 100


//---- input parameters

extern int cci_p = 14;

extern int ma = 7;

extern int ma2 = 2;

int NumberOfBarsToCalculate = Bars-IndicatorCounted();


//---- indicator buffers

double Buffer0[];

double Buffer1[];

double Buffer2[];

double Ma[];

double Ma2[];

double Cci[];



//| Custom indicator initialization function                         |


  int init()




//---- indicator line






























int start() {

      string short_name;

      NumberOfBarsToCalculate = Bars-IndicatorCounted();

      short_name = "MyCustom CCI with MA2MA7["+cci_p+"] "; 


        int shift;

         int limit;

         int counted_bars=IndicatorCounted();


         //---- check for possible errors

         if(counted_bars<0) return(-1);


         //---- last counted bar will be recounted

         if(counted_bars>0) counted_bars--;



         //--- main loops 1 and 2

         for(shift=0; shift < limit; shift++)


              Cci[shift] = iCCI(NULL,0,cci_p,PRICE_TYPICAL,shift);    

              Buffer0[shift] = Cci[shift];



         for(shift=0; shift < limit; shift++)


               Ma[shift] = iMAOnArray(Cci,0,ma,0,MODE_EMA,shift);

               Ma2[shift] = iMAOnArray(Cci,0,ma2,0,MODE_EMA,shift);

               Buffer1[shift] = Ma[shift];

               Buffer2[shift] = Ma2[shift];





philipngcc 2014.08.04 16:30  

Ignore the above.. The reading is tally now  .

whroeder1 2014.08.05 13:52  
Don't paste code
Play video
Please edit your post.
For large amounts of code, attach it.
To add comments, please log in or register