Urgent! Metatrader5 Alert problem!

 

Hey there, 

 I have been struggling for a few days with this simple but annoying problem. Is it possible to set up an alert which gives notifications everytime a candles makes 4 ticks in its body on the M5 chart? Would make my life much easier but I don't even know where to start it.

 I would really appreciate any help on this matter. thanks.

P.S: That's my first post, apologies if the forum already has debated about this. I just couldn't find it. 

 

Oh dear urgent so we better hurry...

Here it is.

//+------------------------------------------------------------------+
//|                                                      4-Ticks.mq5 |
//|                        Copyright 2017, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"

int tick;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   if(Period()!=PERIOD_M5)
     {
      ChartSetSymbolPeriod(0,Symbol(),PERIOD_M5);
     }
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   tick++;
     {
      if(tick==4)
        {
         Alert("4-ticks");
           {
            tick=0;
           }
        }
     }
  }
//+------------------------------------------------------------------+
 

Thanks! I really aprecciated. 

This is the first time I'm using the Metaeditor. Where do I put this code?  

 

 

I foresee a lot of alerts

 
honest_knave:
I foresee a lot of alerts
and a lot of questions...
 

Nah, dont worry, I'm just not familiar with the metatrader5 and metaeditor. The asset that I operate in Brazil barelly moves, 4 ticks candles it is a trigger for my scalper strategy.

I just wanted some help on this introductory matter.

 sorry  

 
arturdaraujo:

Nah, dont worry, I'm just not familiar with the metatrader5 and metaeditor. The asset that I operate in Brazil barelly moves, 4 ticks candles it is a trigger for my scalper strategy.

I just wanted some help on this introductory matter.

 sorry  

Marco has actually given you the entire code.

From inside MetaEditor, click File > New

Select Expert Advisor (template)

Give it a name e.g. Experts\4-ticks

Click Next

Click Next again

Click Finish

Delete everything in the file that is created.

Copy-paste Marco's entire code

Press F7

Start MetaTrader 5

Add your new EA to a chart 

 
arturdaraujo:

Thanks! I really aprecciated. 

This is the first time I'm using the Metaeditor. Where do I put this code?  

You had your code within 30 Minutes but it took you 19 Hours to respond.

Next time please omit the urgent.

Put the code in MetaEditor and compile it and then you can load it onto a chart and it will give a alert every four ticks.
 
Marco vd Heijden:
You had your code within 30 Minutes but it took you 19 Hours to respond.

Next time please omit the urgent.

Put the code in MetaEditor and compile it and then you can load it onto a chart and it will give a alert every four ticks.

Sorry man! I was very upset by not knowing something so simple. I really appreciated the help you guys gave me around here.

Thanks once again

 
Macro seems too kind and fast today :)