Manual order and EA closing

 

Hi guys,

I would like to ask this question,

If I don't placing (omit) a magic number command in the EA, will my EA still monitor and closed my manually ordered.

Thanks for any advices from here....

AZR

 
No mind readers here. Does your EA do a orderSelect loop with out magic number but with symbol? Then it will find a manually placed order on its chart.
 
12BPRO2:

Hi guys,

I would like to ask this question,

If I don't placing (omit) a magic number command in the EA, will my EA still monitor and closed my manually ordered.

Your EA will do what you code it to do,  if that includes monitoring and closing manually placed Orders then yes it will.  If you filter correctly by Symbol and/or Magic Number then no, it won't.
 

Ok Guys,

Answering WHRoeder - Does My EA do a orderSelect loop with out magic number but with symbol

YES....

Answering RaptorUK -  If you filter correctly by Symbol and/or Magic Number then no, it won't.

YES..... so i guess my EA won't monitor and closed my manual order...

If that's the CASE what if I change the magicnumber = 0, would it do the trick.

or I have change the following command line....

magicNumber to OrderTicket...

Sorry for my lack of knowledge, I'm not a programmer just learning...

{
   int total=OpenTradesForMNandPairType(magicNumber, Symbol());
   for(int cnt=total-1;cnt>=0;cnt--)
    {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      if(   OrderType()<=OP_SELL                      // check for opened position
         && OrderSymbol()==Symbol()                   // check for symbol
         && OrderMagicNumber() == magicNumber)        // my magic number
      {
         if(OrderType()==OP_BUY)   // BUY position is opened
         {
            // should it be closed?                      
            if(ExitBuyCondition())
            {
               if(OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet)) // close position
               {
                  return (true);
               }
               return(false);
            }
         }
         else // go to short position
         {
            // should it be closed?       
            if(ExitSellCondition())
            {
               if(OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet)) // close position
               {
                  return (true); 
               }
               return(false);
            }         
         }
      }
   }
   return (true);
}
 
      if(   OrderType()<=OP_SELL                      // check for opened position
         && OrderSymbol()==Symbol()                   // check for symbol
         && (OrderMagicNumber() == magicNumber||OrderMagicNumber() == 0))        // my magic number  && manual trades
 
12BPRO2:

Ok Guys,

Answering WHRoeder - Does My EA do a orderSelect loop with out magic number but with symbol

YES....

Answering RaptorUK -  If you filter correctly by Symbol and/or Magic Number then no, it won't.

YES..... so i guess my EA won't monitor and closed my manual order...

If that's the CASE what if I change the magicnumber = 0, would it do the trick.

or I have change the following command line....

magicNumber to OrderTicket...

Sorry for my lack of knowledge, I'm not a programmer just learning...

If you want your code to work on all trades, not just the trades that belong to your EA,  for a particular symbol do this . . .

      if( ( OrderType() == OP_SELL ||                  // check for opened position
            OrderType() == OP_BUY ) 
         && OrderSymbol()==Symbol() )                 // check for symbol
 
RaptorUK:

If you want your code to work on all trades, not just the trades that belong to your EA,  for a particular symbol do this . . .

 


Hi deVries.

Thanks for your time and opinion

Best Regards,

 
@12BPRO2 I have change the following command line....magicNumber to OrderTicket...
Than there are some magic numbers, and the manual one does not have
int errors;
/*checks external or trade without sl/tp*/
bool openedTrades()
 {
  if(OrdersTotal()<1) return(0);//inital checkings //  || !online
  bool close;
  double od,min,err;
  for(int ot=OrdersTotal()-1;ot>-1;ot--)
   {
    if( !OrderSelect(ot,SELECT_BY_POS) )continue;
    if( OrderType()>OP_BUY || OrderType()<OP_SELL ) continue;//we consider market orders only
    if( OrderSymbol()!=Symbol() ) continue;//remove if for all symbols
    if( OrderStopLoss()>0.0 && OrderTakeProfit()>0.0 ) continue;//no change
    close=0;
    min = MarketInfo( OrderSymbol() , MODE_STOPLEVEL )
     * MarketInfo( OrderSymbol() , MODE_POINT );//minimum alowed to change stops
    if( OrderMagicNumber()!=ThisEaMagicNumber || OrderMagicNumber()<1 )
     {//MN, but needs a choice/change or will affect other EA IF there is 
      if( OrderProfit()>0.0 ) close=1; //or other close logic
      else continue;
     }
    else if( OrderProfit()>0.0 ) close=1;//EA trade, but put close logic here
    else if( PutStops ) // if by settings to modoify stops
     if( SendStops() ) continue;//if empty stops modify function
    err = MarketInfo( OrderSymbol() , MODE_FREEZELEVEL )  
     * MarketInfo( OrderSymbol() , MODE_POINT );//minimum alowed to close
    od = MathAbs( OrderOpenPrice()-OrderClosePrice() );//possible to be more acurate 
    if( close && od>err ) // but it is not ideal solution, it is basic
      if( !OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),slipp*p2p) )
       errors++;
   }
  return(0);
 }
 
 
rfb:
Than there are some magic numbers, and the manual one does not have

What does this mean ?

if( OrderType()>2 )

 Why not write code that is easy to read and comprehend ?

 
RaptorUK:

What does this mean ?

 Why not write code that is easy to read and comprehend ?

 

Big Error,  I'm am not used to use assigned names (OP_BUY), I'll have to change my habit in the future.
 
  if( OrderMagicNumber()!=ThisEaMagicNumber || OrderMagicNumber()<1 )

makes it your EA is changing manual trades and trades placed by other EA's  but not its own

why do you do that ??? 

Reason: