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

 
Isn't it time to merge all the MT4 help threads into one?
 
Renat Akhtyamov:
Isn't it time to merge all threads about MT4 into one?

Each author has his own branch. It's just that one author runs it and the other author doesn't and won't. It's just a place for those who want to help. Why would I want to shove my branch into a branch of an author who is not going to help me with mql4?

 
Artyom Trishkin:
and I think so, too.
 

Hello.

Where can I find the language description for MT4?

 
DVlad:

Hello.

Where can I find the language description for MT4?

In MetaEditor on F1. Or here, same thing, but online. You can also google books on C++.
Справочник MQL4
Справочник MQL4
  • docs.mql4.com
Справочник MQL4
 

Hello.

Help me find the price of the last order.

This function finds the price of the oldest order and I need the youngest one.

What to change?


double GetOrderOpenPrice(string sy="", int op=-1, int mn=-1) {
  datetime t;
  double   r=0;
  int      i, k=OrdersTotal();

  if (sy=="0") sy=Symbol();
  for (i=0; i<k; i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      if (OrderSymbol()==sy || sy=="") {
        if (OrderType()>1 && OrderType()<6) {
          if (op<0 || OrderType()==op) {
            if (mn<0 || OrderMagicNumber()==mn) {
              if (t<OrderOpenTime()) {
                t=OrderOpenTime();
                r=OrderOpenPrice();
              }
            }
          }
        }
      }
    }
  }
  return(r);
}
 
Marina Korotkih:

Hello.

Help me find the price of the last order.

This function finds the price of the oldest order and I need the youngest one.

What to change?


double GetOrderOpenPrice(string sy="", int op=-1, int mn=-1) {
  datetime t;
  double   r=0;
  int      i, k=OrdersTotal();

  if (sy=="0") sy=Symbol();
  for (i=0; i<k; i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      if (OrderSymbol()==sy || sy=="") {
        if (OrderType()>1 && OrderType()<6) {
          if (op<0 || OrderType()==op) {
            if (mn<0 || OrderMagicNumber()==mn) {
              if (t<OrderOpenTime()) {
                t=OrderOpenTime();
                r=OrderOpenPrice();
              }
            }
          }
        }
      }
    }
  }
  return(r);
}
Well, that's the latest, that is, the newest
 
Marina Korotkih:

Hello.

Help me find the price of the last order.

This function finds the price of the oldest order and I need the youngest one.

What to change?


double GetOrderOpenPrice(string sy="", int op=-1, int mn=-1) {
  datetime t;
  double   r=0;
  int      i, k=OrdersTotal();

  if (sy=="0") sy=Symbol();
  for (i=0; i<k; i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      if (OrderSymbol()==sy || sy=="") {
        if (OrderType()>1 && OrderType()<6) {
          if (op<0 || OrderType()==op) {
            if (mn<0 || OrderMagicNumber()==mn) {
              if (t<OrderOpenTime()) {
                t=OrderOpenTime();
                r=OrderOpenPrice();
              }
            }
          }
        }
      }
    }
  }
  return(r);
}
That's how it determines the price of the last order.
 
Alekseu Fedotov:
That's how it determines the price of the last order.
Vitaly Muzichenko:
Well, it is the most recent, i.e. the newest

No, the function returns the sellstop price 1.07057 and I need the price of the fourteenth sellstop order 1.06637


price
 
Marina Korotkih:

No, the function returns the sellstop price 1.07057 and I need the price of the fourteenth sellstop order 1.06637

double GetOrderOpenPrice(string sy="", int op=-1, int mn=-1) {
 double r=-1;
 if (sy=="0") sy=Symbol();
  for (int i=0; i<OrdersTotal(); i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      if (OrderSymbol()==sy || sy=="") {
        if (OrderType()>1 && OrderType()<6) {
          if (op<0 || OrderType()==op) {
            if (mn<0 || OrderMagicNumber()==mn) {
              if (r>OrderOpenPrice() || r==-1) {
                r=OrderOpenPrice();
  }}}}}}}
  return(r);
}
Reason: