Why won't this alert work?

Back to topics list To post a new topic, please log in or register
avatar
63
Neal_Van 2016.04.12 07:41
 
   if(Bid>ExtMapBuffer8[0])
      {
      PlaySound(UptrendAlert); Alert("ExtMapBuffer8", Symbol());
      alertcount++;
      }
   
   if(Bid<ExtMapBuffer1[0])
         {
         PlaySound(DowntrendAlert); Alert("ExtMapBuffer1", Symbol());
         alertcount++;

         } 

avatar
Moderator
3418
GumRai 2016.04.12 08:40 #
 

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

Advertising will lead to a ban.

avatar
63
Neal_Van 2016.04.12 23: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? 

avatar
Moderator
3418
GumRai 2016.04.13 02: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

avatar
63
Neal_Van 2016.04.13 22: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. 
avatar
13006
WHRoeder 2016.04.13 22: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.

avatar
Moderator
3418
GumRai 2016.04.14 01: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

avatar
63
Neal_Van 2016.04.15 01: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..   
avatar
Moderator
3418
GumRai 2016.04.15 01: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]

avatar
63
Neal_Van 2016.04.15 02: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.. 
avatar
63
Neal_Van 2016.04.15 04:16 #
 
i think it worked lol.. thanks for helping me think.. i'm still testing it.. 
Back to topics list  

To add comments, please log in or register