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

 
Armen63:
Hello, how to implement a condition in the code of the Expert Advisor to set the same type of orders 50 pips after the last order
//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 19.02.2008                                                     |
//|  Описание : Возвращает расстояние в пунктах между рынком и ближайшей       |
//|             позицей                                                        |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    sy - наименование инструмента   ("" или NULL - текущий символ)          |
//|    op - торговая операция          (    -1      - любая позиция)           |
//|    mn - MagicNumber                (    -1      - любой магик)             |
//+----------------------------------------------------------------------------+
int DistMarketAndPos(string sy="", int op=-1, int mn=-1) {
  double d, p;
  int i, k=OrdersTotal(), r=1000000;

  if (sy=="" || sy=="0") sy=Symbol();
  p=MarketInfo(sy, MODE_POINT);
  if (p==0) if (StringFind(sy, "JPY")<0) p=0.0001; else p=0.01;
  for (i=0; i<k; i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      if ((OrderSymbol()==sy) && (op<0 || OrderType()==op)) {
        if (mn<0 || OrderMagicNumber()==mn) {
          if (OrderType()==OP_BUY) {
            d=MathAbs(MarketInfo(sy, MODE_ASK)-OrderOpenPrice())/p;
            if (r>d) r=NormalizeDouble(d, 0);
          }
          if (OrderType()==OP_SELL) {
            d=MathAbs(OrderOpenPrice()-MarketInfo(sy, MODE_BID))/p;
            if (r>d) r=NormalizeDouble(d, 0);
          }
        }
      }
    }
  }
  return(r);
}
 

Please advise where to insert a line in the code in the attached indicator, I don't know anything about it. The thing is that this indicator shows the movement of currency pairs in a separate window but because one of the pairs is missing in the market overview window does not show anything. I have been advised to use this one:

Error may occur only in this place

double Vol = iCustom(s[n],0, "Ind ZeroLag MACD",FastEMA,SlowEMA,0,0) / MarketInfo(s[n], MODE_POINT);

when there is no data on MarketInfo(symbol, MODE_POINT), we get a division by zero.

insert check in MarketInfo(symbol, MODE_POINT)

I don't know where to put it ( I don't see GBP/NZD pair in market overview) . Please advise.

Files:
indicator.mq4  6 kb
 
BeerGod:

Function "DistMarketAndPos" is not referenced and will be removed from exp-file

 
Armen63:
Function "DistMarketAndPos" is not referenced and will be removed from exp-file

There is no reference to it in the code of the Expert Advisor, this function gives the number of pips between the market price and the opening price of the order, compare this value and if it is equal to or greater than 50, you are allowed to open a new order.
 
first_may:
Good afternoon, could you tell me if there is an indicator in MT4 that shows open interest? If not, can it be replaced by something similar?

Not anymore, not yet, there will be.
 
What do you mean, not anymore? It turns out that some time ago, there was such an indicator?
 
Has anyone encountered such a problem as lack of quotes?

Neither in the tester nor in the live chart there's nothing from January 13 to May 17... Even as if uploaded in the terminal through the menu "Tools-->Quotes Archive"...


 
It has happened before, I think this is the intrigue of DC so that it would be problematic to test anything.
 
first_may:
What do you mean, not anymore? It turns out that some time ago, there was such an indicator?

Yes, it was, it's in codebase.
 
FAQ:

Yes, it was, it's in codebase.

What criteria do you use to find it in codebase?
Reason: