Alerts not showing

 

Hello

I have a very simple EA with an alert only. Here is the code:

void OnTick()
  {
//---   
         //Test
         if (Close[1] < Open[1] || Close[1] > Open[1])  //Test
      {
         Alert("Test");
         PlaySound("email");      
       }  
  }

This code is just to test the Alert and Playsound functions.

But nothing happens. My EA is activated with a happy face on the chart.

No popup notification or sound is played, nothing appears in the Journal or Alert tab either.

What is wrong here?

 
Paul Anscombe:

you don't appear to be populating the value of Close and Open so they will have equal value and the condition will never be met.

https://www.mql5.com/en/docs/series/copyrates


I've never heard of this before.

My other codes have worked perfectly well on Strategy Tester without copyrates.

The alert works in the Strategy Tester by appearing in the Journal Tab but not in a separate window.

 
ladyrose:


I've never heard of this before.

My other codes have worked perfectly well on Strategy Tester without copyrates.

The alert works in the Strategy Tester by appearing in the Journal Tab but not in a separate window.

my bad forgot you were on MT4 

why don't you print out the values of Close and Open to make sure the test is valid

and if you want to just test the alerts simply remove the if.

You might want to limit the alert to just once in either case as it will try and alert every tick as it is coded


it works on my MT4 so I would check the values of the condition that you are getting 

The Fundamentals of Testing in MetaTrader 5
The Fundamentals of Testing in MetaTrader 5
  • www.mql5.com
The idea of ​​automated trading is appealing by the fact that the trading robot can work non-stop for 24 hours a day, seven days a week. The robot does not get tired, doubtful or scared, it's is totally free from any psychological problems. It is sufficient enough to clearly formalize the trading rules and implement them in the algorithms, and...
 
Paul Anscombe:

it works on my MT4 so I would check the values of the condition that you are getting 

Actually it works on mine. I just found out now.

I've been testing it on an offline chart that's where it's not working.

I made a 3m chart. It does not work there. Why?

 
ladyrose:

Actually it works on mine. I just found out now.

I've been testing it on an offline chart that's where it's not working.

I made a 3m chart. It does not work there. Why?

I suggest that you check the values of open and close...

 
Paul Anscombe:

I suggest that you check the values of open and close...

Here is what solved the problem:

https://www.mql5.com/en/forum/152421#comment_3779431 

Uncheck the Offline Chart in properties.

EA to run on offline chart MT4
EA to run on offline chart MT4
  • 2014.07.18
  • www.mql5.com
Hello, around one year ago I could make an EA work on an offline chart. But now I see it's not working anymore...