[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 228

 
Vinin:

Do the cycle in reverse. From more to less.

like this? Because I don't know anything about cycles.

for(int i=0; i>=OrdersTotal(); i++)
 
anton777:

like this? Because I don't know about cycles.


for(int i=OrdersTotal()-1; i>=0;i--)
  {
     if(OrderSelect(i, SELECT_BY_POS)==true)
       {
          if(i==2)
            {
               int Ord_ticket=OrderTicket();
               Comment("Ord_ticket = ",Ord_ticket);
            }
       }
  }
 
Vinin:


now it won't close.

here's the function where you can put OrderClose() ?

//+-------------------------------------------------------------------------------------------+
//|  Описание : Возвращает цену открытия предпоследней открытой позиции или -1                |
//+-------------------------------------------------------------------------------------------+
//|  Параметры:                                                                               |
//|    sy - наименование инструмента   (""   - любой символ, NULL - текущий символ)           |
//|    op - операция                   (-1   - любая позиция)                                 |
//|    mn - MagicNumber                (-1   - любой магик)                                   |
//+-------------------------------------------------------------------------------------------+
double GetPrePricePos(string sy="", int op=-1, int mn=-1) {
  datetime o;
  double   l=-1;
  int      i, k=OrdersTotal()-1;

  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()==OP_BUY || OrderType()==OP_SELL) {
          if (op<0 || OrderType()==op) {
            if (mn<0 || OrderMagicNumber()==mn) {
              if (o<OrderOpenTime()) {
                o=OrderOpenTime();
                l=OrderOpenPrice();
              }
            }
          }
        }
      }
    }
  }
  return(l);
}


// Use the SRC button //

 
Is it possible to get the indicator to do a re-run without the arrival of another tick?
 

As far as I understand it, if there are more than 8 decimal places, the calculations will automatically be rounded down to those 8 decimal places! Is it possible to increase this value?

 

Actually, there are 15 significant decimal digits. But such a number occupies 8 bytes of memory.
Why do you need such an amazing accuracy of calculations (more than 8 digits)?

 
MikeM:
Is it possible to make the indicator perform a re-run without the arrival of another tick?
Service scripts for MT4.
 
Lians:

I have a question:

I know that with EAs and scripts, you can only create and modify files in the experts/files folder.

1. Can I work with files in subfolders of this folder?

2. If yes, can you show an example of how this is done in the code?

Or maybe someone has a dll-case that allows you to work with files not in this directory?

4. Or maybe who knows some external software to continuously sync the files folder from another folder on the computer?

1. Yes, you can.

2. Add another folder name to files folder with a slash: files\mydirectory\myfile.dat

3. I have a DLL, but haven't tested it yet. There is such a library.

4. This can and should be done with symbolic or hard and soft links. It's easier than syncing.

 
MikeM:

Actually, significant decimal digits there are 15. But such a number occupies 8 bytes in memory.
Why do you need such an amazing accuracy of calculations (more than 8 digits)?

Trying to work with matrices... I tried to work around this, but it still comes up. It's a bit of a stretch to get around it, as the logical explanations for the actions start to get lost.

Regarding 15 digits - checked, normally only 8 decimal places, so I wonder if it's possible to extend.

 
dzhini:

About the 15 digits - I checked, only 8 decimal places, so I'm wondering if it's possible to extend it.

How did you check? I get 15.

MikeM:
Is it possible to force the indicator to re-draw without the arrival of another tick?
Redraw what? Chart objects or chart updates?