Forex
Google
New signals service!

Go Back   Forex Trading > Discussion Areas > Metatrader 4


Register in Forex TSD!
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time).
Click here to register and get more information

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-17-2006, 12:58 PM
iboersma's Avatar
Junior Member
 
Join Date: Apr 2006
Posts: 22
iboersma is on a distinguished road
Can someone please check this indicator?

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.

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_C LOSE,MODE_MAIN,i);
double SignalCurrent = iMACD(Symbol(),0,FastEMA,SlowEMA,SignalSMA,PRICE_C LOSE,MODE_SIGNAL,i);
double MacdPrevious = iMACD(Symbol(),0,FastEMA,SlowEMA,SignalSMA,PRICE_C LOSE,MODE_MAIN,i+1);
double SignalPrevious = iMACD(Symbol(),0,FastEMA,SlowEMA,SignalSMA,PRICE_C LOSE,MODE_SIGNAL,i+1);
double MaCurrent=iMA(NULL,0,MATrendPeriod,0,MODE_EMA,PRIC E_CLOSE,i);
double MaPrevious=iMA(NULL,0,MATrendPeriod,0,MODE_EMA,PRI CE_CLOSE,i+1);

if(MacdCurrent<0 && MacdCurrent>SignalCurrent && MacdPrevious<SignalPrevious &&
MathAbs(MacdCurrent)>(MACDOpenLevel*Point) && MaCurrent>MaPrevious)
{
MACDUp[i] = Close[i];
Alert(Symbol()+" MACD moving UP!");
SendMail(Symbol()+" MACD moving UP!","Better enter a BUY order!");
}


else if(MacdCurrent>0 && MacdCurrent<SignalCurrent && MacdPrevious>SignalPrevious &&
MacdCurrent>(MACDOpenLevel*Point) && MaCurrent<MaPrevious)
{
MACDDown[i] = Close[i];
Alert(Symbol()+" MACD moving DOWN!");
SendMail(Symbol()+" MACD moving DOWN!","Better enter a SELL order!");
}
//----
return(0);
}
//+--------------
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-17-2006, 01:37 PM
igorad's Avatar
Senior Member
 
Join Date: Oct 2005
Location: Ukraine
Posts: 793
igorad is on a distinguished road
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);
//----
__________________
Let's improve trade skills together
http://finance.groups.yahoo.com/group/TrendLaboratory
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-17-2006, 02:09 PM
iboersma's Avatar
Junior Member
 
Join Date: Apr 2006
Posts: 22
iboersma is on a distinguished road
Quote:
Originally Posted by igorad
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Check this out!!! tznef Non Related Discussions 15 12-17-2007 08:16 AM
newdigital check !! Baba_master Expert Advisors - Metatrader 4 8 06-21-2007 04:23 PM
How to check for check for currency symbol tak145 Expert Advisors - Metatrader 4 1 05-12-2007 01:16 PM
Can someone check if this EA is done correctly please !! pikachucom Expert Advisors - Metatrader 4 6 04-04-2006 10:34 PM


All times are GMT. The time now is 07:44 PM.



Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.