Quote:
|
Originally Posted by camisa
Hi, can someone tell me the code so the simple example indicator I attach only issues an alert after the close of the candle if the signal stays valid and not keep alerting during the duration of the candle???
Thanks!
|
The idea is to find out if there is a new bar. we can doing that by comparing the current bar time with a time that we save.
here is the code for this routine
bool NewBar()
{
static datetime dt = 0;
if (Time[0] != dt)
{
dt = Time[0];
return(true);
}
return(false);
}
Now before we check our condition we can check if the bar has changed. Something like that
i=Bars-counted_bars; // your original line of code
if (!NewBar()) // Check if new bar occurs
return(0);
while(i>=0) // your original line of code