Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 769

 
Please help, you need to add the time of the advisor. who can help, write in the personal. as a sign of gratitude, I will share my idea
 
Sergei Boriskov:
Help please, we need to add time to the Expert Advisor. who can help, please contact me in person. as a thank you, i will share my idea
This forum is for open discussion.
 
Please help me, I need to add a time to the advisor.
Files:
qwer.mq4  14 kb
 
Sergei Boriskov:
Please help me, I need to add the running time to my EA.

Try this script to pull out some useful features for your EA.

//+----------------------------------------------------------------------------+
//|                                                test_isTradeTimeString.mq4  |
//|                                                                            |
//|                                                    Ким Игорь В. aka KimIV  |
//|                                                       http://www.kimiv.ru  |
//|                                                                            |
//|  29.04.2009  Скрипт для тестирования функции isTradeTimeString().          |
//+----------------------------------------------------------------------------+
#property copyright "Ким Игорь В. aka KimIV"
#property link  "http://www.kimiv.ru"


void OnStart() {
//1. Временной отрезок внутри суток.
//Текущее время торгового сервера внутри отрезка и пусть оно равно "07:50".
//  if (isTradeTimeString("06:00", "09:30")) Message("Торгуем...");
//  else Message("Отдыхаем...");

//2. Временной отрезок внутри суток.
//Текущее время торгового сервера вне отрезка и пусть оно равно "07:50".
  if (isTradeTimeString("12:00", "16:30")) Message("Торгуем...");
  else Message("Отдыхаем...");

//3. Временной отрезок включает границу суток.
//Текущее время торгового сервера внутри отрезка и пусть оно равно "07:50".
  //if (isTradeTimeString("20:15", "09:30")) Message("Торгуем...");
  //else Message("Отдыхаем...");

//4. Временной отрезок включает границу суток.
//Текущее время торгового сервера вне отрезка и пусть оно равно "07:50".
//  if (isTradeTimeString("8:00", "18:30")) Message("Торгуем...");
 // else Message("Отдыхаем...");
}

//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 29.04.2009                                                     |
//|  Описание : Возвращает флаг разрешения торговли по времени.                |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    TimeBegin - время начала торговли         (ЧЧ:ММ)                       |
//|    TimeEnd   - время окончания торговли      (ЧЧ:ММ)                       |
//+----------------------------------------------------------------------------+
bool isTradeTimeString(string TimeBegin="00:00", string TimeEnd="00:00") {
  datetime dtBegin, dtEnd;        // Время начала и окончания работы
  int      hc, he;                // Часы текущего времени и окончания работы

  dtBegin=StringToTime( TimeToString(TimeCurrent(), TIME_DATE)+" "+TimeBegin);
  dtEnd  =StringToTime( TimeToString(TimeCurrent(), TIME_DATE)+" "+TimeEnd);
  hc     =TimeHour(TimeCurrent());
  he     =TimeHour(dtEnd);
  if (dtBegin>=dtEnd) {
    if (hc>=he) dtEnd+=24*60*60; else dtBegin-=24*60*60;
  }

  if (TimeCurrent()>=dtBegin && TimeCurrent()<=dtEnd) return(true);
  else return(false);
}

//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 01.09.2005                                                     |
//|  Описание : Вывод сообщения в коммент и в журнал                           |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    m - текст сообщения                                                     |
//+----------------------------------------------------------------------------+
void Message(string m) {
  Alert(m);
  if (StringLen(m)>0) Alert(m);
}
//+----------------------------------------------------------------------------+

 
Sergei Boriskov:
Please help me, I need to add time to the Expert Advisor.
Have you tried to do something yourself? Or do you want us to do it for you?
This is a training thread. If you can't - we'll help, we'll teach, but we'll do everything for you...
 
Alekseu Fedotov:

Try this script to pull out some useful features for your EA.

Thank you

 
Vitaly Muzichenko:

Well, you can get something useful and sometimes even extraordinary out of every code.

Codebase is designed for this very purpose, not for what two people do with it.

P.S. I got a good idea, I will need to rewrite the array of structures, somehow it did not even think about it before.

https://www.mql5.com/ru/code/24787

The codebase was created for this very purpose and is designed to do the things two people do with it.

ArrayZigZag
ArrayZigZag
  • www.mql5.com
При создании объекта в его конструктор необходимо передать в качестве параметров: 3. Использовать экземпляр объекта  ZigZag как обычный массив структур. Доступны для чтения следующие поля: Свойство Тип Описание 4. Публичным доступны два метода:  ZigZag.Update(void) - обновление значений индикатора ZigZag , можно использовать как на каждом...
 
Igor Makanu:

https://www.mql5.com/ru/code/24787

Study it, or edit the class that holds the data to suit your needs , in my case it is CZigZagPeak , dynamic lists are cool!

Thanks, I'll have a look in the evening!

 

Good afternoon.

Help with the code, please, as I'm not a programmer myself :(

I need a part of code to calculate the distance between orders.

The essence of the block:

Runs once a week on Monday at the beginning of trading session opening.

Historical data for the previous month are loaded. (D1) (How to determine the last month or just calculate 30 days)

All candle sizes are recorded taking into account shadows of each candle on D1 and average size of a candle for the month is calculated.

Also we calculate the average value of the candlestick size for the last week.

Then the average value between the month and the week is calculated and divided by N parts. This will be the distance between the orders.

 
Alexander Layzerevich:

Good afternoon.

Help with the code, please, as I'm not a programmer myself :(

I need a part of code to calculate the distance between orders.

The essence of the block:

Runs once a week on Monday at the beginning of trading session opening.

Historical data for the previous month are loaded. (D1)

All sizes are recorded taking into account shadows of each candle on D1 and the average value of candle size for the month is calculated.

The average value of the candlestick size for the last week is also calculated.

Then the average value between the month and the week is calculated and divided by N parts. This will be the distance between the orders.

Use the ATR indicator