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

 
paladin80:
What does it mean to consider an indicator in the tester? (1) Maybe the indicator of another timeframe should be displayed during visualization, or (2) in the EA code, in the function of the indicator you need to calculate a value for another timeframe?

there are several indicators linked to several timeframes in the EA, if I use comment() function, then it displays only indicator values for tested timeframe, other indicator values remain unchanged, I suppose that during the test indicators of other timeframes are not taken into account.

 Comment(   "\n Pic1 ", pic1,
   "\n Pic5 ", pic5,
   "\n Pic15 ", pic15,
   "\n Pic30 ", pic30,
   "\n Pic60 ", pic60,
   "\n Pic240 ", pic240);

where numbers 1, 5, 15, 30, 60, 240, correspond to timeframes m1, m5, m15, m30, H1, H4

As a result, when testing at 4 o'clock, only p240 is displayed, the rest of values hangs on the start, on the hour, only p60 changes value and so on...

Going back to my question, is there a way to correct display of values in the tester for different timeframes and take into account values from different timeframes or current for the tested timeframe?

 
vilard:

I have several indicators linked to several timeframes, if I use the comment() function, then only indicator values for the tested timeframe are displayed, other indicator values remain unchanged, I assume that indicators of other timeframes are not taken into account in the test either.

...

First, show me the part of the code where you find in the EA the indicator values for other timeframes. I suspect there may be an error there.
 
Hello! Could you please tell me how to record that an order is opened only once (while the condition is met) and when the order closes (even if the condition is still met) no more orders are executed!
 
how to make an order open once an hour and only at the beginning of the hour
 
shljachov:
how to make an order open once per hour and only at the beginning of the hour
int TimeBar_t = (TimeCurrent()-Time[0])/60; // время в минутах с открытия свечи

or

https://docs.mql4.com/ru/dateandtime/minute

only naturally check if an order is opened so that another one is not opened

 
Hello , help with code !!! I need an order to open based on a condition once an hour at the beginning of the hour ( on a new hourly bar) and regardless of the result a new opening was only after 1 hour or 2 or 3 etc. and also only at the beginning of the hour (on a new hourly bar) depending on the condition ?????
 
//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 19.02.2008                                                     |
//|  Описание : Возвращает количество секунд после открытия последней позиций. |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    sy - наименование инструмента   (""   - любой символ,                   |
//|                                     NULL - текущий символ)                 |
//|    op - операция                   (-1   - любая позиция)                  |
//|    mn - MagicNumber                (-1   - любой магик)                    |
//+----------------------------------------------------------------------------+
datetime SecondsAfterOpenLastPos(string sy="", int op=-1, int mn=-1) {
  datetime t;
  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()==OP_BUY || OrderType()==OP_SELL) {
          if (op<0 || OrderType()==op) {
            if (mn<0 || OrderMagicNumber()==mn) {
              if (t<OrderOpenTime()) t=OrderOpenTime();
            }
          }
        }
      }
    }
  }
  return(TimeCurrent()-t);
}
//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 19.02.2008                                                     |
//|  Описание : Возвращает количество секунд после закрытия последней позиций. |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    sy - наименование инструмента   (""   - любой символ,                   |
//|                                     NULL - текущий символ)                 |
//|    op - операция                   (-1   - любая позиция)                  |
//|    mn - MagicNumber                (-1   - любой магик)                    |
//+----------------------------------------------------------------------------+
datetime SecondsAfterCloseLastPos(string sy="", int op=-1, int mn=-1) {
  datetime t;
  int      i, 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();
            }
          }
        }
      }
    }
  }
  return(TimeCurrent()-t);
}
https://www.mql5.com/ru/forum/131859
 
thanks a lot 604 BeerGod 03.09.2012 13:06
 
paladin80:
First, show the part of the code where you find the indicator values for other timeframes in the EA. The suspicion is that there might be an error lurking there.
 int pic1=GetExtremumZZBar("",PERIOD_M1,0,12,5,3);
   int pic5=GetExtremumZZBar("",PERIOD_M5,0,12,5,3);
   int pic15=GetExtremumZZBar("",PERIOD_M15,0,12,5,3);
   int pic30=GetExtremumZZBar("",PERIOD_M30,0,12,5,3);
   int pic60=GetExtremumZZBar("",PERIOD_H1,0,12,5,3);
   int pic240=GetExtremumZZBar("",PERIOD_H4,0,12,5,3);

Kim's function

//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 07.10.2006                                                     |
//|  Описание : Возвращает номер бара экстремума ЗигЗага по его номеру.        |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    sy - наименование инструмента   (NULL или "" - текущий символ)          |
//|    tf - таймфрейм                  (      0     - текущий ТФ)              |
//|    ne - номер экстремума           (      0     - последний)               |
//|    dp - ExtDepth                                                           |
//|    dv - ExtDeviation                                                       |
//|    bs - ExtBackstep                                                        |
//+----------------------------------------------------------------------------+
int GetExtremumZZBar(string sy="", int tf=0, int ne=0, int dp=12, int dv=5, int bc=3) {
  if (sy=="" || sy=="0") sy=Symbol();
  double zz;
  int    i, k=iBars(sy, tf), ke=0;

  for (i=0; i<k; i++) {
    zz=iCustom(sy, tf, "ZigZag", dp, dv, bc, 0, i);
    if (zz!=0) {
      ke++;
      if (ke>ne) return(i);
    }
  }
  Print("GetExtremumZZBar(): Экстремум ЗигЗага номер ",ne," не найден");
  return(-1);
}
 
Hmm, try it this way:
   int pic1=GetExtremumZZBar(NULL,PERIOD_M1,0,12,5,3);
   int pic5=GetExtremumZZBar(NULL,PERIOD_M5,0,12,5,3);
   int pic15=GetExtremumZZBar(NULL,PERIOD_M15,0,12,5,3);
   int pic30=GetExtremumZZBar(NULL,PERIOD_M30,0,12,5,3);
   int pic60=GetExtremumZZBar(NULL,PERIOD_H1,0,12,5,3);
   int pic240=GetExtremumZZBar(NULL,PERIOD_H4,0,12,5,3);

//---
int GetExtremumZZBar(string sy, int tf, int ne, int dp, int dv, int bc) {
...
}