plese your advise with - 'static' - comma or semicolon expected error

 

bool New_Bar=false;
int start()
{
Fun_New_Bar();
if (New_Bar==false)
int i=0;
while(New_Bar==true)
if(iSAR(NULL,0,0.02,0.2,0)<Ask && i=1)
OrderSend(Symbol(),OP_BUY,0.1,Ask,30,iSAR(NULL,0,0.02,0.2,0),Ask+2000*Point,0,0,0,0);
return;
}
//---------------------------------------------------------------------------------
int init()
{
void Fun_New_Bar

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

i'm getting error mesage :'static' - comma or semicolon expected

What's wrong?

 

inside init() there is


"void Fun_New_Bar". Either you want to define this function(1) or call it(2):


(1):

void Fun_New_Bar()

{

....

}



(2):

int init()

{

Fun_New_Bar();

....

}


If u really want to define this function, then it must be made out of init() section.

 
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
bool New_Bar=false;

int start()
{    
     
      if (New_Bar==false)
      int i=0;                           
      while(New_Bar==true)
      {
        if(iSAR(NULL,0,0.02,0.2,0)<Ask && i=1) 
            OrderSend(Symbol(),OP_BUY,0.1,Ask,30,iSAR(NULL,0,0.02,0.2,0),Ask+2000*Point,0,0,0,0);
           
}
//--------------------------------------------------------------------------------
void Fun_New_Bar
{      
      static datetime New_Time=0;
      if (New_Time!=Time[0])
         {
         New_Time=Time[0];
         New_Bar=true;
}

//---------------------------------------------------------------------------------   
init()
{
Fun_New_Bar();

return (New_Bar);
}

i still not understand whats wrong

im getting error: '{' - comma or semicolon expected

thanks

 

For every "{" you must have a "}".

That should keep you busy for a while.

Study some code samples that work.

The { and } enclose logical blocks of code.

Example:

if something is true do something

if( 1 < 2 ){

... do this

... and this

... and this

... and do this last thing you want done if 1 is less than 2

}

To answer "What is wrong?"

You have SYNTAX errors.

 

I probably feel Christmas coming and solved the issues in our code. :-)

I suggest that you improve programming skills.

Here is your code with corrections on it:



// the char '/' WAS MISSING HERE-
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
bool New_Bar=false;

int start()
{

if (New_Bar==false)
int i=0;
while(New_Bar==true)
{
if(iSAR(NULL,0,0.02,0.2,0)<Ask && i==1) // THE COMPARITION OPERATOR SHOULD BE "=="
OrderSend(Symbol(),OP_BUY,0.1,Ask,30,iSAR(NULL,0,0.02,0.2,0),Ask+2000*Point,0,0,0,0);
} // BRACKET WAS MISSING HERE

}


//--------------------------------------------------------------------------------
void Fun_New_Bar() // PARENTHESIS WERE MISSING HERE
{
static datetime New_Time=0;
if (New_Time!=Time[0])
{
New_Time=Time[0];
New_Bar=true;
} // A BRACKET WAS MISSING HERE
}

//---------------------------------------------------------------------------------

bool init() // RETURN TYPE DECLARATION WAS MISSING HERE
{
Fun_New_Bar();
// an issue of style, you don't make returns of global variables.
return (New_Bar);
}

 
abstract_mind wrote >>

I probably feel Christmas coming and solved the issues in our code. :-)

I suggest that you improve programming skills.

Here is your code with corrections on it:


// the char '/' WAS MISSING HERE-
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
bool New_Bar=false;

int start()
{

if (New_Bar==false)
int i=0;
while(New_Bar==true)
{
if(iSAR(NULL,0,0.02,0.2,0)<Ask && i==1) // THE COMPARITION OPERATOR SHOULD BE "=="
OrderSend(Symbol(),OP_BUY,0.1,Ask,30,iSAR(NULL,0,0.02,0.2,0),Ask+2000*Point,0,0,0,0);
} // BRACKET WAS MISSING HERE

}


//--------------------------------------------------------------------------------
void Fun_New_Bar() // PARENTHESIS WERE MISSING HERE
{
static datetime New_Time=0;
if (New_Time!=Time[0])
{
New_Time=Time[0];
New_Bar=true;
} // A BRACKET WAS MISSING HERE
}

//---------------------------------------------------------------------------------

bool init() // RETURN TYPE DECLARATION WAS MISSING HERE
{
Fun_New_Bar();
// an issue of style, you don't make returns of global variables.
return (New_Bar);
}

Thank You!

why i cant backtesting that EA?

 

/*

Put it eurusd 1H chart and begin testing since September 2008


*/





// the char '/' WAS MISSING HERE-

//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
bool New_Bar=false;

int start()
{

// what do you intend to do with variable 'i'?
//if (New_Bar==false)
//int i=0;
int digits = MarketInfo(Symbol(),MODE_DIGITS);

if(Fun_New_Bar())
if(OrdersTotal()==0)
{
if(iSAR(NULL,0,0.02,0.2,0)<Ask /*&& i==1*/) // THE COMPARITION OPERATOR SHOULD BE "=="
{
double stopLoss = NormalizeDouble(iSAR(NULL,0,0.02,0.2,0), digits);
double takeProfit = NormalizeDouble(Ask+100*Point, digits);

OrderSend(Symbol(),OP_BUY,0.1,Ask,10,stopLoss,takeProfit,0,0,0,Blue);
} // BRACKET WAS MISSING HERE
if(iSAR(NULL,0,0.02,0.2,0)>Bid /*&& i==1*/) // THE COMPARITION OPERATOR SHOULD BE "=="
{
stopLoss = NormalizeDouble(iSAR(NULL,0,0.02,0.2,0), digits);
takeProfit = NormalizeDouble(Ask-100*Point, digits);

OrderSend(Symbol(),OP_SELL,0.1,Bid,10,stopLoss,takeProfit,0,0,0,Red);
} // BRACKET WAS MISSING HERE
}

}


//--------------------------------------------------------------------------------
bool Fun_New_Bar() // PARENTHESIS WERE MISSING HERE
{
static datetime New_Time=0;
RefreshRates();
if (New_Time!=Time[0])
{
New_Time=Time[0];
New_Bar=true;
} // A BRACKET WAS MISSING HERE
else
New_Bar = false;
return(New_Bar);
}

//---------------------------------------------------------------------------------

bool init() // RETURN TYPE DECLARATION WAS MISSING HERE
{
Fun_New_Bar();
// an issue of style, you don't make returns of global variables.
return (New_Bar);
}
 
abstract_mind wrote >>

/*

Put it eurusd 1H chart and begin testing since September 2008

*/

// the char '/' WAS MISSING HERE-

//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
bool New_Bar=false;

int start()
{

// what do you intend to do with variable 'i'?
//if (New_Bar==false)
//int i=0;
int digits = MarketInfo(Symbol(),MODE_DIGITS);

if(Fun_New_Bar())
if(OrdersTotal()==0)
{
if(iSAR(NULL,0,0.02,0.2,0)<Ask /*&& i==1*/) // THE COMPARITION OPERATOR SHOULD BE "=="
{
double stopLoss = NormalizeDouble(iSAR(NULL,0,0.02,0.2,0), digits);
double takeProfit = NormalizeDouble(Ask+100*Point, digits);

OrderSend(Symbol(),OP_BUY,0.1,Ask,10,stopLoss,takeProfit,0,0,0,Blue);
} // BRACKET WAS MISSING HERE
if(iSAR(NULL,0,0.02,0.2,0)>Bid /*&& i==1*/) // THE COMPARITION OPERATOR SHOULD BE "=="
{
stopLoss = NormalizeDouble(iSAR(NULL,0,0.02,0.2,0), digits);
takeProfit = NormalizeDouble(Ask-100*Point, digits);

OrderSend(Symbol(),OP_SELL,0.1,Bid,10,stopLoss,takeProfit,0,0,0,Red);
} // BRACKET WAS MISSING HERE
}

}


//--------------------------------------------------------------------------------
bool Fun_New_Bar() // PARENTHESIS WERE MISSING HERE
{
static datetime New_Time=0;
RefreshRates();
if (New_Time!=Time[0])
{
New_Time=Time[0];
New_Bar=true;
} // A BRACKET WAS MISSING HERE
else
New_Bar = false;
return(New_Bar);
}

//---------------------------------------------------------------------------------

bool init() // RETURN TYPE DECLARATION WAS MISSING HERE
{
Fun_New_Bar();
// an issue of style, you don't make returns of global variables.
return (New_Bar);
}

Thanks !!!