View Single Post
  #5 (permalink)  
Old 12-11-2006, 06:29 PM
Maji Maji is offline
Senior Member
 
Join Date: Mar 2006
Posts: 787
Maji is on a distinguished road
Again, do a search, I am sure you will find Coder's Guru's lessons. There is nothing better than learning how to do it right.

I am providing you with a subroutine that will count the number of trades for a given symbol and a given magicnumber. You can call that to find the number of trades, and if it is equal to or less than a certain number, you can place your trades.

PHP Code:
int CountTrades(int MagicNumber)
{
 
int count=0;
 
int trade;
 for(
trade=OrdersTotal()-1;trade>=0;trade--)
 {
  
OrderSelect(trade,SELECT_BY_POS,MODE_TRADES);
  
  if(
OrderSymbol()!=Symbol() || OrderMagicNumber()!=MagicNumber)
   continue;
   
  if(
OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)   
  if(
OrderType()==OP_BUY || OrderType()==OP_SELL)
   
count++;
 }
//for
 
return(count);

Reply With Quote