Author: Coders Guru
JMA_alert
Miscellaneous
Implements a curve of type %1It issuies visual alerts to the screen
0 Views
0 Downloads
0 Favorites
JMA_alert
//+------------------------------------------------------------------+
//| CrossedAlerts.mq4 |
//| Coders Guru |
//| Newdigital (just use the Codersguru code for JMA alert.
//| 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
extern int Length_slow = 7;
extern int Length_fast = 5;
//---- 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]= iCustom(NULL,0,"JMA",Length_slow,0,1,pos);

ExtMapBuffer2[pos]= iCustom(NULL,0,"JMA",Length_fast,0,1,pos);


pos--;
}



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


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



Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---