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); }
Your code:
if (Bid>=OrderOpenPrice()+HedgeFactor*Point
{
My fixing:
if (Bid>=OrderOpenPrice()+HedgeFactor*Point)//<--- here
{
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) )
I tested - no errors
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
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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);
}