pls help

 

pls can someone tell me the code for new bar? Actually i know of this:

void Fun_New_Bar()
{
static datetime New_Time=0;
New_Bar=false;
if(New_Time!=Time[0])
{
New_Time=Time[0];
New_Bar=true;
}
}

But my problem is that i dont know if it is correct or not, and if it is correct, how am i going to refer to it ?

is it going to be in this form?

if (tr>sd&&New_Bar=true&&buy==0)
{
OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-StopLoss*Point, TP,"F",0,0,Red);

}


THANKS

 
bool Fun_New_Bar()
{
static datetime New_Time=0;
bool New_Bar=false;
if(New_Time!=Time[0])
{
New_Time=Time[0];
New_Bar=true;
}
return(New_Bar);
}
....
if (tr>sd&&Fun_New_Bar()&&buy==0) 
...
 

Don't even need a function:
start() {
  static datetime Time0;  bool newBar = Time[0] > Time0; Time0=Time[0];
 
  if (!newBar) return;                  
  // or
  if (tr>sd && newBar && buy==0) {
  //...
Reason: