Quote:
|
Originally Posted by murky waters
question: how do you write an "if" function that triggers code at the END of each bar on the chart (which works independent of chart timeframe)?
|
murky waters,
Welcome to our forum!
Test this code:
PHP Code:
bool NewBar() //this function will return true if there's a new bar.
{
static bool first_call = true;
static int start_bar = 0;
if(first_call)
{
start_bar=Bars;
first_call=false;
}
if(Bars == (start_bar+1))
{
first_call=true;
return (true);
}
else
{
return (false);
}
}
int start() //<-- in your start function you may use code like this
{
if (NewBar)
{
//do something
}
return (0);
}