How to set alerts sound on indicator "i-FractalsEx"

 
Good trading.

I had attached an indicator file ( i-FractalsEx ) here which generate Buy or Sell arrow signal when market condition meet certain rules, I find it predict very accurately the market direction but it does not generate alerts sound.

Does anyone can help to modify the program so that it will alert me whenever either up or down arrow appear.

Thanks very much.

Regards,
Thomas Lai
Files:
 
#property copyright "©"
#property link      ""

#define major   1
#define minor   0

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Yellow
#property indicator_width1  1
#property indicator_width2  1


extern int Fr.Period = 6;
extern int MaxBars = 500;


double upper_fr[];
double lower_fr[];

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

void init() {
  SetIndexBuffer(0, upper_fr);
  SetIndexBuffer(1, lower_fr);
  
  SetIndexEmptyValue(0, 0);
  SetIndexEmptyValue(1, 0);
  
  SetIndexStyle(0, DRAW_ARROW);
  SetIndexArrow(0, 234);

  SetIndexStyle(1, DRAW_ARROW);
  SetIndexArrow(1, 233);  
}

void start() 
{
  int counted = IndicatorCounted();
  if (counted < 0) return (-1);
  if (counted > 0) counted--;
  
  int limit = MathMin(Bars-counted, MaxBars);
  
  //-----
  
  double dy = 0;
  for (int i=1; i <= 20; i++) {
    dy += 0.3*(High[i]-Low[i])/20;
  }
  
  for (i=0+Fr.Period; i <= limit+Fr.Period; i++) 
  {
    upper_fr[i] = 0;
    lower_fr[i] = 0;
  
    if (is_upper_fr(i, Fr.Period)){
       upper_fr[i] = High[i]+dy;
       if(IndicatorCounted() > 0) PlaySound("alert2.wav");
    }
    if (is_lower_fr(i, Fr.Period)){ 
       lower_fr[i] = Low[i]-dy;
       if(IndicatorCounted() > 0) PlaySound("alert2.wav");
    }
  }
}

bool is_upper_fr(int bar, int period) 
{
  for (int i=1; i<=period; i++) 
  {
    if (bar+i >= Bars || bar-i < 0) return (false);

    if (High[bar] < High[bar+i]) return (false);
    if (High[bar] < High[bar-i]) return (false);
  }
  
  return (true);
}

bool is_lower_fr(int bar, int period) 
{
  for (int i=1; i<=period; i++) 
  {
    if (bar+i >= Bars || bar-i < 0) return (false);
    
    if (Low[bar] > Low[bar+i]) return (false);
    if (Low[bar] > Low[bar-i]) return (false);
  }
  
  return (true);
}
 
Never played with indicatorCounted before as I usually have no need for it (:P) so could have gotten it wrong, but there you have it.
 
forexCoder:
Never played with indicatorCounted before as I usually have no need for it (:P) so could have gotten it wrong, but there you have it.


Hi forexcoder,

Thanks very much, I will try it on my MT4 and see whether it work

 
thomaslai86:


Hi forexcoder,

Thanks very much, I will try it on my MT4 and see whether it work




I found there is something not going right, the alerts sound activate even start from many bars behind and never stop sounding, I need to delete the indicator to stop the sound, and I don't know the alerts come from which chart since I always open so many charts on my MT4 platform.

I just need the alerts start on the last 2~3 bar and notify me which chart it generate from and can stop the alerts anytime or 10 second notifying then stop automatically, either way will be fine.

Please kindly help me to improve the functionality of this indicator.

 

Yea I was kinda expecting that :P As i said,never used the indicator counted much :P

According to documentation just switch the IndicatorCounted() > 0 with Bars - IndicatorCounted() > 0

but i can already see another new set of problems there....

It's why I never use the damn thing.

 

Hi forex coder

can you make this become an EA

apply for all pairs and all time frame
use 0.01 lot and this lot is adjustable
execute buy order when yellow arrow
execute sell order when red arrow

take profit is 10 pips.

please help. thank you.

 

Thomas,

I think I have done, what you wanted - and a bit more.

I draw a little lines at the most recent 3 bars at the price of the last up- and down-fractals. And there is an alert (one for up, one for down) if the close[0] crosses these lines.

I saw that sometimes your fractal symbols appear where they should not be - I think corrected.

Now I think its a nice tiny little indicator, have fun with it.

Gooly

Files:
 
gooly:

Thomas,

I think I have done, what you wanted - and a bit more.

Why ? you are 2 years too late . . .

Thread start date - 2011.07.05

This is what happens when Users dredge up old threads for no good reason.

 

Why? - Why not?

I looked at it whether it could help me and started to change it, so that it becomes easier for me to see what I want.

That' so bad?

 
gooly:

Why? - Why not?

I looked at it whether it could help me and started to change it, so that it becomes easier for me to see what I want.

That' so bad?

Yes, it can potentially waste other peoples time thinking this is a new thread as it is at the top of the list. PM Thomas instead if you must . . . don't hold your breath waiting for a reply, his last post on this forum was in this thread in July 2011.