help - checking bar opening

 

Dear All,

I am trying to use the following code and cant make it work. I have check and rechecked the code seem clean, I cant figure out why nothing is being printed....please help.

int start()
  {int oldBarTime;

oldBarTime=Time[0];

if(oldBarTime!=Time[0])
{oldBarTime=Time[0];
Print("Opening of a 15 mn bar");}



return(0);
}

Nothing is being printed...did i miss something ?

thx!

 

MA

As written, your var

olBarTime

is volatile & is being reset each tick - when start() executes again

To do what I think you want, use a static var which preserves its state (i.e. value) across ticks

--

static int oldBarTime;

init()
{
  oldBarTime=Time[0];

}

int start()
{

   if(oldBarTime!=Time[0])
    { oldBarTime=Time[0];
      Print("Opening of a 15 mn bar");
    }



return(0);
}

Good luck

-BB-

 
BarrowBoy wrote >>

MA

As written, your var

olBarTime

is volatile & is being reset each tick - when start() executes again

To do what I think you want, use a static var which preserves its state (i.e. value) across ticks

--

Good luck

-BB-

Its working now thank you very much.

Reason: