Why won't this alert work?

 
   if(Bid>ExtMapBuffer8[0])
      {
      PlaySound(UptrendAlert); Alert("ExtMapBuffer8", Symbol());
      alertcount++;
      }
   
   if(Bid<ExtMapBuffer1[0])
         {
         PlaySound(DowntrendAlert); Alert("ExtMapBuffer1", Symbol());
         alertcount++;

         } 

 

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

Advertising will lead to a ban.

 

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? 

 

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

 
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. 
 
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.
 
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

 
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..   
 

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]

 
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.. 
 
i think it worked lol.. thanks for helping me think.. i'm still testing it.. 
Reason: