Need help in Magic Number.

 

hey.

 I have a function which prevents the EA to send orders on eachtick once conditions are fulfilled , i have attached the code of function. Problem is, until now it was working fine But now i want to send Multiple orders under one symbol.

please provide the right directions.

bool Checkorders(int magicnumber)
  {
   
   int openorders= OrdersTotal() ;
   for(int i= 0 ; i<openorders; i++)
     {
      if(OrderSelect(i,SELECT_BY_POS) == true)
        {
         if(OrderMagicNumber() == magicnumber)
           {
            return true ;
            Alert(" position open ") ;
           }

        }

     }
   return false ;
  }
 

Either use a different magic number for each symbol

or

bool Checkorders(int magicnumber, string symbol_name)
  {   
   int openorders= OrdersTotal() ;
   for(int i= 0 ; i<openorders; i++)
     {
      if(OrderSelect(i,SELECT_BY_POS) == true)
        {
         if(OrderMagicNumber() == magicnumber && OrderSymbol()==symbol_name)
           {
            Alert(" position open for ",symbol_name) ;
            return true ;
           }
        }
     }
   return false ;
  }
 
Keith Watford:

Either use a different magic number for each symbol

or

Thank you for your guidance.

   i am already using different magic number for every symbol, this is not the problem i am having. Problem is that i want multiple orders under one symbol. So if magic number is given to a symbol, it will open a trade with the provided magic number, but now it will not allow another order to be placed because the an order with this magic number is already opened.

if i needed 2 or 3 open orders then i could open 3\4 charts of the symbol and give everyone a different magic number, but i mostly have 20 open trades per symbols, I cant open 20 charts of same symbol and manage them continuously.

I hope you understood my problem. Please let me know if there is Any Way of doing it.

 
assfianazhar:

Please don't edit and completely change your initial post when you have had replies to your topic.

The code in your initial post is now no longer relevant as you have changed your question.

Please post your relevant code.

 
Keith Watford:

Please don't edit and completely change your initial post when you have had replies to your topic.

The code in your initial post is now no longer relevant as you have changed your question.

Please post your relevant code.

Well the question is not changed. this was my question in first place, i just explained it thoroughly in reply.

Code is the same as previously written.

 
assfianazhar: Problem is that i want multiple orders under one symbol. So if magic number is given to a symbol, it will open a trade with the provided magic number, but now it will not allow another order to be placed because the an order with this magic number is already opened.

So don't check.

 
William Roeder:

So don't check.

if you do not check or put some limitation, then it will send an order at every tick.

 
assfianazhar:

if you do not check or put some limitation, then it will send an order at every tick.

Any Ways I think i have found a solution to it.

What i want was to open a trade when it is closed by TP, with same values.

 SO i was storing  ticket numbers of open orders in an array,and once it is closed by TP, after sending an order i have removed that ticket from array. Since that ticket is no more there so it will not send anymore orders.  In this way i dont even have to check for magic number.

it is working for me.  let me know if i am missing something important.