An Example of Trading Logic, with a Question

 
...actually this is a question that's been concerning to me for a while now, are there cases when verifying OrderSelect() (i.e. to resolve the Warning) is actually a bad idea and I'd be better off just leaving
OrderSelect(glbOrderTicket,SELECT_BY_TICKET, MODE_TRADES);

instead of using

if(OrderSelect(glbOrderTicket, SELECT_BY_TICKET, MODE_TRADES) == true)

 
Alex Go:
...actually this is a question that's been concerning to me for a while now, are there cases when verifying OrderSelect() (i.e. to resolve the Warning) is actually a bad idea and I'd be better off just leaving

instead of using

i would use something like this :

if(!OrderSelect(glbOrderTicket,SELECT_BY_TICKET, MODE_TRADES))break;
  if(OrderSymbol() != Symbol() && OrderMagicNumber() != MagicNumber)continue;
     if(OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
       {
        ...
       }
 
Kenneth Parling:

i would use something like this :

if(OrderSymbol() != Symbol() && OrderMagicNumber() != MagicNumber) continue;

In my opinion, this algo actually only slows down program execution, because even without that command, the pointer will always continue until eof.

 
Roberto Jacobs:

In my opinion, this algo actually only slows down program execution, because even without that command, the pointer will always continue until eof.

the point using it is to keep track of it's own orders and not be in conflict with any other advisers open orders

 

in other words, if I'm using something like this

if(glbOrderType == OP_BUYLIMIT){
         if(OrderSelect(glbOrderTicket, SELECT_BY_TICKET, MODE_TRADES) == true)
         if(entry != OrderOpenPrice())
         if(OrderModify(glbOrderTicket,entry,stop,take,0,clrNONE) == false) 
            Print("Err (",GetLastError(), ") Modify Sell Price= ",entry," SL= ",stop," TP= ",take);}

it's actually slower, but same result as this?

if(glbOrderType == OP_BUYLIMIT){
         OrderSelect(glbOrderTicket, SELECT_BY_TICKET, MODE_TRADES);
         if(entry != OrderOpenPrice())
         if(OrderModify(glbOrderTicket,entry,stop,take,0,clrNONE) == false) 
            Print("Err (",GetLastError(), ") Modify Sell Price= ",entry," SL= ",stop," TP= ",take);}
of course...only one Expert active at a time per currency, per account, per broker, per machine(platform, computer, tablet, mobile) so, no running multiple charts with same currency and different EAs
 
Alex Go:

in other words, if I'm using something like this

it's actually slower, but same result as this?

of course...only one Expert active at a time per currency, per account, per broker, per machine(platform, computer, tablet, mobile) so, no running multiple charts with same currency and different EAs

the second one will give you a compile warning to check return value of OrderSelect. If one of your examples are slower or faster i can't tell

if(glbOrderType == OP_BUYLIMIT){
         OrderSelect(glbOrderTicket, SELECT_BY_TICKET, MODE_TRADES); <----This will need a return function
         if(entry != OrderOpenPrice())
         if(OrderModify(glbOrderTicket,entry,stop,take,0,clrNONE) == false) 
            Print("Err (",GetLastError(), ") Modify Sell Price= ",entry," SL= ",stop," TP= ",take);}


//rewritten
bool retval=false;

if(glbOrderType == OP_BUYLIMIT){
         retval=OrderSelect(glbOrderTicket, SELECT_BY_TICKET, MODE_TRADES);
         if(entry != OrderOpenPrice())
         if(OrderModify(glbOrderTicket,entry,stop,take,0,clrNONE) == false) 
            Print("Err (",GetLastError(), ") Modify Sell Price= ",entry," SL= ",stop," TP= ",take);}
 

and i use to code this like the example:

if(OrderModify(glbOrderTicket,entry,stop,take,0,clrNONE) == false) <-----your code

if(!OrderModify(glbOrderTicket,entry,stop,take,0,clrNONE)) <----- my example
 

same thing here

if(OrderSelect(glbOrderTicket, SELECT_BY_TICKET, MODE_TRADES) == true)<---- your code

if(!OrderSelect(glbOrderTicket, SELECT_BY_TICKET, MODE_TRADES))break; <----- my example
 
Kenneth Parling:

same thing here

Thank you, that was educational indeed, I appreciate it
 
Alex Go:
Thank you, that was educational indeed, I appreciate it

you're welcome 😉

 
Kenneth Parling:

the point using it is to keep track of it's own orders and not be in conflict with any other advisers open orders

You have kept track with this code.

if(OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)