View Single Post
  #48 (permalink)  
Old 02-01-2006, 05:43 PM
newdigital newdigital is online now
Administrator
 
Join Date: Sep 2005
Posts: 16,819
Blog Entries: 146
newdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud of
Quote:
Originally Posted by image3022
Hi All

Does any know of a JMA cross alert, or can anyone modify a EMA cross alert to a JMA cross alert for me. The alert below works well but not knowing anything about programing I can't change the EMA to JMA (simply replacing the ema with jma does not work). The one below alerts once on cross, I would like it to alert five times before it stops.

//+------------------------------------------------------------------+
//| CrossedAlerts.mq4 |
//| Coders Guru |
//| http://www.forex-tsd.com |
//+------------------------------------------------------------------+
#property copyright "Coders Guru"
#property link "http://www.forex-tsd.com"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_color2 Aqua
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,ExtMapBuffer2);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}

bool Crossed (double line1 , double line2 )
{

static string last_direction = "";
string current_dirction = "";

if(line1>line2)current_dirction = "up";
if(line1<=line2)current_dirction = "down";



if(current_dirction != last_direction)
{
Alert("EMA Cross for "+Symbol()+" on the "+Period()+" minute chart.");
last_direction = current_dirction;
return (true);
}
else
{
return (false);

}

}
int start()
{
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--;

int pos=Bars-counted_bars;



while(pos>=0)
{
ExtMapBuffer1[pos]= iMA(NULL,0,5,0,MODE_EMA,PRICE_CLOSE,pos);

ExtMapBuffer2[pos]= iMA(NULL,0,7,0,MODE_EMA,PRICE_CLOSE,pos);


pos--;
}



Print(Crossed (ExtMapBuffer1[0],ExtMapBuffer2[0]));


//----
return(0);
}
//+------------------------------------------------------------------+




Have a great Day Mark
Mark,

I am not good coder. But seems I did this alert.
I modified the Codersguru code for JMA.

Just insert this JMA_alert indicator to the chart and make sure that you have original JMA indicator in the folder (but not in the chart). So, the JMA_alert only should be attached to the chart.

And you may change the settings. By default it is Length_slow = 7 and Length_fast = 5. But it may be any.
Attached Files
File Type: mq4 JMA.mq4 (10.7 KB, 696 views)
File Type: mq4 JMA_alert.mq4 (2.2 KB, 820 views)
Reply With Quote