Download MetaTrader 5
To add comments, please log in or register
Trade with MetaTarder 5. Download it right now!
Neal_Van
275
Neal_Van 2016.04.12 05:41 
   if(Bid>ExtMapBuffer8[0])
      {
      PlaySound(UptrendAlert); Alert("ExtMapBuffer8", Symbol());
      alertcount++;
      }
   
   if(Bid<ExtMapBuffer1[0])
         {
         PlaySound(DowntrendAlert); Alert("ExtMapBuffer1", Symbol());
         alertcount++;

         } 

Keith Watford
Moderator
7955
Keith Watford 2016.04.12 06:40  

I have removed your other topic that includes a link that could be considered advertising.

Advertising will lead to a ban.

Neal_Van
275
Neal_Van 2016.04.12 21:30  

help... lol...

i've spent so long on trying to figure out what this code fires when the condition is not met.... I don't want to share my sacred code lol..

Does Pie still come on here? 

Keith Watford
Moderator
7955
Keith Watford 2016.04.13 00:10  

Your code "works" if the condition is true, you will get a pop-up alert window.

The playsound will not be heard because the alert takes priority over PlaySound

Neal_Van
275
Neal_Van 2016.04.13 20:30  
Hi again.. Well it is not triggering at the right value.. i'm checking the buffer value and there's no reason it shouldn't work.. the code is based of moving averages if that makes any difference. 
whroeder1
13627
whroeder1 2016.04.13 20:52  
Neal_Van there's no reason it shouldn't work..
  1. There is a reason, you just don't know it.
  2. Add print statements before your ifs, including your variables values and find out why.
Keith Watford
Moderator
7955
Keith Watford 2016.04.13 23:56  
Neal_Van:
Hi again.. Well it is not triggering at the right value.. i'm checking the buffer value and there's no reason it shouldn't work.. the code is based of moving averages if that makes any difference. 

When writing code, you have to be precise so that the code executes as you want.

You should also be precise when posting here so that your problem can be understood by others.

Your post is vague

"Doesn't work" is meaningless without details

Is the alert not triggering or is the alert triggering when you don't expect it to.

If the alert IS triggering

Are you checking the buffer value at the exact time of the alert?

The code checks Buffer[0], so by the time you check, Buffer[0] could have changed as could Bid and the values for the moving averages

Neal_Van
275
Neal_Van 2016.04.14 23:22  
GumRai:

When writing code, you have to be precise so that the code executes as you want.

You should also be precise when posting here so that your problem can be understood by others.

Your post is vague

"Doesn't work" is meaningless without details

Is the alert not triggering or is the alert triggering when you don't expect it to.

If the alert IS triggering

Are you checking the buffer value at the exact time of the alert?

The code checks Buffer[0], so by the time you check, Buffer[0] could have changed as could Bid and the values for the moving averages

Hi.. The alert is triggering when I don't expect it to.. It is supposed to trigger if it exceeds the buffer value or inversely goes below it. i have the buffer value digitally shown in a label in a separate indicator that i use for testing but it displays the buffer value directly rather than by its assigned name..  as far as i know the buffer value shouldn't change..   
Keith Watford
Moderator
7955
Keith Watford 2016.04.14 23:45  

It is unusual for Buffer[0] to not change. Usually an indicator is coded so that Buffer[0] is updated every tick. Of course this may not be the case here.

Show the code that assigns a value to Buffer[0]

Neal_Van
275
Neal_Van 2016.04.15 00:33  
I have an idea.. I'll let you know if it worked.. i'll use multiple conditions for past bars.. but i would still like to know why it isn't working just as it is.. i going to have to do some reading i guess.. 
Neal_Van
275
Neal_Van 2016.04.15 02:16  
i think it worked lol.. thanks for helping me think.. i'm still testing it.. 
/
To add comments, please log in or register