Executing a function after bar closes

 

Can someone show me sample code of how I can execute a function after a bar closes?

I'm trying to avoid checking bar[1] with every tick.

 

int last_bar=0;

int start()
{

......

if(last_bar != Time[0] )
{
last_bar = Time[0];

//

do your stuff here....
//..... 

}
}