igorad:
This part of code must have this look:
This part of code must have this look:
//---- indicators
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,159);
SetIndexBuffer(0,MACDUp);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,159);
SetIndexBuffer(1,MACDDown);
//----Thanks for the catch, Igorad. I've made the correction.
Once I attach this to a chart, should it not add the up/down arrows to all previous points in the chart where the trade signal would have been triggered? I guess I'm looking for it to indicate where I should have bought/sold to confirm that it is working correctly. Is this not how it should work?
Thanks,
Ian
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
Hi,
I put this MACD signal indicator together from various pieces/parts others had already done but it doesn't seem to be working. I get no up/down arrows nor alerts when I load it to a chart.![](https://c.mql5.com/forextsd/smiles/embaressed_smile.png)
Could someone please take a quick look and let me know what I've done wrong?
Thanks!
- Ian
//+------------------------------------------------------------------+
//| MACD Signal.mq4 |
//| Ian Boersma |
//| iboersma@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Ian Boersma"
#property link "iboersma@gmail.com"
#property indicator_buffers 2
#property indicator_color1 LimeGreen
#property indicator_color2 Red
#property indicator_chart_window
double MACDUp[];
double MACDDown[];
extern int FastEMA=12;
extern int SlowEMA=26;
extern int SignalSMA=9;
extern int MATrendPeriod=26;
extern int MACDOpenLevel=4;
extern int MACDCloseLevel=2;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,159);
SetIndexBuffer(0,MACDUp);
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,159);
SetIndexBuffer(0,MACDDown);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start() {
int limit, i, counter;
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;
for(i = 0; i <= limit; i++)
//----
double MacdCurrent = iMACD(Symbol(),0,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_MAIN,i);
double SignalCurrent = iMACD(Symbol(),0,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_SIGNAL,i);
double MacdPrevious = iMACD(Symbol(),0,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_MAIN,i+1);
double SignalPrevious = iMACD(Symbol(),0,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_SIGNAL,i+1);
double MaCurrent=iMA(NULL,0,MATrendPeriod,0,MODE_EMA,PRICE_CLOSE,i);
double MaPrevious=iMA(NULL,0,MATrendPeriod,0,MODE_EMA,PRICE_CLOSE,i+1);
if(MacdCurrentSignalCurrent && MacdPrevious<SignalPrevious &&
MathAbs(MacdCurrent)>(MACDOpenLevel*Point) && MaCurrent>MaPrevious)
{
MACDUp = Close;
Alert(Symbol()+" MACD moving UP!");
SendMail(Symbol()+" MACD moving UP!","Better enter a BUY order!");
}
else if(MacdCurrent>0 && MacdCurrentSignalPrevious &&
MacdCurrent>(MACDOpenLevel*Point) && MaCurrent<MaPrevious)
{
MACDDown = Close;
Alert(Symbol()+" MACD moving DOWN!");
SendMail(Symbol()+" MACD moving DOWN!","Better enter a SELL order!");
}
//----
return(0);
}
//+--------------