alert iterations

 

I have written a custom indicator that puts up an alert box and play the alert sound when my criteria are met, but it makes the alert sound on every tick.

How do I make sure it only alerts me on the first signal and not on every tick.


eg:


if (X,y,z)

{

Alert("Signal")

}


how do I make sure the above example does not alert me every tick that those criteria are true but rather only the 1st time those criteria come true?


thanx

 
bool firstTime = true;
if (X,y,z)
{

 if (firstTime)
 {
   Alert("Signal");
   firstTime = false;
 } 
}
 
GarF1eld:

Thank you very much. I will try that.

 

if you would just paste that code in your EA, it wouldnt work :D


declare firstTime as a global variable. and

firstTime = true;

put into the init() function.




 
23510:

Thank you very much. I will try that.


Garfield I tried it but it does not seem to work, I am new to coding so Im sure I am doing something wrong, can you please take a look at my code and see if you can tell me what I am doing wrong...


I will post my indy with the indy's it uses.

thanx

 
23510:

Garfield I tried it but it does not seem to work, I am new to coding so Im sure I am doing something wrong, can you please take a look at my code and see if you can tell me what I am doing wrong...


I will post my indy with the indy's it uses.

thanx

here's the indy it uses

Files:
 
23510:

here's the indy it uses

and this one

Files:
 
Now my indy is not alerting me when all the conditions are met....it does not wait for the CCI 34 to be in the correct place.
 
GarF1eld:

if you would just paste that code in your EA, it wouldnt work :D


declare firstTime as a global variable. and

put into the init() function.




Ok thank you, that works now, now all I have to figure out is why the idy signals before all the criteria are met....frustrating me a bit. ;)

 
23510:

Ok thank you, that works now, now all I have to figure out is why the idy signals before all the criteria are met....frustrating me a bit. ;)

AAAh Im an idiot! I had the wrong SetIndexBuffer value in the CCi 34 settings!!! it works now.


Thanks Garfield for your advice on the iterations, helped very much.

 

You're welcomed.

Good luck

Reason: