Start trade

 

Any one please tell me. Can i open any order if my EA begin with the following code :

int start()

{ 

  uchar i=0;

  uchar k=0;

  uchar t=OrdersTotal();

  for(i=0;i<t;i++)

  {OrderSelect(i,SELECT_BY_POS,MODE_TRADES);

   k=0;

   if(OrderSymbol()==Symbol()) k++;}

   if(k=0)

   { conditions and order send}

 return(i);

}

...

I want only one order be sent in a symbol. But i start test, it dont present any order with 0 profit.

 
  1. When you post code please use the CODE button (Alt-S)! (For large amounts of code, attach it.) Please edit your (original) post.
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor

  2. Style the code so you can see the nesting.

  3.   {OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
    Check your return codes for errors, and report them. Don't just silence the compiler, it is trying to help you.
              What are Function return values ? How do I use them ? - MQL4 and MetaTrader 4 - MQL4 programming forum
              Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
    Only those functions that return a value (e.g. iClose, MarketInfo, etc.) must you call ResetLastError before in order to check after.

  4. Why are you zeroing your count, inside the loop?
Reason: