Moving average of Momentum

 
I am still thinking about connection of two indicators. I need count moving average of momentum in my code for Expert Advisor. When I made a custom indicator, it was fine, I calculated momentum in buffer and then I used iMA for counting MA of momentum. But in Expert Advisor it dosn't work. I attach my code.

//+------------------------------------------------------------------+
//|                                               MA of Momentum.mq4 |
//|                                          Copyright © 2005, Milan |
//|                                                                  |
//+------------------------------------------------------------------+
#property indicator_buffers 1

//---- input parameters
extern int       MomPer=20;
extern int       MA1Per=13;

double           MomBuffer[];

//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
{
int i,limit;
   int counted_bars=IndicatorCounted();
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
   for(i=0; i<limit; i++)
      MomBuffer[i]=iMomentum(NULL,0,MomPer,PRICE_CLOSE,i);
   return(0);//----
//----
 
double MA1curr;

MA1curr = iMAOnArray(MomBuffer,Bars,MA1Per,0,MODE_EMA,0);
   return(0);
  }
//+------------------------------------------------------------------+



This code is without trading function, in reality is with. Could somebody help me?

 
Indicator dos not trade. You need write indicator, and then call it in your expert advisor.
 
Than you for your answer. I thought, I type the code of indicator to the Expert and it will observe crossing of two values from result of counting of indicator Momentum and Moving average of momentum. Something like MACD with signal line. Thereby, I supposed, I count Momentum, then MA of Momentum and compare the result. If Mom<MA sell, opposite buy. Doesn't it the way?
But, MA can count from price or buffer only. I developed this indicator and work properly, but I still don't know, how it add to the Expert Advisor.
Milan
 
Call iCustom(NULL,0,"YourIndicatorName",other_parameters,index,shift)

see help on iCustom
 
Thank a lot.
Milan