[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 185

 

Hello.

Please help me find an error. The code should return the type of the last closed order (in this case a losing order).

Thank you in advance.

string OrdersTypeHistLoss_b(){
  double ProfHist=OrdersProfHist_b();
  string SMB=Symbol();
  string TypeHistLoss;
  int MAGIC;
  int i;
  for (i=0; i<OrdersHistoryTotal(); i++) {//Начало цикла
     if (OrderSelect(i,SELECT_BY_POS,MODE_HISTORY) == true) {
      if(OrderSymbol()==SMB) {
       if(OrderMagicNumber()==(MAGIC || 777)) {
         if(ProfHist<0){ 
           TypeHistLoss=OrderType();
         }  
        }  
       } 

     }//конец работы с выбранным ордером
   }//Конец цикла
  return(TypeHistLoss);
}
 

if(OrderMagicNumber()==MAGIC || OrderMagicNumber()== 777)) {

 
tara:

if(OrderMagicNumber()==MAGIC || OrderMagicNumber()== 777)) {

if(OrderMagicNumber()==(MAGIC || 777)) {

This line works - I use it in several other subroutines of mine. In any case, I haven't encountered any problems so far.

Thank you.

 

(A puzzling question).

How do I determine programmatically whether a number is even or odd?

For example:

int a, b, c;

a=2;

b=3;

c=a+b

c is even or odd?

One more theoretical question...

Is it worth forced zeroing of the array, if data is written to it dynamically, when new bars appear?

Thanks in advance.

 

1. By the value of the remainder of division by 2.

2. Worth.

 
tara:

1. By the value of the remainder of division by 2.

2. Worth.

The remainder is clear, but what mql function detects the remainder?

 
NickXXX:

(A puzzling question).

How do I determine programmatically whether a number is even or odd?

For example:

int a, b, c;

a=2;

b=3;

c=a+b

c is even or odd?



If the numbers are integers, check the remainder of division by 2

if (c % 2==0) //четное
 
Vinin:


If the numbers are integers, check the remainder of division by 2

Thank you.)
 
NickXXX:

The balance is clear, but what mql function determines whether there is a balance?


https://docs.mql4.com/ru/math/MathMod