Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 639

 

I can't think of anything) there is a line And how do I check if the line has changed

 
ClanVi:

I can't think) there is a line And how do I check if this line has changed



CHARTEVENT_OBJECT_CHANGE

Changing the properties of a graphical object via the properties dialog

Parameter "sparam" returns the name of the changed object. If the object is yours, check the properties that are critical for your object.
 
barabashkakvn:


CHARTEVENT_OBJECT_CHANGE

Changing the properties of a graphical object via properties dialog

The parameter "sparam" returns the name of the changed object. If the object is yours, then check the properties that are critical for your object.

How without an object, if we know the price is a line, we have to check if it has changed, it is clear that we have to compare the price.)

what kind of

if(NormalizeDouble(Price,Digits)-NormalizeDouble(Price2,Digits)!=0)
Price2 = Price;

where to get a measure of Price2))

 
ClanVi:

How without an object, we know the price and this is the line, it is necessary to check whether it has changed or not, it is clear that it is necessary to compare this price I do not know how)

what kind of

where to get a measure of Price2))


the price at the last bar and will be Price2, compare Bid with any price of the last bar of your choice - Open, Close, High, Low.

If you want intermediate prices, you need to save the tick history and take the previous price from there, then the Bid will be compared to the price of the previous tick.

And what is the sense of price normalization? You need to normalize calculated values that will be used in trade orders later, and the price is already normalized.

 
evillive:

the price on the last bar will be Price2

If you want intermediate prices, you have to save the tick history and take the previous price from there.

Got it all figured out :)

No, it wouldn't work with my bars.

 
in the signals, I can only set the maximum risk that the author uses, no more?
 
simpleton:

The search method in the one below is slightly different:

#property strict

/******************************************************************************/
bool AddValue(double &array[], const double value) {
  const int size = ArraySize(array);

  if (ArrayResize(array, size + 1) != size + 1) {
    return false; // Ошибка, значение не может быть добавлено к массиву
  }

  array[size] = value; //записываем
  return true; // Нет ошибки, значение добавлено к массиву
}

/******************************************************************************/
bool AddValueIfFound(double &array[], const string name) {
  const int type = ObjectType(name);

  if (type == OBJ_TREND) {
    switch ((color)ObjectGet(name, OBJPROP_COLOR)) { // Тип color допустимо использовать в switch
    case Goldenrod:
    case Gainsboro:
    case White:
      if (!AddValue(array, ObjectGetValueByShift(name, 1))) {
        return false; // Ошибка, значение найдено, но не может быть добавлено к массиву
      }
    }
  }

  return true; // Нет ошибки, значение, если найдено, добавлено к массиву
}

/******************************************************************************/
bool MassTrendNumber(double &array[], const bool buy) { // Поиск значения цены трендовой линии, текущего бара, запись в массив. Два массива: masS и masB
  const string subname = (buy ? "uptrendline" : "downtrendline"); // существует два названия трендовых линий, первое и второе

  if (ArrayResize(array, 0) != 0) {
    return false; // Ошибка, массив не может быть заполнен достоверно
  }

  for (int i = 0, limit = ObjectsTotal(OBJ_TREND); i < limit; i++) {
    if (!AddValueIfFound(array, subname + IntegerToString(i))|| !FilTrenLin(subname+IntegerToString(i))) { \\ Вот куда вставил
      return false; // Ошибка, массив, если и заполнен, то недостоверно
    }
  }

  return true; // Нет ошибки, массив заполнен достоверно
}
/***************************************************************************/
 bool FilTrenLin(string name) {

const  string   dt_123 = TimeToStr(TimeCurrent(),TIME_SECONDS); //
const  datetime   vremnin= StrToTime(dt_123); // Присваиваем время в секундах 
  
    
const  datetime     vrem2kor= ObjectGet(name,OBJPROP_TIME2);// время второй координаты
    MqlDateTime str1;
    TimeToStruct(vrem2kor,str2);
const  int     PjatPon=str1.sec;

    if(PjatPon+3600>=vremnin){ \\ если время 2-ой координаты + час > времени нынешнего то блокируем запись в массив
   Print("  PjatPon  ", PjatPon,"  vremnin ",vremnin,"  vrem2kor ",vrem2kor);
        return false;
    }  
   return true;
}
/******************************************************************************/ void FillAndPrint(double &array[], const bool buy) {   if (MassTrendNumber(array, buy)) {     const int limit = ArraySize(array);     Print("Найдено объектов: ", limit);     for (int i = 0; i < limit; i++) {       Print("Price[", i, "] = ", DoubleToStr(array[i], Digits));     }   } else {     Print("Чёрт!");   } }

Don't think of it as cheeky, Idon't even know how to address it anymore, but I can't help it. I thought that if I could make up an array, then the conditions would be hammered out, filtering the signal like nothing else.

 
Top2n:

Don't mind me, Idon't even know how to address it anymore, but there's nothing I can do about it.I thought that if I could make an array, then the conditions would be a pain in the ass to filter the signal.

The TimeCurrent() function is overloaded. If you read the description of the datetime type, you will see that the first function's first variant will do:

#property strict

/******************************************************************************/
long DiffInSecs(const datetime dt1, const datetime dt2) {
  return dt1 - dt2;
}

/******************************************************************************/
void OnStart() {
  const datetime dt = TimeCurrent();

  Sleep(5555);
  Print("Diff in secs = ", DiffInSecs(TimeCurrent(), dt));
}

It does:

01:10:43 Script 2 EURUSDm,H1: loaded successfully
01:10:43 2 EURUSDm,H1: initialized
01:10:49 2 EURUSDm,H1: Diff in secs = 6
01:10:49 2 EURUSDm,H1: uninit reason 0
01:10:49 Script 2 EURUSDm,H1: removed

We can go to the other side, not to get the difference of moments in time, but to compare these moments (at the same time, we can use a conditional expression again):

#property strict

/******************************************************************************/
void test(const datetime dt) {
  Sleep(2000);
  Print("Момент времени dt ", TimeCurrent() < dt ? "НЕ " : "", "достигнут");
}

/******************************************************************************/
void OnStart() {
  const datetime dt1 = TimeCurrent();
  const datetime dt2 = dt1 + 5;

  test(dt2);
  test(dt2);
  test(dt2);
  test(dt2);
}

Startup gives:

01:30:29 Script 2 EURUSDm,H1: loaded successfully
01:30:29 2 EURUSDm,H1: initialized
01:30:31 2 EURUSDm,H1: Момент времени dt НЕ достигнут
01:30:33 2 EURUSDm,H1: Момент времени dt НЕ достигнут
01:30:35 2 EURUSDm,H1: Момент времени dt достигнут
01:30:38 2 EURUSDm,H1: Момент времени dt достигнут
01:30:38 2 EURUSDm,H1: uninit reason 0
01:30:38 Script 2 EURUSDm,H1: removed

After understanding the essence of the applied ideas, and remembering what the datetime type is, working with moments of time, if the required accuracy does not exceed units of seconds, should not cause difficulties.

 
simpleton:

The TimeCurrent() function is overloaded. If you read the description of what the datetime type is, you will find that the first version of the function is fine:

It does:

We can go in the other direction as well, not to get the time moments difference, but to compare these moments (at the same time, we can use a conditional expression again):

Running gives:

Once you understand the ideas, and remembering the datetime type, working with points in time should be no problem, as long as the required precision does not exceed units of seconds.


To be honest, I haven't figured out how to apply it. There's a millimetre to go, it's a shame to stop when it's almost finished.

Task, don't write price to array if object time(2nd parameter+3600sec>current)||(1st parameter time - 2nd parameter time)<3600sec )

/******************************************************************************/
bool MassTrendNumber(double &array[], const bool buy) { // Поиск значения цены трендовой линии, текущего бара, запись в массив. Два массива: masS и masB
  const string subname = (buy ? "uptrendline" : "downtrendline"); // существует два названия трендовых линий, первое и второе

  if (ArrayResize(array, 0) != 0) {
    return false; // Ошибка, массив не может быть заполнен достоверно
  }

  for (int i = 0, limit = ObjectsTotal(OBJ_TREND); i < limit+2; i++) {
    if (!AddValueIfFound(array, subname + IntegerToString(i))||!FilTrenLin(subname + IntegerToString(i)) {// Условие вставил вот сюда
      return false; // Ошибка, массив, если и заполнен, то недостоверно
    }
  }
 
  return true; // Нет ошибки, массив заполнен достоверно
}
/***************************************************************************/
 bool FilTrenLin(string name) {

 const  datetime    dt = TimeCurrent();
 const  datetime   dt1 = ObjectGet(name,OBJPROP_TIME1);
 const  datetime   dt2 = ObjectGet(name,OBJPROP_TIME2);
  Print("  DiffInSecs(dt,dt2)  ", DiffInSecs(dt,dt2),"  DiffInSecs(dt2,dt1))  ",DiffInSecs(dt2,dt1),"  dt1  ",dt1);
  
     if(DiffInSecs(dt,dt2)<3600||DiffInSecs(dt2,dt1)<3600)// Если время объекта второго параметра + 3600 сек > текущего времени,
 или если разница первого и второго   параметра времени объекта < 3600 сек, то запускаем ошибку, чтоб цена не записалась в массив.
     {   return false;
     }  
   return true;
} 
/******************************************************************************/
long DiffInSecs(const datetime dt1, const datetime dt2) {
  return dt1 - dt2;
}
 

Hello comrades!

MT5 has such wonderful and very useful tools "Pulse Elliott Wave" and "correcting Elliott Wave".

The question is: Can I integrate these tools from MT5 into MT4?

I trade in MT4. It is not very convenient to move to MT5 for analysis.

Or: What are the other ways to solve the issue?

Reason: