Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 768

 
Leonid123456:

Hello.

There is a task like this. (can't attach it to a tick)

If a pending order triggers {then...}.

In my EA, I use Terminal.mqh to calculate orders.

Terminal // Mas_Tip[0] open Buy

// if the number of Buy ordershas increased by 1

if (Mas_Tip[0]+1)

{

function

}

Everything works. But it triggers on every next tick.

How to attach this case to a tick? And then compare the value on the previous tick and on the current tick.

And can you translate the highlighted string into our human language? What it should be and what you get when executing this line...
 
AlexeyVik:
Can you translate the highlighted line into our language? What should be and what you get when executing this line...

// if the number ofBuy ordershas increased by 1 then...

{

function e.g. opens or closes other orders...

}

It doesn't have to be like thisif (Mas_Tip[0]+1) we can doif (Mas_Tip[0] >Mas_Tip[1]) // if there are more Buy orders than Cell. Open a pending one, for example.

The point is that on the next tick this data is true again.

 
Leonid123456:

// if the number ofBuy ordershas increased by 1 then...

{

function e.g. opens or closes other orders...

}

if (Mas_Tip[0]+1)

In the parentheses of if there should be a bool, i.e., true or false.

Here it is obviously int. That is an integer.

Of course, true is 1 and false is 0 (if I'm not mistaken). But still it is not right. What doesMas_Tip[0] return?

 
ikatsko:

if (Mas_Tip[0]+1)

in parentheses of if should be a bool, i.e. true or false.

But here it is obviously int. That is an integer.

Of course, true is 1 and false is 0 (if I'm not mistaken). But still it is not right. What doesMas_Tip[0] return?

Number of open Buy orders.

 
Leonid123456:

// if the number ofBuy ordershas increased by 1 then...

{

function e.g. opens or closes other orders...

}

No, that's what you want. Actually it's not. There is some value in the array Mas_Tip[0], and if it is greater than zero, the condition if(Mas_Tip[0]) will be true. And if we add 1 to this value, it will always be true since the number of open orders cannot be equal to -1.

 
AlexeyVik:

No, that's the way you want it. In fact, it's not. There is some value in the array Mas_Tip[0] and if it is greater than zero, the condition if(Mas_Tip[0]) will already be true. And if we add 1 to this value, it will always be true since the number of open orders cannot be equal to -1.


I tried to do it in this way

   bool  Fact_1 = false;                    // Глобальная перемен.
       bool  Fact_2 = false;                    // Глобальная перемен.
//--------------------------------------------------------------------
int start()                                     // Спец. функция start
  {
                          // Локальная перемен.
   if (Fact_2==true)                            //Если сообщение уже..
      return;                                   //..было, то выходим
 
   if (Mas_Tip[0]+1)
      Fact_1 = true;                            // Произошло событие 1
 
   
 
   return;                                      // Выход из start()
  }
//--------------------------------------------------------------------
                               // Пользовательс. ф-ия
  {
             // Сообщение
   Fact_2 = true;                               // Произошло событие 2
   return;                                      // Выход из польз.ф-ии

}

It turns out to be a one-time event.

 
ikatsko:

if (Mas_Tip[0]+1)

in parentheses of if should be a bool, i.e. true or false.

But here it is obviously int. That is an integer.

Of course, true is 1 and false is 0 (if I'm not mistaken). But still it is not right. What doesMas_Tip[0] return?

false is 0 and true if it is not 0.

Try this line

bool b;
b = 7.40;
if(b) Print("b = ", b);
The compiler may warn about a possible loss of precision, but it will work.
 

you can discardMas_Tip[0]

How to get an event. A Buy has opened.

 
Leonid123456:

you can discardMas_Tip[0]

How to get an event. A Buy has opened.

Remember the old Buy count in some variable and compare it with the current value returned by the Buy Counting function, how else?
 
evillive:
remember the old number of Byes and compare it with the current number, how else?
That's exactly what's not working.
Reason: