iMAOnArray Help (can't plot MA on Bear Bulls Power Indicator)

 
Hi to all MQL4 community!

This is my very first post here looking for help because by this days i'm trying to customize this "Bears Bulls Power" indicator made by Waddah Attar adding to it a moving average but with no fortune yet...

I read many articles about iMAOnArray and i understand the function,but when i try to make it work on this indicator,it doesn't plot anything...

I tried to preserve the original structure of the code and only to incorporate the required lines according to the theory but as i said before...no luck till now...where is the mistake??....what's wrong?...please,any help will be very valuable.


Here is the code...

//+------------------------------------------------------------------+
//|                  Bear_Bulls_Power.mq4                            |
//|         Copyright © 2006, Eng. Waddah Attar                      |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Waddah Attar"
#property link "waddahattar@hotmail.com"
//----
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_color3 White
#property indicator_color4 Yellow
#property indicator_level1 0.0
//----
extern int MyPeriod = 13;
//----
double ExtBuffer1[];
double ExtBuffer2[];

double ExtVvalue[]; // ADDED BUFFER TO DRAW THE MA
double ExtMA[]; // ADDED BUFFER TO DRAW THE MA
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(4);

SetIndexBuffer(0, ExtBuffer1);
SetIndexStyle(0,DRAW_HISTOGRAM,0,2);
//----
SetIndexBuffer(1, ExtBuffer2);
SetIndexStyle(1,DRAW_HISTOGRAM,0,2);
//----
SetIndexBuffer(2, ExtVvalue);
SetIndexStyle(2,DRAW_LINE,0,2);
//----
SetIndexBuffer(3, ExtMA);
SetIndexStyle(3,DRAW_LINE,0,2);


//----
IndicatorShortName("Bear_Bulls_Power (" + MyPeriod + ") ");
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
double ma, pBears ,pBulls ,v;
int i, limit;
int counted_bars = IndicatorCounted();
if(counted_bars < 0)
return(-1);
if(counted_bars > 0)
counted_bars--;
limit = Bars - counted_bars;

for(i = 0; i < limit; i++)
{
ma = iMA(NULL, 0, MyPeriod, 0, MODE_EMA, PRICE_CLOSE, i);
pBulls = High[i] - ma;
pBears = Low[i] - ma;
v = (pBears + pBulls) / 2;
if(v >= 0)             
{
ExtBuffer1[i] = v;
ExtBuffer2[i] = 0;
ExtVvalue[i] = v;// It doesn't matter if v>0 or not...i save all values in this buffer for future MA calculation...
}
else
{
ExtBuffer1[i] = 0;
ExtBuffer2[i] = v;
ExtVvalue[i] = v;// It doesn't matter if v>0 or not...i save all values in this buffer for future MA calculation...    
}

}

for(i = 0; i < limit; i++)
{
ExtMA[i]= iMAOnArray(ExtVvalue,0,15,0,MODE_EMA,i);
}
return(0);
}
//+------------------------------------------------------------------+

Many thanks in advance!!

Best Regards.
 
Norbert:
Hi to all MQL4 community!

This is my very first post here looking for help because by this days i'm trying to customize this "Bears Bulls Power" indicator made by Waddah Attar adding to it a moving average but with no fortune yet...

I read many articles about iMAOnArray and i understand the function,but when i try to make it work on this indicator,it doesn't plot anything...

I tried to preserve the original structure of the code and only to incorporate the required lines according to the theory but as i said before...no luck till now...where is the mistake??....what's wrong?...please,any help will be very valuable.


Here is the code...


Many thanks in advance!!

Best Regards.


hmm, works in my termina!

 
FWIW, working here too. Looks just like the picture above.
 

EADeveloper and sj1!!

Many many thanks for your replies.In fact,after seeing your answers and trying to remember which error i could have made,i realize that what happened to me was a newbie mistake...these are my first tries in programming...i apologize.

It was late at night and after trying and trying and trying with no good results,i decided to post the problem...but before, i made maybe the last correction to it (saw a difference in a value) without probing the indicator one more time... was tired...

This was the correction...

//+------------------------------------------------------------------+
//|                  Bear_Bulls_Power.mq4                            |
//|         Copyright © 2006, Eng. Waddah Attar                      |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Waddah Attar"
#property link "waddahattar@hotmail.com"
//----
#property indicator_separate_window
#property indicator_buffers 3   <-- WAS WRITTEN 3 INSTEAD OF 4...
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_color3 White
#property indicator_color4 Yellow
#property indicator_level1 0.0
//----
extern int MyPeriod = 13;
//----
double ExtBuffer1[];
double ExtBuffer2[];

double ExtVvalue[]; // ADDED BUFFER TO DRAW THE MA
double ExtMA[]; // ADDED BUFFER TO DRAW THE MA
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(4); 

...then the EMA appeared on the chart...I apologize again for this stupid rookie bug.

Thank you very much!

Best regards.

Reason: