Please Login
Advertisement
3rd Party Advertisement
Go Back
3rd Party Advertisement
General Forex Talk Talk with other traders about anything and everything FOREX.
Reply
 
LinkBack (3) Thread Tools Display Modes
3 links from elsewhere to this Post. Click to view. (#1 (permalink))
Old
Agent86's Avatar
Private, 1st Class
 
Default MT4 MACD Alert ? - 10-20-2008, 02:13 PM

Hi

I have downloaded these two .mq4 files for MACD

One of them appears to be the fix for the MT4 because the current MACD does not appear to be correct or perhaps non standard compared to MACD of other charting packages.

Anyhow I want the (MACD Crossover alert) to match the (MACD True)

If anyone could tell me which part of the MACD Crossover I should change to make them correctly please?:

MACD TRUE:
Quote:
//+------------------------------------------------------------------+

//| MACD.mq4 |

//| Copyright 2005, David W. Thomas |

//| mailto:davidwt@usa.net |

//+------------------------------------------------------------------+

// This is the correct computation and display of MACD.

#property copyright "Copyright 2005, David W. Thomas"

#property link "mailto:davidwt@usa.net"



#property indicator_separate_window

#property indicator_buffers 3

#property indicator_color1 Blue

#property indicator_color2 Red

#property indicator_color3 Green



//---- input parameters

extern int FastMAPeriod=12;

extern int SlowMAPeriod=26;

extern int SignalMAPeriod=9;



//---- buffers

double MACDLineBuffer[];

double SignalLineBuffer[];

double HistogramBuffer[];



//---- variables

double alpha = 0;

double alpha_1 = 0;



//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

int init()

{

IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1 );

//---- indicators

SetIndexStyle(0,DRAW_LINE);

SetIndexBuffer(0,MACDLineBuffer);

SetIndexDrawBegin(0,SlowMAPeriod);

SetIndexStyle(1,DRAW_LINE,STYLE_DOT);

SetIndexBuffer(1,SignalLineBuffer);

SetIndexDrawBegin(1,SlowMAPeriod+SignalMAPeriod);

SetIndexStyle(2,DRAW_HISTOGRAM);

SetIndexBuffer(2,HistogramBuffer);

SetIndexDrawBegin(2,SlowMAPeriod+SignalMAPeriod);

//---- name for DataWindow and indicator subwindow label

IndicatorShortName("MACD("+FastMAPeriod+","+SlowMAPeriod+","+SignalMAPeriod+")");

SetIndexLabel(0,"MACD");

SetIndexLabel(1,"Signal");

//----

alpha = 2.0 / (SignalMAPeriod + 1.0);

alpha_1 = 1.0 - alpha;

//----

return(0);

}

//+------------------------------------------------------------------+

//| Custor indicator deinitialization function |

//+------------------------------------------------------------------+

int deinit()

{

//----



//----

return(0);

}

//+------------------------------------------------------------------+

//| Custom indicator iteration function |

//+------------------------------------------------------------------+

int start()

{

int limit;

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(int i=limit; i>=0; i--)

{

MACDLineBuffer[i] = iMA(NULL,0,FastMAPeriod,0,MODE_EMA,PRICE_CLOSE,i) - iMA(NULL,0,SlowMAPeriod,0,MODE_EMA,PRICE_CLOSE,i);

SignalLineBuffer[i] = alpha*MACDLineBuffer[i] + alpha_1*SignalLineBuffer[i+1];

HistogramBuffer[i] = MACDLineBuffer[i] - SignalLineBuffer[i];

}



//----

return(0);

}

//+------------------------------------------------------------------+

MACD Crossover:
Quote:
//+------------------------------------------------------------------+
//| MACD-Crossover_Signal.mq4 |
//+------------------------------------------------------------------+

#property copyright "Copyright 2007, Robert Hill)"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 LimeGreen
#property indicator_color2 Red

double CrossUp[];
double CrossDown[];
extern int FastEMA=12;
extern int SlowEMA=26;
extern int SignalSMA=9;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0, DRAW_ARROW, EMPTY);
SetIndexArrow(0, 233);
SetIndexBuffer(0, CrossUp);
SetIndexStyle(1, DRAW_ARROW, EMPTY);
SetIndexArrow(1, 234);
SetIndexBuffer(1, CrossDown);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start() {
int limit, i, counter;
double MACD_Main, MACD_Signal, MACD_MainPrevious, MACD_SignalPrevious;
double Range, AvgRange;
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++) {

counter=i;
Range=0;
AvgRange=0;
for (counter=i ;counter<=i+9;counter++) {
AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);
}
Range=AvgRange/10;

MACD_Main = iMACD(NULL, 0, FastEMA, SlowEMA, SignalSMA, PRICE_CLOSE, MODE_MAIN, i);
MACD_MainPrevious = iMACD(NULL, 0, FastEMA, SlowEMA, SignalSMA, PRICE_CLOSE, MODE_MAIN, i+1);
MACD_Signal = iMACD(NULL, 0, FastEMA, SlowEMA, SignalSMA, PRICE_CLOSE, MODE_SIGNAL, i);
MACD_SignalPrevious = iMACD(NULL, 0, FastEMA, SlowEMA, SignalSMA, PRICE_CLOSE, MODE_SIGNAL, i+1);


if ((MACD_Signal < MACD_Main) && (MACD_SignalPrevious > MACD_MainPrevious)) {
CrossUp[i] = Low[i] - Range*0.5;
}
else if ((MACD_Signal > MACD_Main) && (MACD_SignalPrevious < MACD_MainPrevious)) {
CrossDown[i] = High[i] + Range*0.5;
}
}
return(0);
}

Basically the MACD Crossover appears to be a little off. The arrows do not appear in sync with the actual crossover. Many of them are correct, however some arrows appear when no MACD True is showing a crossover. ?

I wish the indicator would allow me to make changes from the panel instead of in the script part, but I don't know how. Perhaps as I learn the MQL4 I will know someday.

Please advise
Thanks

Last edited by Agent86 : 10-20-2008 at 02:17 PM.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On

LinkBacks (?)
LinkBack to this Thread: http://www.forexpeacearmy.com/forex-forum/general-forex-talk/3232-mt4-macd-alert.html
Posted By For Type Date
Các chỉ tiêu MT4 | sống kinh doanh ngoại hối tài liệu với tiêu đề ngoại hối, kinh doanh ngoại hối cảnh báo và ngoại hối lịch This thread Refback 01-11-2009 10:06 AM
MT4 Индикаторы | Live Forex Торговые ведомости с Forex новости, торговые сигналы Forex и Forex Календарь This thread Refback 12-29-2008 05:13 PM
MT4 Indicators | Live Forex Trading Statements with Forex Headlines, Forex Trading Alerts and Forex Calendar This thread Refback 12-28-2008 08:49 PM

Similar Threads
Thread Thread Starter Forum Replies Last Post
Trouble shooting a MACD RSI EA MattaMidus General Forex Talk 0 12-04-2009 05:13 AM
ICM and GFX Alert Sibali Scam Alerts Folder 0 11-24-2009 08:56 AM
Macd Moving Average Strategy SXMTrader Forex Trading Systems and Strategies 1 07-10-2009 11:45 AM
Bonari-7 : Alert, Alert !! Scam Ricardo Mendoza Scam Alerts Folder 0 03-17-2009 06:53 AM
Re: MACD onwukarisa Beginners Bootcamp 2 10-14-2008 08:22 AM

Market forecasts, lessons, charts, and forum.
3rd Party Advertisement
© Copyright www.ForexPeaceArmy.com - All Rights Reserved
TM Forex Peace Army, ForexPeaceArmy, FPA, and the FPA Shield Logo are all trademarks of the Forex Peace Army. All rights reserved under US and international law.

LinkBacks Enabled by vBSEO 3.1.0