Help please : )

 

First of all, those who can code mql deserve a lot of respect!!

I have spent months learning mql and apart from being able to code in prorealtime (which isn't really coding) I got pretty much nowhere with mql. I watched videos, made notes, but didn't really get anywhere, its very hard as all tutorials (on basic, c+) seem to be totally withdrawn from practical side of things : (

So here I am appealing for a bit of help.

Basically, I have 13 different charts running on my screen (all 1hr pairs) and what I need is for this to happen:

1. When new 1hr bar opens (i.e. at the hour, eg: 09.00, 10.00, etc), mql checks the previous bar and checks to see if it's true range (high-low) is below the last X number of bar's true ranges (eg: if it is below 10 last bars for example). So I am looking for basically NR4 or NR7 if you are familiar with that set up (a narrow range bar). If the true range for last hour's bar is indeed lowest in last X number of bars then the computer to do an sound ALARM, and that's it.

Right now I am doing this visually and it means checking the screens myself every single hour, which is a nightmare as its a 24hr process.

Ideally, if it is possible to incorporate the alarm function and check into the code below, somehow. I simply took the typical ATR code and changed the graph type of indicator to HISTOGRAM (so its easier to spot if the last hour bar is indeed lowest range). So I only use 1 custom indicator and it is below. If someone could incorporate the above paramter for an alarm into that code below (if that is reasonable) then I'd at least learn a bit more mql myself as well as have that functionality : ) . If not, then any other solution is welcomed : ) 

 --------------------------------

//+------------------------------------------------------------------+
//|                                                          ATR.mq4 |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net/"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 DodgerBlue
//---- input parameters
extern int AtrPeriod=14;
//---- buffers
double AtrBuffer[];
double TempBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
//---- 1 additional buffer used for counting.
   IndicatorBuffers(2);
//---- indicator line
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,AtrBuffer);
   SetIndexBuffer(1,TempBuffer);
//---- name for DataWindow and indicator subwindow label
   short_name="ATR("+AtrPeriod+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
//----
   SetIndexDrawBegin(0,AtrPeriod);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Average True Range                                               |
//+------------------------------------------------------------------+
int start()
  {
   int i,counted_bars=IndicatorCounted();
//----
   if(Bars<=AtrPeriod) return(0);
//---- initial zero
   if(counted_bars<1)
      for(i=1;i<=AtrPeriod;i++) AtrBuffer[Bars-i]=0.0;
//----
   i=Bars-counted_bars-1;
   while(i>=0)
     {
      double high=High[i];
      double low =Low[i];
      if(i==Bars-1) TempBuffer[i]=high-low;
      else
        {
         double prevclose=Close[i+1];
         TempBuffer[i]=MathMax(high,prevclose)-MathMin(low,prevclose);
        }
      i--;
     }
//----
   if(counted_bars>0) counted_bars--;
   int limit=Bars-counted_bars;
   for(i=0; i<limit; i++)
      AtrBuffer[i]=iMAOnArray(TempBuffer,Bars,AtrPeriod,0,MODE_SMA,i);
//----
   return(0);
  }
//+------------------------------------------------------------------+ 

 
oh, I change AtrPeriod from 14 to 1, in the actual mt4 when I set the custom indicator onto the chart
 
niko:

First of all, those who can code mql deserve a lot of respect!!

I have spent months learning mql and apart from being able to code in prorealtime (which isn't really coding) I got pretty much nowhere with mql. I watched videos, made notes, but didn't really get anywhere, its very hard as all tutorials (on basic, c+) seem to be totally withdrawn from practical side of things : (


<CODE DELETED>

Please edit your post . . .    please use the   SRC   button to post code: How to use the   SRC   button. 
 
sorry, done, its been a few years since I posted here : )
Reason: