[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 299

 
GarKain:
people, is there a virtual dedicated server anywhere on the internet for free?
No.
 

Guys who are friendly with Pyatra. Look at my Indy for the championship, please. I'm stuck - I can't decide...

Translating from 4 to 5 - there on the forum - silence. Put the code in the branch - on this page. Description - on the previous one.

Thanks.

 
bool isCloseLastPosByTake(string sy="", int op=-1, int mn=-1) {
  datetime t;
  double   ocp, otp;
  int      dg, i, j=-1, k=OrdersHistoryTotal();

  if (sy=="0") sy=Symbol();
  for (i=0; i<k; i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) {
      if (OrderSymbol()==sy || sy=="") {
        if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
          if (op<0 || OrderType()==op) {
            if (mn<0 || OrderMagicNumber()==mn) {
              if (t<OrderCloseTime()) {
                t=OrderCloseTime();
                j=i;
              }
            }
          }
        }
      }
    }
  }
  if (OrderSelect(j, SELECT_BY_POS, MODE_HISTORY)) {                     // !!!!!!!!?????? ХОТЬ КТО-ТО МОЖЕТ ОБЪЯСНИТЬ ЗНАЧЕНИЕ СТРОК КОДА, КОТОРЫЕ НАЧИНАЮТСЯ С ЭТОГО МЕСТА?
    dg=MarketInfo(sy, MODE_DIGITS);
    if (dg==0) if (StringFind(OrderSymbol(), "JPY")<0) dg=4; else dg=2;
    ocp=NormalizeDouble(OrderClosePrice(), dg);
    otp=NormalizeDouble(OrderTakeProfit(), dg);
    if (ocp==otp) return(True);
  }
  return(False);
 
okvseok:

bool isCloseLastPosByTake(string sy="", int op=-1, int mn=-1) {
 datetime t;
 double ocp, otp;
 int dg, i, j=-1, k=OrdersHistoryTotal();

 if (sy=="0") sy=Symbol();
 for (i=0; i<k; i++) {
 if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) {
 if (OrderSymbol()==sy || sy=="") {
 if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
 if (op<0 || OrderType()==op) {
 if (mn<0 || OrderMagicNumber()==mn) {
 if (t<OrderCloseTime()) {
 t=OrderCloseTime();
 j=i;
 }
 }
 }
 }
 }
 }
 }
 // !!!!!!!!?????? ХОТЬ КТО-ТО МОЖЕТ ОБЪЯСНИТЬ ЗНАЧЕНИЕ СТРОК КОДА, КОТОРЫЕ НАЧИНАЮТСЯ С ЭТОГО МЕСТА?
 if (OrderSelect(j, SELECT_BY_POS, MODE_HISTORY)) {// Если очередной ордер истории торгов выбран, то
 dg=MarketInfo(sy, MODE_DIGITS);// переменная dg принимет значение дигитса по валютной паре, имя которой лежит в переменной sy
 // далее я возможно не верно расставил приоритет скобок, но по сути должно быть так:
 if (dg==0){// если дигитс равен нулю, то
 if(StringFind(OrderSymbol(),"JPY")<0){// если в имени инструмента ордера найдена подстрока то (только это не правильно написано - функция может верноуть значение > 1)
 dg=4;// дигитс принимает значение = 4
 }
 else{// иначе
 dg=2;// дигитс принимает значение = 2
 }
 }
 ocp=NormalizeDouble(OrderClosePrice(), dg);// нормализация цены закрытия ордера
 otp=NormalizeDouble(OrderTakeProfit(), dg);// нормализация цены ТейкПрофита ордера
 if (ocp==otp) return(True);
 }
 return(False);// команда вернуть из подпрограммы значение "ложь"
 }
 
drknn:

bool isCloseLastPosByTake(string sy="", int op=-1, int mn=-1) {
datetime t;
double ocp, otp;
int dg, i, j=-1, k=OrdersHistoryTotal();

if (sy=="0") sy=Symbol();
for (i=0; i<k; i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) {
if (OrderSymbol()==sy || sy==") {
if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
if (op<0 || OrderType()==op) {
if (mn<0 || OrderMagicNumber()==mn) {
if (t<OrderCloseTime()) {
t=OrderCloseTime();
j=i;
}
}
}
}
}
}
}
// !!!!!!!!?????? CAN ANYONE EXPLAIN THE MEANING OF THE LINES OF CODE THAT START IN THIS PLACE?
if (OrderSelect(j, SELECT_BY_POS, MODE_HISTORY)) {// If the next order of the trading history is selected
dg=MarketInfo(sy, MODE_DIGITS);// the variable dg will accept the value of the digits by the currency pair whose name is in the variable sy
// hereinafter probably I have placed the brackets incorrectly but in fact it should be like this
if (dg==0){// if digits is zero, then
if(StringFind(OrderSymbol(), "JPY")<0){// if a substring is found in the order symbol name then (only it is not written correctly - the function can validate > 1)
dg=4;// digits takes value = 4
}
else{// else
dg=2;// digits takes value = 2
}
}
ocp=NormalizeDouble(OrderClosePrice(), dg);// normalize order close price
otp=NormalizeDouble(OrderTakeProfit(), dg);// normalize the order TakeProfit price
if (ocp==otp) return(True);
}
return(False);// command to return(false) from the subroutine
}
thanks, what is digits?
 
okvseok:
thank you, what is digits?

The digits of a trading instrument - how many digits after the decimal point it has.
 
drknn:

Significance of a trade instrument - how many digits after the decimal point it has.

That is, if I know the digits are 4, then the code can be shortened like this?

int dg = 4;

............ code

if (OrderSelect(j, SELECT_BY_POS, MODE_HISTORY)) {

ocp=NormalizeDouble(OrderClosePrice(), dg);// normalize order closing price
otp=NormalizeDouble(OrderTakeProfit(), dg);// normalize order TakeProfit price
if (ocp==otp) return(True);
}

return(False);

}

 
I don't know if it's possible - according to the author's idea (well, it seems to me) this part of the code is designed to automatically determine digits - so that the code can determine exactly how many digits after the decimal point to round prices to. Only this part of the code is uselessly made.
 
Can you please tell me if there is an indicator that calculates the total number of open orders for all pairs involved in the trading process?
 
yosuf:
Can you please tell me if there is an indicator which calculates the total number of open orders for all pairs involved in the trading process?
Nope, no. It is easier to make a simple Expert Advisor which calculates the number of open positions.