MANUAL ORDER AND EA CLOSING

To add comments, please log in or register
AZRUL AZMI
61
AZRUL AZMI  

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

whroeder1
17954
whroeder1  
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.
Simon Gniadkowski
17644
Simon Gniadkowski  
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.
AZRUL AZMI
61
AZRUL AZMI  

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);
}
Tjipke de Vries
6542
Tjipke de Vries  
      if(   OrderType()<=OP_SELL                      // check for opened position
         && OrderSymbol()==Symbol()                   // check for symbol
         && (OrderMagicNumber() == magicNumber||OrderMagicNumber() == 0))        // my magic number  && manual trades
Simon Gniadkowski
17644
Simon Gniadkowski  
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
AZRUL AZMI
61
AZRUL AZMI  
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,

RFB
127
RFB  
@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);
 }
 
Simon Gniadkowski
17644
Simon Gniadkowski  
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 ?

RFB
127
RFB  
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.
Tjipke de Vries
6542
Tjipke de Vries  
  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 ??? 

12
To add comments, please log in or register