5-8openEMA_crossover (signal and alert)

If you need an Indicator or Signal developed or translated from other language, please post all Indicator development REQUESTS to this section here.

Moderator: admin

5-8openEMA_crossover (signal and alert)

Postby cruelhoax » Fri Oct 15, 2010 4:07 am

HI There, hoping someone could convert this for me? I have already found the 3AIME 5820emacrossover on this site but it also incudes the 20 ema and also you cant change the numbers.
I took this mq4 indicator and signal, changed the default 5 and 8 to 1 and 2 and have had nice success trading on the daily charts with it. Would love to replicate this on the Trade Station II and once and for all leave MT4 behind.

Thanks Clint
PS Big apologies if this is not the way to post the mq4 (Im not sure how to post it?). Hopefully i dont get too big a flaming :-S

Code: Select all
//+------------------------------------------------------------------+
//|                                         EMA-Crossover_Signal.mq4 |
//|                         |
//+------------------------------------------------------------------+

/*
  +------------------------------------------------------------------+
  | Allows you to enter two ema periods and it will then show you at |
  | Which point they crossed over. It is more usful on the shorter   |
  | periods that get obscured by the bars / candlesticks and when    |
  | the zoom level is out. Also allows you then to remove the emas   |
  | from the chart.             
  +------------------------------------------------------------------+
*/   

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 LightBlue
#property indicator_color2 Magenta

double CrossUp[];
double CrossDown[];
int CurrentTrend = 0;
int starttime = 0;
extern int FasterEMA = 5;
extern int SlowerEMA = 8;
extern int Show_Alert = 1;
extern int Play_Sound = 1;
extern int Send_Mail = 1;
extern string SoundFilename = "alert.wav";


int init()
  {
   SetIndexStyle(0, DRAW_ARROW, EMPTY);
   SetIndexArrow(0, 233);
   SetIndexBuffer(0, CrossUp);
   SetIndexStyle(1, DRAW_ARROW, EMPTY);
   SetIndexArrow(1, 234);
   SetIndexBuffer(1, CrossDown);
   starttime = TimeLocal();
   
   return(0);
  }


int deinit()
  {
   return(0);
  }


int start() {
   int limit, i, counter, loop;
   double fasterEMAnow, slowerEMAnow, fasterEMAprevious, slowerEMAprevious, fasterEMAafter, slowerEMAafter;
   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;

   loop = 0;
   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;
       
      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_OPEN, i);
      slowerEMAprevious = iMA(NULL, 0, SlowerEMA, 0, MODE_EMA, PRICE_OPEN, i+1);
      slowerEMAafter = iMA(NULL, 0, SlowerEMA, 0, MODE_EMA, PRICE_OPEN, i-1);
     
      if ((fasterEMAnow > slowerEMAnow) && (fasterEMAprevious < slowerEMAprevious) && (fasterEMAafter > slowerEMAafter)) {
         CrossUp[i] = Low[i] - Range*0.5;

         if ((loop == 0) && (CurrentTrend != 1) && (TimeLocal() - starttime >= 10))  {
            if (Show_Alert == 1)  {
               Alert("Cross Up on " + Symbol() + " " + Period() + "min " + FasterEMA + "/" + SlowerEMA + " EMA");
               }
            if (Play_Sound == 1)  {
               PlaySound(SoundFilename);
               }
            if (Send_Mail == 1)  {
               SendMail("Cross Up on " + Symbol() + " " + Period() + "min " + FasterEMA + "/" + SlowerEMA + " EMA", "");
               }
               
            CurrentTrend = 1;
            }

         if (loop == 0)  {
            loop = 1;
            }
      }
      else if ((fasterEMAnow < slowerEMAnow) && (fasterEMAprevious > slowerEMAprevious) && (fasterEMAafter < slowerEMAafter)) {
         CrossDown[i] = High[i] + Range*0.5;

         if ((loop == 0) && (CurrentTrend != -1) && (TimeLocal() - starttime >= 10))  {
            if (Show_Alert == 1)  {
               Alert("Cross Down on " + Symbol() + " " + Period() + "min " + FasterEMA + "/" + SlowerEMA + " EMA");
               }
            if (Play_Sound == 1)  {
               PlaySound(SoundFilename);
               }
            if (Send_Mail == 1)  {
               SendMail("Cross Down on " + Symbol() + " " + Period() + "min " + FasterEMA + "/" + SlowerEMA + " EMA", "");
               }
               
            CurrentTrend = -1;
            }

         if (loop == 0)  {
            loop = 1;
            }
       }
   }
   return(0);
}
cruelhoax
 
Posts: 5
Joined: Sun Jun 06, 2010 11:56 pm


Re: 5-8openEMA_crossover (signal and alert)

Postby cruelhoax » Sat Oct 16, 2010 11:36 pm

Thank you Kindly
cruelhoax
 
Posts: 5
Joined: Sun Jun 06, 2010 11:56 pm

Re: 5-8openEMA_crossover (signal and alert)

Postby Alexander.Gettinger » Mon Nov 08, 2010 4:28 am

Alexander.Gettinger
FXCodeBase: Confirmed User
 
Posts: 3785
Joined: Wed Mar 31, 2010 9:40 pm
Location: Russia, Omsk

Re: 5-8openEMA_crossover (signal and alert)

Postby cruelhoax » Tue Nov 09, 2010 1:28 am

Thank you, very much appreciated!
cruelhoax
 
Posts: 5
Joined: Sun Jun 06, 2010 11:56 pm


Return to Indicator and Signal Requests

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Majestic-12 [Bot] and 39 guests