Your unbalanced left parenthesis is in your first "if"
then it will also execute where cnt=1.
Hope this helps.
if((MA5C<MA20C)
I think the problem with not closing your orders is that if there is only one order, your FOR loop is only executing with cnt=0 and never executes with cnt=1 because you are only iterating while cnt is less than total:
for(cnt=0;cnt<total;cnt++)
If you do it while cnt is less than or equal to total like this:
for(cnt=0;cnt<=total;cnt++)
then it will also execute where cnt=1.
Hope this helps.
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
int start() { double MA5C,MA20C,MA5P,MA20P,slip,lot; int total,ticket,cnt; MA5C=iMA(NULL,0,3,-4,MODE_SMMA,PRICE_CLOSE,0); MA20C=iMA(NULL,0,20,0,MODE_EMA,PRICE_CLOSE,0); total=OrdersTotal(); slip=0.00; lot=AccountBalance()/1000; if(total<1) { if((MA5C<MA20C) { ticket=OrderSend(Symbol(),OP_SELL,lot,Bid,10,0,0,0,0,0,Yellow); if(ticket<0) { Print("OrderSend failed with error #",GetLastError()); return(0); } } if(MA5C>MA20C) { ticket=OrderSend(Symbol(),OP_BUY,lot,Ask,10,0,0,0,0,0,Yellow); if(ticket<0) { Print("OrderSend failed with error #",GetLastError()); return(0); } } } for(cnt=0;cnt<total;cnt++) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if(OrderType()==OP_SELL) { if(MA5C>MA20C) { OrderClose(OrderTicket(),OrderLots(),Ask,10,Green); return(0); } } if(OrderType()==OP_BUY) { if(MA5C<MA20C) { OrderClose(OrderTicket(),OrderLots(),Bid,10,Green); return(0); } } } }The compiling also says that I have an " 'end_of_program/'-unbalanced left paranthesis" error on the very last line but I can't figure out how to fix it. Any help would be greatly appreciated.