Finding the intersection point

sunshineh  
Hi,
I have fond the following indicator:

#property copyright "Kalenzo"
#property link      "bartlomiej.gorski@gmail.com"
#property indicator_color1 DodgerBlue
#property indicator_color2 Lime
#property indicator_buffers 2

extern int MoMPeriod = 14;
extern int MaType = MODE_EMA;
extern int MaPeriod = 50;
extern int TimeFrame = 60;

double mom[],
       ema[],
       momTF[],
       emaTF[];
       
#property indicator_separate_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorBuffers(4);
   
   SetIndexBuffer(0,mom);
   SetIndexBuffer(1,ema);
   
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1);
   
   SetIndexBuffer(2,momTF);
   SetIndexBuffer(3,emaTF);
   
   IndicatorShortName("MTF Momentum "+tf());
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   
//----
     int bbshift,limit,limitTF;
     limit=Bars;
     limitTF = iBars(Symbol(),TimeFrame);
     
     for(int i=0; i<limitTF; i++) momTF[i] = iMomentum(Symbol(),TimeFrame,MoMPeriod,PRICE_CLOSE,i);
     for(int j=0; j<limitTF; j++) emaTF[j] = iMAOnArray(momTF,0,MaPeriod,0,MaType,j);
     
     for(int t=0; t<limit; t++)
     {
         bbshift = iBarShift(Symbol(),TimeFrame,Time[t]);
         mom[t] = momTF[bbshift];
         ema[t] = emaTF[bbshift];
     }

//----
   return(0);
  }  

But I can't get the intersection point from this two lines with my ea, even I can't get the right value from the indicator, which is displayed.

I can calculate the normal Momentum-value with the indicator function, but how could I calculate the real value over the momTF-Array in my ea?


Tjipke de Vries  
indicator_buffers 2

Did you try iCustom ??

and if so how did you use that function inside your EA for this indicator ??

sunshineh  

I tried this in my ea, but the values were wrong:

double x1= iCustom(NULL,0,"MOM_EMA_MTF",14,MODE_EMA,50,60,0,0);     
double x2=iCustom(NULL,0,"MOM_EMA_MTF",14,MODE_EMA,50,60,0,10);
double y1=iCustom(NULL,0,"MOM_EMA_MTF",14,MODE_EMA,50,60,1,0);
double y2=iCustom(NULL,0,"MOM_EMA_MTF",14,MODE_EMA,50,60,1,10);
Tjipke de Vries  
sunshineh:

I tried this in my ea, but the values were wrong:

You are using iCustom correctly,

but you can make your problem more clear if you show this with picture of the chart attached the indicator

(momentum with calculated average momentum) and the values you read in your EA

I think the problem is you are calculating values of bar 0 This is changing every tick.

Also iMAOnArray(momTF,0,MaPeriod,0,MaType,j); is that way not a constant value

and why do you compare value bar 0 with the value of bar 10.

Wouldn't it be the intersection will happen in two following bars ??

Reason: