// ------------------------------------------------------------------
//| EMA-Crossover_Signal. Mq4 |
//| Copyright © 2005, Jason Robinson (jnrtrading) |
//|
http://www.jnrtading.co.uk |
//p------------------------------------------------------------------
/*
------------------------------------------------------------------
| lets you enter two ema periods and it will then show you at |
| Which point they crossed over. It's more usful on the briefer |
| spans which get obscured by the bars / candlesticks and when |
| the zoom level is outside. Also allows you to take out the emas |
| from the chart. (emas are initially set at 5 and 6) |
------------------------------------------------------------------
*/
#property copyright Copyright © 2005, Jason Robinson (jnrtrading)
#property hyperlink http://www.jnrtrading.co.uk
#property indior_chart_window
#property indior_buffers 2
#property indior_color1 SeaGreen
#property indior_color2 Red
double CrossUp[];
double CrossDown[];
extern int FasterEMA = 5;
extern int SlowerEMA = 13;
extern bool SoundON=false;
double alertTag;
double control=2147483647;
// ------------------------------------------------------------------
//| Custom indior initialization function |
// ------------------------------------------------------------------
int init()
//-- indiors
SetIndexStyle(0, DRAW_ARROW, EMPTY,3);
SetIndexArrow(0, 233);
SetIndexBuffer(0, CrossUp);
SetIndexStyle(1, DRAW_ARROW, EMPTY,3);
SetIndexArrow(1, 234);
SetIndexBuffer(1, CrossDown);
//--
return(0);
// ------------------------------------------------------------------
//| Custom indior deinitialization function |
// ------------------------------------------------------------------
int deinit()
//--
//--
return(0);
// ------------------------------------------------------------------
//| Custom indior iteration function |
// ------------------------------------------------------------------
int start()
int limit, I, counter;
double fasterEMAnow, slowerEMAnow, fasterEMAprevious, slowerEMAprevious, fasterEMAafter, slowerEMAafter;
double Range, AvgRange;
int counted_bars=IndiorCounted();
//-- check for possible errors
if(counted_barslt;0) return(-1);
//-- last counted bar will be recounted
if(counted_barsgt;0) counted_bars--;
limit=Bars-counted_bars;
for(I = 0; I lt;= limit; I )
counter=I;
Range=0;
AvgRange=0;
for (counter=I ;counterlt;=I 9;counter )
AvgRange=AvgRange MathAbs(High[counter]-Low[counter]);
Range=AvgRange/10;
fasterEMAnow = iMA(NULL, 0, FasterEMA, 0, MODE_EMA, PRICE_CLOSE, I);
fasterEMAprevious = iMA(NULL, 0, FasterEMA, 0, MODE_EMA, PRICE_CLOSE, I 1);
fasterEMAafter = iMA(NULL, 0, FasterEMA, 0, MODE_EMA, PRICE_CLOSE, i-1);
slowerEMAnow = iMA(NULL, 0, SlowerEMA, 0, MODE_EMA, PRICE_CLOSE, I);
slowerEMAprevious = iMA(NULL, 0, SlowerEMA, 0, MODE_EMA, PRICE_CLOSE, I 1);
slowerEMAafter = iMA(NULL, 0, SlowerEMA, 0, MODE_EMA, PRICE_CLOSE, i-1);
if ((fasterEMAnow gt; slowerEMAnow) (fasterEMAprevious lt; slowerEMAprevious) (fasterEMAafter gt; slowerEMAafter))
CrossUp[I] = Low[I] - Range*0.5;
else
CrossUp[I] = 0;
else if ((fasterEMAnow lt; slowerEMAnow) (fasterEMAprevious gt; slowerEMAprevious) (fasterEMAafter lt; slowerEMAafter))
CrossDown[I] = High[I] Range*0.5;
else
CrossDown[I] = 0;
if (SoundON==true I==1 CrossUp[I] gt; CrossDown[I] alertTag! =Timing[0])
Alert(EMA Cross Trend going Down on ,Symbol(), ,Stage());
alertTag = Timing[0];
if (SoundON==true I==1 CrossUp[I] lt; CrossDown[I] alertTag! =Timing[0])
Alert(EMA Cross Trend going On ,Symbol(), ,Stage());
alertTag = Timing[0];
return(0);