Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1622

 
makssub #:

... I'll check it out one of these days.

Today or the other day?

That's troubling...

 
Roman Sharanov NULL.
But if I just copy the code from the first constructor to the second one and don't call it, everything works. What is the problem?
PapaYozh #:


The problem is in MQL.

In such situations, I put initialization in separate method which I pull from different constructors.

---

There is also a problem with calling the parent constructor.

The problem is in not understanding what is happening when calling it:

CWave(namePref, startPrice, startTime, endPrice, endTime);

And here it's simple. A CWave object is created and immediately destroyed))) This temporary object has nothing to do with the instance in whose constructor the call was made)))

 
Vladimir Simakov #:

The problem is not understanding what happens when you make a call:

And here it's simple. A CWave object is created and immediately destroyed.) This temporary object has nothing to do with the instance in whose constructor the call was made)))

Where did you see the new operator?
 

Good day all!!!

I am writing a grid EA, I need to find a profit only for the order with the maximum ticket and the order with the minimum ticket (the minimum is for later), now I want to find a profit for the maximum order. I am attaching the function and a picture which shows the principle of opening a grid of orders. My question is, am I correct in writing the function for calculating the profit of an order with a maximal ticket? Thanks in advance.

//+----------------------------------------------------------------------------+
//| Расчет профита максимального ордера в сетке                                |
//+----------------------------------------------------------------------------+
double GetProfitMaxOrder(int otype)
{
  int max_ticket=0;
  double max_ticket_profit = 0;
         ticket = 0;
  {
   for (int cnt = OrdersTotal() - 1; cnt >= 0; cnt--) 
    {
    if(OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderType() == otype)
      {
        max_ticket = OrderTicket();
        if(max_ticket > ticket)
        {
          ticket = max_ticket;
          max_ticket_profit = OrderProfit();
        }
      }
    }
  }
  return(max_ticket_profit);
}

 
Сергей Таболин #:

So today or the other day?

It's a bit alarming...

It's fine. I wanted to check now, but they called me and I realised I wouldn't be back soon. That's quite a report, isn't it?)

 
EVGENII SHELIPOV #:

Good day all!!!

I am writing a grid EA, I need to find a profit only for the order with the maximum ticket and the order with the minimum ticket (the minimum is for later), now I want to find a profit for the maximum order. I am attaching the function and a picture which shows the principle of opening a grid of orders. My question is, am I correct in writing the function for calculating the profit of an order with a maximal ticket? Thanks in advance.

//+----------------------------------------------------------------------------+
//| Расчет профита максимального ордера в сетке                                |
//+----------------------------------------------------------------------------+
double GetProfitMaxOrder(int otype)
{
  int max_ticket=0;
  double max_ticket_profit = 0;
  {
   for (int cnt = OrdersTotal() - 1; cnt >= 0; cnt--) 
    {
    if(OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderType() == otype)
      {
      if(max_ticket < OrderTicket())
         {
         max_ticket = OrderTicket();
         max_ticket_profit = OrderProfit()+OrderCommission()+OrderSwap();
        }
      }
    }
  }
  return(max_ticket_profit);
}
 
Vladimir Simakov #:

The problem is not understanding what happens when you make a call:

And here it's simple. A CWave object is created and immediately destroyed.) This temporary object has nothing to do with the instance in whose constructor the call was made)))


Don't get fancy. The essence of what happens is that you call a method that is a constructor with a different set of parameters. No object is created by this.

A similar constructor call, which also will not lead to the desired result:

this.CWave(namePref, startPrice, startTime, endPrice, endTime);
 
Good afternoon. Please advise how to find the opening price of the nearest order to the current price. MQL4. Do you have any examples?
 

Hello, could you please tell me if I understand the expression correctly?

MaxMartinLot = Lot*MathPow(K_Martin,OrdersClose); - means K_Martin , to the extent of OrdersClose ?

 
законопослушный гражданин #:

Hello, could you please tell me if I understand the expression correctly?

MaxMartinLot = Lot*MathPow(K_Martin,OrdersClose); - means K_Martin , to the extent of OrdersClose ?

What is OrdersClose ?

See here