My indicators, and issues I have with iCustom(...)

 

I have finished my indicators, although I would like to add minimums and maximums, but my main issue is writing out the code for their iCustom(...)s, so that I can use them in my EA.

Pressurised Market Buy(Downward Bias)

//+------------------------------------------------------------------+
//|                       Pressurised Market Buy (Downward Bias).mq4 |
//|                                                       Luciano. E |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Luciano .E"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Blue
//#property indicator_color2 Green 
double MBMPD[];
double MarketPressure[];
double MarketBias[];
extern int InPeriod = 20;
double pips;


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
  
  double ticksize = MarketInfo(Symbol(), MODE_TICKSIZE);
  if (ticksize == 0.00001 || ticksize == 0.001)
  pips = ticksize*10;
  else pips =ticksize;
  
   SetIndexBuffer(0,MBMPD);
   SetIndexStyle(0,DRAW_HISTOGRAM,EMPTY,2,Blue);
   SetIndexLabel(0,"Market Bias/Market Pressure Difference");
   SetIndexDrawBegin(0,InPeriod+3);   
   /*SetIndexBuffer(1,MarketPressure);
   SetIndexStyle(1,DRAW_HISTOGRAM,EMPTY,2,Green);
   SetIndexLabel(1,"MarketPressure");
   SetIndexDrawBegin(1,202);*/
   
   
  
   
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   
   
   int counted_bars=IndicatorCounted();
   if(counted_bars<0)return(-1);
   if(counted_bars>0)counted_bars--;
   int uncountedbars=Bars-counted_bars; 
   
//- ---


for(int i=0;i<uncountedbars;i++)
    
   {
      if((iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i+1)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i+1))/(iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i+2)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i+2))<1 && (iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i+1)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i+1))<1)
      MBMPD[i]   =(iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i))/1*pips/1*pips;

else  if((iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i+1)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i+1))/(iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i+2)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i+2))>=1 && (iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i+1)-iMA(NULL,0,InPeriod, 0,MODE_SMMA,PRICE_OPEN,i+1))<1)
      MBMPD[i]   =(iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i))/1*pips/(iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i+1)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i+1))/(iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i+2)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i+2));

else if((iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i+1)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i+1))/(iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i+2)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i+2))<1 && (iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i+1)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i+1))>=1)
      MBMPD[i]   =(iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i))/(iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i+1)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i+1))/(iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i+1)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i+1))/1*pips;
   }
   
    
   
/*for(int j=0;j<uncountedbars;j++)

   {
      
      MarketPressure[j] =(iMA(NULL,0,200,0,MODE_SMMA,PRICE_HIGH,j)-iMA(NULL,0,200,0,MODE_SMMA,PRICE_OPEN,j))/(iMA(NULL,0,200,0,MODE_SMMA,PRICE_HIGH,j+1)-iMA(NULL,0,200,0,MODE_SMMA,PRICE_OPEN,j+1));
   }*/
      


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

Pressurised Market Sell(Downward Bias)

//+------------------------------------------------------------------+
//|                        Pressurised Market Sell (Upward Bias).mq4 |
//|                                                       Luciano. E |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Luciano .E"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Red
//#property indicator_color2 Green 
double MBMPD[];
double MarketPressure[];
double MarketBias[];
extern int InPeriod = 20;
double pips;


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
  
  double ticksize = MarketInfo(Symbol(), MODE_TICKSIZE);
  if (ticksize == 0.00001 || ticksize == 0.001)
  pips = ticksize*10;
  else pips =ticksize;
  
   SetIndexBuffer(0,MBMPD);
   SetIndexStyle(0,DRAW_HISTOGRAM,EMPTY,2,Blue);
   SetIndexLabel(0,"Market Bias/Market Pressure Difference");
   SetIndexDrawBegin(0,InPeriod+3);   
   /*SetIndexBuffer(1,MarketPressure);
   SetIndexStyle(1,DRAW_HISTOGRAM,EMPTY,2,Green);
   SetIndexLabel(1,"MarketPressure");
   SetIndexDrawBegin(1,202);*/
   
   
  
   
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   
   
   int counted_bars=IndicatorCounted();
   if(counted_bars<0)return(-1);
   if(counted_bars>0)counted_bars--;
   int uncountedbars=Bars-counted_bars; 
   
//- ---


for(int i=0;i<uncountedbars;i++)
    
   {
      if((iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i+1)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i+1))/(iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i+2)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i+2))<1 && (iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i+1)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i+1))<1)
      MBMPD[i]   =(iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i))/1*pips/1*pips;

else  if((iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i+1)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i+1))/(iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i+2)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i+2))>=1 && (iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i+1)-iMA(NULL,0,InPeriod, 0,MODE_SMMA,PRICE_CLOSE,i+1))<1)
      MBMPD[i]   =(iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i))/1*pips/(iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i+1)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i+1))/(iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i+2)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i+2));

else if((iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i+1)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i+1))/(iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i+2)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i+2))<1 && (iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i+1)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i+1))>=1)
      MBMPD[i]   =(iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i))/(iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i+1)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i+1))/(iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i+1)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i+1))/1*pips;
   }
   
    
   
/*for(int j=0;j<uncountedbars;j++)

   {
      
      MarketPressure[j] =(iMA(NULL,0,200,0,MODE_SMMA,PRICE_HIGH,j)-iMA(NULL,0,200,0,MODE_SMMA,PRICE_OPEN,j))/(iMA(NULL,0,200,0,MODE_SMMA,PRICE_HIGH,j+1)-iMA(NULL,0,200,0,MODE_SMMA,PRICE_OPEN,j+1));
   }*/
      


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

My iCustom() lines.

PMB             = iCustom(NULL,0,"Pressurised Market Buy(Downward Bias)",20,0,1);
PMS             = iCustom(NULL,0,"Pressurised Market Sell(Upward Bias)",20,0,1);

Atm my ea can't seem to grab the values, I tried it without the external values (the,20,). so did I write the iCustom() incorrectly?

 
MetaNt:

I have finished my indicators, although I would like to add minimums and maximums, but my main issue is writing out the code for their iCustom(...)s, so that I can use them in my EA.

Pressurised Market Buy(Downward Bias)

Pressurised Market Sell(Downward Bias)

My iCustom() lines.

Atm my ea can't seem to grab the values, I tried it without the external values (the,20,). so did I write the iCustom() incorrectly?

Your iCustom() calls look OK, what value do you get from then compared to what you see with your Indicators on a chart and looking at it's values with the Data Window ?
 
Well I doesn't seem to be receiving any values, when I load the indicator onto the chart it gives values however, the EA can not act on them, or at least this is what the situation appears to be. It keeps getting the value 0.
 
There is a zero divide in my code.
 
MetaNt: There is a zero divide in my code.
  1. Are your books one column but two feet wide? No because that is unreadable. They are 6 inches, sometimes two columns, so you can read it easily. So should be your code. I'm not going to go scrolling back and forth trying to read it. Edit the post with formatted code and you might get additional help.
  2. So find it and prevent it.
    What is value * pips * pips ?
    x)/1*pips/1*pips;
    (x)*pips/1*pips;
    (x)*pips*pips;
    What happens if when you get a doji?
    (x)/(iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i+2)
        -iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i+2)
 
WHRoeder:
  1. Are your books one column but two feet wide? No because that is unreadable. They are 6 inches, sometimes two columns, so you can read it easily. So should be your code. I'm not going to go scrolling back and forth trying to read it. Edit the post with formatted code and you might get additional help.
  2. So find it and prevent it.
    What is value * pips * pips ?
    What happens if when you get a doji?


It was a bit of a rush job, hence the lack of defined variables in place of iMA. It looks like in my hope of avoiding work I have to fix problems that never would have arisen. Sorry for the cumbersome code.

 

Gosh I'm still getting zero divide.

Edit: I think I know what the problem is actually.

//+------------------------------------------------------------------+
//|                       Pressurised Market Buy (Downward Bias).mq4 |
//|                                                       Luciano. E |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Luciano .E"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Blue
//#property indicator_color2 Green 
double MBMPD[];
double MarketPressure[];
double MarketBias[];
extern int InPeriod = 20;
double pips;
double Bulk0[];
double Bulk1[];
double Bulk2[];


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
  
  double ticksize = MarketInfo(Symbol(), MODE_TICKSIZE);
  if (ticksize == 0.00001 || ticksize == 0.001)
  pips = ticksize*10;
  else pips =ticksize;
  
   SetIndexBuffer(0,MBMPD);
   SetIndexStyle(0,DRAW_HISTOGRAM,EMPTY,2,Blue);
   SetIndexLabel(0,"Market Bias/Market Pressure Difference");
   SetIndexDrawBegin(0,InPeriod+3);   
   /*SetIndexBuffer(1,MarketPressure);
   SetIndexStyle(1,DRAW_HISTOGRAM,EMPTY,2,Green);
   SetIndexLabel(1,"MarketPressure");
   SetIndexDrawBegin(1,202);*/
   
   
  
   
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   
   
   int counted_bars=IndicatorCounted();
   if(counted_bars<0)return(-1);
   if(counted_bars>0)counted_bars--;
   int uncountedbars=Bars-counted_bars; 
   
   
 

   
   
//- ---

for(int i=0;i<uncountedbars;i++)
    
   {   
     Bulk0[i]=(iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i));
     Bulk1[i]=(iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i+1)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i+1));
     Bulk2[i]=(iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i+2)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i+2));
     
     if(Bulk1[i]==0 )Bulk1[i]=1;
     else Bulk1[i]=(iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i+1)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i+1));
     
     if(Bulk2[i]==0)Bulk2[i]=1;
     else Bulk2[i]=(iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i+2)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i+2));
     
     
     
     
     MBMPD[i]=(Bulk0[i]/Bulk1[i])/(Bulk1[i]/Bulk2[i]); 
   }


   return(0);
  }
 

Ok no more zero divide, but I'm not getting any values loaded up.

//+------------------------------------------------------------------+
//|                       Pressurised Market Buy (Downward Bias).mq4 |
//|                                                       Luciano. E |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Luciano .E"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Blue
//#property indicator_color2 Green 
double MBMPD[];
double MarketPressure[];
double MarketBias[];
extern int InPeriod = 20;
double pips;
double Bulk0[];
double Bulk1[];
double Bulk2[];


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
  
  double ticksize = MarketInfo(Symbol(), MODE_TICKSIZE);
  if (ticksize == 0.00001 || ticksize == 0.001)
  pips = ticksize*10;
  else pips =ticksize;
  
   SetIndexBuffer(0,MBMPD);
   SetIndexStyle(0,DRAW_HISTOGRAM,EMPTY,2,Blue);
   SetIndexLabel(0,"Market Bias/Market Pressure Difference");
   SetIndexDrawBegin(0,InPeriod+3);   
   /*SetIndexBuffer(1,MarketPressure);
   SetIndexStyle(1,DRAW_HISTOGRAM,EMPTY,2,Green);
   SetIndexLabel(1,"MarketPressure");
   SetIndexDrawBegin(1,202);*/
   
   
  
   
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   
   
   int counted_bars=IndicatorCounted();
   if(counted_bars<0)return(-1);
   if(counted_bars>0)counted_bars--;
   int uncountedbars=Bars-counted_bars; 
   
   
 

   
   
//- ---

for(int i=0;i<uncountedbars;i++)
    
   {   
     Bulk0[i]=(iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i));
     Bulk1[i]=(iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i+1)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i+1));
     Bulk2[i]=(iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i+2)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i+2));
     
     if(Bulk1[i]!=0 && Bulk2[i]!=0)
     {
     MBMPD[i]=(Bulk0[i]/Bulk1[i])/(Bulk1[i]/Bulk2[i]); 
     }
     else
     {
     MBMPD[i]=Bulk0[i]/1*pips;
     }
   }


   return(0);
  }
//+------------------------------------------------------------------+
 
  1. Print out your variables and find out why.
  2. MBMPD[i]=(Bulk0[i]/Bulk1[i])/(Bulk1[i]/Bulk2[i]); 
    MBMPD[i]=Bulk0[i]/Bulk1[i]/Bulk1[i]*Bulk2[i]
    MBMPD[i]=Bulk0[i]*Bulk2[i]/(Bulk1[i]*Bulk1[i])   // All the same but any meaning?
    
    MBMPD[i]=Bulk0[i]/1*pips;
    MBMPD[i]=Bulk0[i]*pips;
             ^ average difference between open and close e.g. 20 pips= 0.0020
                     ^ 0.0001
    ^ Result = 0.00000 (to 5 digits)
  3. Bulk0[i]=(iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i)-iMA(NULL,0,​InPeriod,​0,​MODE_SMMA,​PRICE_OPEN,​i));
    Bulk1[i]=(iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i+1)-iMA(NULL,0,​InPeriod,​0,​MODE_SMMA,PRICE_OPEN,​i+1));
    Bulk2[i]=(iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i+2)-iMA(NULL,0,​InPeriod,​0,​MODE_SMMA,​PRICE_OPEN,​i+2));
    Isn't Bulk1[i] == Bulk0[i+1] always? Isn't Bulk2[i] == Bulk0[i+2] always? Substitute and simplify KISS
 
WHRoeder:
  1. Print out your variables and find out why.
  2. Bulk0[i]=(iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i)-iMA(NULL,0,​InPeriod,​0,​MODE_SMMA,​PRICE_OPEN,​i));
    Bulk1[i]=(iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i+1)-iMA(NULL,0,​InPeriod,​0,​MODE_SMMA,PRICE_OPEN,​i+1));
    Bulk2[i]=(iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i+2)-iMA(NULL,0,​InPeriod,​0,​MODE_SMMA,​PRICE_OPEN,​i+2));
    Isn't Bulk1[i] == Bulk0[i+1] always? Isn't Bulk2[i] == Bulk0[i+2] always? Substitute and simplify KISS


Ouch, and thanks. I get chart results when i use iMA directly but not when I use bulk, it's almost as if Bulk for i isn't getting calculated before the indicator array gets calculated.

Bulk0[i] = 0.

Bulk0[i] !=0 ; but MBMPD get's calculated before Bulk0[i].

Hold on I'm going to fix this thing.

 

Ok I've gotten rid of the zero divides and the Rate of Rate of Increase (RRI) amplifiers (basically tick size values that give too much weight to pip size values) and so far it's working on the chart, I haven't tested it with the EA, I need to go back to the drawing board to take a look at the logic behind the indicator concept itself.

//+------------------------------------------------------------------+
//|                       Pressurised Market Buy (Downward Bias).mq4 |
//|                                                       Luciano. E |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Luciano .E"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Blue
//#property indicator_color2 Green 
double MBMPD[];
double MarketPressure[];
double MarketBias[];
extern int InPeriod = 20;
double pips;
double Bulk0[];
double Bulk1[];
double Bulk2[];


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
  
  double ticksize = MarketInfo(Symbol(), MODE_TICKSIZE);
  if (ticksize == 0.00001 || ticksize == 0.001)
  pips = ticksize*10;
  else pips =ticksize;
  
   SetIndexBuffer(0,MBMPD);
   SetIndexStyle(0,DRAW_HISTOGRAM,EMPTY,2,Blue);
   SetIndexLabel(0,"Market Bias/Market Pressure Difference");
   SetIndexDrawBegin(0,InPeriod+3);   
   /*SetIndexBuffer(1,MarketPressure);
   SetIndexStyle(1,DRAW_HISTOGRAM,EMPTY,2,Green);
   SetIndexLabel(1,"MarketPressure");
   SetIndexDrawBegin(1,202);*/
   
   
  
   
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   
   
   int counted_bars=IndicatorCounted();
   if(counted_bars<0)return(-1);
   if(counted_bars>0)counted_bars--;
   int uncountedbars=Bars-counted_bars; 
   
   
 


//- ---

for(int i=0;i<uncountedbars;i++)
    
   {   
     
    
     
     if((iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i+1)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i+1))>=1*pips && (iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i+2)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i+2))>=1*pips)
     {                                        
                            ////////////////////////////////////////////////////////////Rate of Rate of Increase Current///////////////////////////////////////////////////////////////                           
    //          Rate of Increase Current                                                                       Rate of Increase Previous                                                                                                                                                      
     MBMPD[i]=((iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i))/(iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i+1)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i+1)))
     
     - //Minus
               ////////////////////////////////////////////////////////////Rate of Rate of Increase Previous///////////////////////////////////////////////////////////////        
     //        Rate of Increase Previous                                                                           Rate of Increase Historical
              ((iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i+1)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i+1))/(iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i+2)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i+2)));
     }
     else
     { 
     MBMPD[i]=(iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_CLOSE,i)-iMA(NULL,0,InPeriod,0,MODE_SMMA,PRICE_OPEN,i))/1; 
     }
     
     
   }


   return(0);
  }