if Statement stop's running after first time

 

Hi Everyone!

if Statement stop's running after first day, only works one's on the drup on chart.

pls,need the hint here

      double BFM;
      double BarsFromMidnight()
      
      {
      if(Hour() == 0) {BFM = 0;}
      else 
      if(Hour() == 1) {BFM = 1;}
      else
      if(Hour() == 2) {BFM = 2;}
      else
      if(Hour() == 3) {BFM = 3;}
      else 
      if(Hour() == 4) {BFM = 4;}
      else
      if(Hour() == 5) {BFM = 5;}
      else
      if(Hour() == 6) {BFM = 6;}
      else 
      if(Hour() == 7) {BFM = 7;}
      else
      if(Hour() == 8) {BFM = 8;}
      else
      if(Hour() >  8) {BFM = 8;}
      return(BFM);
      }

int start() { { BFM = BarsFromMidnight();

} return(0); }

 

As you don't call the function BarsFromMidnight anywhere in your code and that function has the only code with an if(), I don't see that the if() is executed at all.

What does the function B() do?

 
Keith Watford:

As you don't call the function BarsFromMidnight anywhere in your code and that function has the only code with an if(), I don't see that the if() is executed at all.

What does the function B() do?


Sorry about "B" means BFM = BarsFromMidnight(); i correct it

 

I also wrote a switch operator that works fine.

int start()
      {
      int BFM;
      int now = Hour();
      switch(now)
      {
      case 1:BFM = now ;break;
      case 2:BFM = now ;break;
      case 3:BFM = now ;break;
      case 4:BFM = now ;break;
      case 5:BFM = now ;break;
      case 6:BFM = now ;break;
      case 7:BFM = now ;break;      
      case 8:BFM = now ;break;
      default: BFM = 8 ;break;
      }
      Comment("Bars from Midnight =",BFM);
      return(0);
      }

But, i still like to solve the if statement.

 
PieroNetto:

I also wrote a switch operator that works fine.

But, i still like to solve the if statement.


What do you want to solve/correct? 

 
Or simplify further
int start(){
      int BFM = MathMax(8, Hour() );
      Comment("Bars from Midnight =",BFM);
      return(0);
}
 
whroeder1:
Or simplify further
Hi whroeder1!

Finally time again to check up on things, check your code and was following up was it does and i took MathMin(), works like a charme.

Thanks a lot for your Help, looking up to you, thanks again.

Having the feeling getting somewhere with your help, keep up the great work,wish you the best.

Regards Piero