OrderSelect function question - page 4

 
boopa26:

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 


When you are asking others for assistance you should make your code as easy to read as possible, that includes using true or false with bools.

Using numbers can lead to mistakes such as this


   bool a=1;
   bool b=-1;
   if(a+b==0)
      Print("a+b equals 0");
   else
      Print("a+b does not equal 0");
  


You are only increasing a if an OrderSelect fails, where does it get reset?

You do not have a loop in your code, where does it cycle through orders?

 
Keith Watford:


When you are asking others for assistance you should make your code as easy to read as possible, that includes using true or false with bools.

Using numbers can lead to mistakes such as this


   bool a=1;
   bool b=-1;
   if(a+b==0)
      Print("a+b equals 0");
   else
      Print("a+b does not equal 0");
  


You are only increasing a if an OrderSelect fails, where does it get reset?

You do not have a loop in your code, where does it cycle through orders?

You are only increasing a if an OrderSelect fails, where does it get reset?

a does not get reset

You do not have a loop in your code, where does it cycle through orders?

it was a mistake to write cycle but code matters not comments 

 

Well, you obviously know everything.

Why are you asking for assistance?

 
Keith Watford:

Well, you obviously know everything.

Why are you asking for assistance?

i can do

if(OrdersHistoryTotal()>0&&
   OrderProfit()<0)

 that works but i wanted to understand how to select last history order then determine if last history order was loss or profit

 
boopa26:

i can do

if(OrdersHistoryTotal()>0&&
   OrderProfit()<0)

 that works but i wanted to understand how to select last history order then determine if it was loss or profit

That does not work as you have not selected an order. I can not think of any reason for the 2 tests to be in the same if() without an OrderSelect()
 
Keith Watford:
That does not work as you have not selected an order. I can not think of any reason for the 2 tests to be in the same if() without an OrderSelect()

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

   a++;

if(OrdersHistoryTotal()>0&&OrderProfit()<0)

read now
 

Why are you showing

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

   a++;

in reponse to a comment on

if(OrdersHistoryTotal()>0&&
   OrderProfit()<0)

?

They obviously have nothing to do with each other

 
Keith Watford:

Why are you showing

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

   a++;

in reponse to a comment on

if(OrdersHistoryTotal()>0&&
   OrderProfit()<0)

?

They obviously have nothing to do with each other

then why does it do what it does? it works inside my mt4 terminal
 
boopa26:
then why does it do what it does? it works inside my mt4 terminal

It may well do something, but I doubt very much that it does what you expect.

Otherwise why are you posting a questiom?

Re-write the code in a logical way so that individual blocks work with each other. Use a loop to cycle through orders and do not use a globally declared variable for the order index/

 
Keith Watford:

It may well do something, but I doubt very much that it does what you expect.

Otherwise why are you posting a questiom?

Re-write the code in a logical way so that individual blocks work with each other. Use a loop to cycle through orders and do not use a globally declared variable for the order index/

ok. thank you
Reason: