OrderSelect function question - page 3

 

"OrderSelect()" return and integer, when the documentation clearly states that it returns a Boolean?

boolean is 0 or 1

You don't even check the result of the "OrderClose()" or if an run-time error occurred! ill write the code after i understand order select FMIC

c programming is important to understand. happy?

 
boopa26:

"OrderSelect()" return and integer, when the documentation clearly states that it returns a Boolean?

boolean is 0 or 1

You don't even check the result of the "OrderClose()" or if an run-time error occurred! yes but that comes after FMIC

It is already a Boolean, you don't need to compare it with anything, be that another Boolean constant or a typecast Integer. You should not hard-code internal represented Boolean values! You should use "true" or "false", but ideally only when initializing a variable, not in comparisons.

if(  OrderSelect( ... ) )  // instead of "if( OrderSelect( ... ) == true )"
if(  OrderSelect( ... ) )  // instead of "if( OrderSelect( ... ) == 1 )"
if( !OrderSelect( ... ) )  // instead of "if( OrderSelect( ... ) == false )"
if( !OrderSelect( ... ) )  // instead of "if( OrderSelect( ... ) == 0 )"

Had you bothered to learn "C", you would have known this!

 

this is my question

what switches order select function from false to true?

i understand ! equals not

examples

if not order select or if order select BUT

by default order select is 0 so what switches order select from 0 to 1?

documentation reads

"Returned value

It returns true if the function succeeds,"

thats not enough information for me to understand


thank you FMIC

 
boopa26:

just this forum

eddie do you know anything about order select function?

Of course i know.

I have learned from other coders and i'm able to read the MQL books and manuals.

But the most important point is: i have learned to use the debugger. It saved me a lot of time searching for MY analytical an codeing mistakes.

 
well done eddie
 
boopa26: i understand ! equals not

If you understand, why did you not do it correctly in the first place!

boopa26: this is my question

what switches order select function from false to true?

examples

if not order select or if order select BUT

by default order select is 0 so what switches order select from 0 to 1?

documentation reads

"Returned value It returns true if the functionsucceeds,"

thats not enough information for me to understand

There is no "default" nor does it switch from one value to another! It either succeeds in selecting the order and returns "true"; or it fails, returning "false" and you have to check the Error code to find out why!

 
  1. boopa26: wants to write order select function to close orders without for cycles or while cycles.
    Then posts code with cycles
  2. boopa26: reading documentation now https://docs.mql4.com/trading/orderselect
    Posts questions before reading.
  3. boopa26:

    1. does not need c knowledge. mql4 is different functions

    3. read documentation already

    4. written code already

    Then contradicts himself about the documentation. and becomes argumentive.
  4. Musngi gets banned and boopa26 suddenly appears. Coincidental? I don't think so.

Please do not feed the troll. When you respond, you give the troll power. When you ignore the troll, he starves for attention and eventually dies.

 

hello i can cycle order select to find open orders but i cannot cycle order select to find closed order profits. example i want to find last closed order profit

this code cycles order select to find open orders

static int a;

//cycle order select

if(OrdersTotal()>0&&
   a<OrdersTotal()&&
   OrderSelect(a,SELECT_BY_POS,MODE_TRADES)==0)

   a++;

//close open order

if(OrdersTotal()>0&&
   OrderSelect(a,SELECT_BY_POS,MODE_TRADES)==1&&
   OrderMagicNumber()==magic_number&&
   OrderType()==OP_BUY&&
// close order signal)
  
   OrderClose(OrderTicket(),lots_2,Bid,3,Blue);

https://docs.mql4.com/trading/orderselect

https://docs.mql4.com/trading/orderprofit

 

maybe this

if(OrdersHistoryTotal()>0&&
   b<OrdersHistoryTotal()&&
   OrderSelect(b,SELECT_BY_POS,MODE_HISTORY)==0)

   b++;


 


 

 
static int a;

//cycle order select

if(OrdersTotal()>0&&
   a<OrdersTotal()&&
   OrderSelect(a,SELECT_BY_POS,MODE_TRADES)==0)

   a++;

//close open order

if(OrdersTotal()>0&&
   OrderSelect(a,SELECT_BY_POS,MODE_TRADES)==1&&
   OrderMagicNumber()==magic_number&&
   OrderType()==OP_BUY&&
// close order signal)
  

   OrderClose(OrderTicket(),lots_2,Bid,3,Blue);

static int a;

yiu do not initialize variable a and why is it static?


OrderSelect(a,SELECT_BY_POS,MODE_TRADES)==0)

You have already been told that you should use true or false, not 1 or 0

OrderSelect(a,SELECT_BY_POS,MODE_TRADES)==false)
// OR
!OrderSelect(a,SELECT_BY_POS,MODE_TRADES))


You are not cycling through the orders

 
Keith Watford:
static int a;

//cycle order select

if(OrdersTotal()>0&&
   a<OrdersTotal()&&
   OrderSelect(a,SELECT_BY_POS,MODE_TRADES)==0)

   a++;

//close open order

if(OrdersTotal()>0&&
   OrderSelect(a,SELECT_BY_POS,MODE_TRADES)==1&&
   OrderMagicNumber()==magic_number&&
   OrderType()==OP_BUY&&
// close order signal)
  

   OrderClose(OrderTicket(),lots_2,Bid,3,Blue);

static int a;

yiu do not initialize variable a and why is it static?


OrderSelect(a,SELECT_BY_POS,MODE_TRADES)==0)

You have already been told that you should use true or false, not 1 or 0

OrderSelect(a,SELECT_BY_POS,MODE_TRADES)==false)
// OR
!OrderSelect(a,SELECT_BY_POS,MODE_TRADES))


You are not cycling through the orders

static int a; sits above start(){ GLOBAL VALUE

theres no difference 1 or 0. true or false

i am increasing value a after conditions take effect