//try this if(Buffer3[i+1]<0 && Buffer3[i]>0) { BuyAlert[i]=Buffer2[i]; } if(Buffer3[i+1]>0 && Buffer3[i]<0) { SellAlert[i]=Buffer1[i]; }
or
if(Buffer3[i+1]<0 && Buffer3[i]>0) { BuyAlert[i]=Buffer1[i]-0.001; } if(Buffer3[i+1]>0 && Buffer3[i]<0) { SellAlert[i]=Buffer2[i]+0.001; }
something like that
ismail.hussein:
And last but not least, is it possible to add this in the main chart window?
not in this indicator because #property indicator_separate_window
Thanks a lot for your quick reply, the first proposal works great, you rock!!
Concerning the display on the main chart, I know that I have to put iindicator_chart_window, but if I do so, nothing get displayed...
Is it because of the DRAW_HISTOGRAM??
Thanks in advance
No one to finalize my problem? ;)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Dear all,
I have kind of weird issue. I'm trying to display arrows on MACD indicator to display buy or sell signal.
Basically, I've updated an MACD indicator code, and in the result, my arrows are displayed in the top of the separate window.
So the lines and histogram are so small, as in the pictures below, Especially in the M5 one :
Here's my code:
#property indicator_separate_window
#property indicator_buffers 5
#property indicator_color1 White
#property indicator_color2 Red
#property indicator_color3 Blue
#property indicator_color4 Green
#property indicator_color5 Red
// extern variables
extern int Fast = 12;
extern int Slow = 26;
extern int Signal = 9;
// buffers
double Buffer1[];
double Buffer2[];
double Buffer3[];
double BuyAlert[];
double SellAlert[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,2);
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1);
SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,1);
SetIndexStyle(3,DRAW_ARROW);
SetIndexStyle(4,DRAW_ARROW);
SetIndexBuffer(0,Buffer3);
SetIndexBuffer(1,Buffer2);
SetIndexBuffer(2,Buffer1);
SetIndexBuffer(3,BuyAlert);
SetIndexBuffer(4,SellAlert);
SetIndexArrow(3,241);
SetIndexArrow(4,242);
SetIndexLabel(3,"Buy Alert");
SetIndexLabel(4,"Sell Alert");
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
for(int i=Bars;i>=0;i--){
Buffer1[i]=iMACD(NULL,0,Fast,Slow,Signal,PRICE_CLOSE,MODE_MAIN,i);
Buffer2[i]=iMACD(NULL,0,Fast,Slow,Signal,PRICE_CLOSE,MODE_SIGNAL,i);
Buffer3[i]=Buffer1[i] - Buffer2[i];
if(Buffer3[i+1]<0 && Buffer3[i]>0)
{
BuyAlert[i]=Close[i];
}
if(Buffer3[i+1]>0 && Buffer3[i]<0)
{
SellAlert[i]=Close[i];
}
}
return(0);
}
//+------------------------------------------------------------------+
And last but not least, is it possible to add this in the main chart window?
Thanks for your help!!!