Oh brother... Look at the bottom of the screen. Do u see this ->
OK? So either attach the source as a mq4/mqh file or use the SRC button to post the code.
if((current>prev)&&((current<0))trend = 1
seems a bit faulty for starters. It gives me
'\end_of_program' - unbalanced left parenthesis
Is this what you mean when you say "am having problems with its coding, an simple possible error, due to which the indicator is not drawing bars."
seems a bit faulty for starters. It gives me
'\end_of_program' - unbalanced left parenthesis
Is this what you mean when you say "am having problems with its coding, an simple possible error, due to which the indicator is not drawing bars."
Every if, should begin and end with parenthesis that's why you get an error here:
if((current>prev)&&((current<0))trend = 1
It should be or
if (current>prev && current<0) trend = 1
or
if ((current>prev) && (current<0)) trend = 1
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello friends this is checkmail and am creating an emacross histogram and am almost done but am having problems with its coding, an simple possible error, due to which the indicator is not drawing bars.
And signal on charts(up/down) .
Hope this won't be too much as this might improve our trades a lot.
Here's the code :
#property copyright "EMACROSSHISTOGRAM"
#property link "emacrosshist"
//---- indicator settings
#property indicator_separate_window
#property indicator_minimum -0.5
#property indicator_maximum 1.05
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
//---- indicator parameters
//---- indicator buffers
double UpBuffer1[];
double UpBuffer2[];
double ind_buffer1[];
extern int ema1 = 10;
extern int ema2 = 25;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(3);
//---- drawing settings
SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,2);
SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,2);
SetIndexBuffer(0,UpBuffer1);
SetIndexBuffer(1,UpBuffer2);
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+2);
SetIndexBuffer(2,ind_buffer1);
//---- name for DataWindow and indicator subwindow label
IndicatorShortName("EMACROSSHIST");
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| Moving Average of Oscillator |
//+------------------------------------------------------------------+
int start()
{
int limit;
int trend;
double current,prev;
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--;
limit=Bars-counted_bars;
//---- Bar counted in the 1-st add buffer
for(int i=0; i<limit; i++)
ind_buffer1[i]=iMA(NULL,0,ema1,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,ema2,0,MODE_EMA,PRICE_CLOSE,i);
for(i=limit-1; i>=0; i--)
{
UpBuffer1[i]=0;
UpBuffer2[i]=0;
current=ind_buffer1[i];
prev=ind_buffer1[i+1];
if((current>prev)&&(current>0)) trend = 2;
if((current>prev)&&((current<0))trend = 1;
if((current<prev)) trend = 1;
if(trend==2)
{
UpBuffer1[i]=1;
UpBuffer2[i]=0;
}
if(trend==1)
{
UpBuffer1[i]=0;
UpBuffer2[i]=1;
}
}
//---- done
return(0);
}
//+------------------------------------------------------------------+