Need help finding compilation error

 

Can anyone help me find the error in the following script?

I keep getting a "\end of program-unbalanced left parentheses" error .

PlaceBuyOrder() and PlaceSellOrder() are functions I defined and which compile ok.

Would appreciate anyone's help. This is my first attempt at writing a MQL4 program

Thanks in advance

int start()
{
//----
int cnt, TurboMagicNum, total;
double winprice,looseprice;


for (cnt=0;cnt<OrdersTotal();cnt++)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
while(OrderClosePrice()==0) //Order Still Open
if (OrderType()==OP_SELL)
if (Bid>=OrderOpenPrice()+HedgeFactor*Point

{
PlaceBuyOrder(); //Opens buy order
OrderSelect(1);
while((Ask-SL*Point>OrderOpenPrice)&& (Ask +TP*Point < Ask+500*Point) )
{
winprice=OrderOpenPrice()+TP*Point;
looseprice=OrderOpenPrice()-SL*Point;
if(Ask>=winprice)

PlaceBuyOrder();
if(Ask<=looseprice)

PlaceSellOrder();
}
}
}

//----
return(0);
}

 
for (cnt=0;cnt<OrdersTotal();cnt++)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
while(OrderClosePrice()==0) //Order Still Open
if (OrderType()==OP_SELL)
if (Bid>=OrderOpenPrice()+HedgeFactor*Point)//<--- here

{
PlaceBuyOrder(); //Opens buy order 
OrderSelect(1);
while((Ask-SL*Point>OrderOpenPrice)&& (Ask +TP*Point < Ask+500*Point) )
{ 
winprice=OrderOpenPrice()+TP*Point;
looseprice=OrderOpenPrice()-SL*Point;
if(Ask>=winprice) 

PlaceBuyOrder();
if(Ask<=looseprice)

PlaceSellOrder();
}
}
}


//---- 
return(0);
}

 
Roger wrote >>

Thanks Roger, but forgive my stupidity. What is the error? Shouldn't a ")" close the if statement ?

 

Your code:

if (Bid>=OrderOpenPrice()+HedgeFactor*Point

{

My fixing:

if (Bid>=OrderOpenPrice()+HedgeFactor*Point)//<--- here

{

 
Roger wrote >>

Your code:

if (Bid>=OrderOpenPrice()+HedgeFactor*Point

{

My fixing:

if (Bid>=OrderOpenPrice()+HedgeFactor*Point)//<--- here

{

Sorry, I seem to have copied it wrong, but my original code has the ")". It still gives me the same error with the bracket there

 

OK

OrderSelect(1); <--- wrong

while((Ask-SL*Point>OrderOpenPrice)&& (Ask +TP*Point < Ask+500*Point) )<--- wrong, should be

while((Ask-SL*Point>OrderOpenPrice())&& (Ask +TP*Point < Ask+500*Point) )


 
Roger wrote >>

OK

OrderSelect(1); <--- wrong

while((Ask-SL*Point>OrderOpenPrice)&& (Ask +TP*Point < Ask+500*Point) )<--- wrong, should be

while((Ask-SL*Point>OrderOpenPrice())&& (Ask +TP*Point < Ask+500*Point) )

T

Thanks, made the changees, still getting the same error.

 
I tested - no errors
 
Roger wrote >>
I tested - no errors

Strange, I am getting the same error from my compiler. Is there another way of compiling other than using the Metaeditor compiler?

 
Send me to PM I'll test it.
 
Roger wrote >>
Send me to PM I'll test it.

I re-checked, the OrderSelect line still had an error which I corrected. I am now getting 0 errors. thanks much. I have a few more lines of code to add, I hope I won't have any problems with those

Reason: