Thread: quick question
View Single Post
  #4 (permalink)  
Old 12-05-2005, 12:59 PM
murky waters murky waters is offline
Junior Member
 
Join Date: Dec 2005
Posts: 2
murky waters is on a distinguished road
codersguru,

Thank you for the quick reply. However when testing your code in the meta editor, I recieve the error NewBar: variable not defined. For the code:

PHP Code:
//+------------------------------------------------------------------+
//|                                                    test_bars.mq4 |
//|                                                      ©2005,  S T |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "©2005, S T"
#property link      ""

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {

   return(
0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {

   return(
0);
  }

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); 

Reply With Quote