Questions from Beginners MQL5 MT5 MetaTrader 5 - page 904

 
Could you please tell me what the error could be due to when debugging with real data: "the specified symbol is not selected".
Thank you !
MT5
 
IlyaDemidenko:
Please advise what may be the reason for the debugging error with real data : "specified symbol is not selected".
Thank you !
MT5

Before testing (before running a test from the MetaEditor) go to the MetaEditor settings and look at the "Debug" tab. In this tab you can see the symbol that will be used for testing:

Now open the terminal and check if the selected symbol is in the "Market Watch" window.


 
Vladimir Karputov:

Before testing (before running a test from the MetaEditor) go to the MetaEditor settings and look at the "Debug" tab. In this tab you can see the symbol that will be used for testing:

Now open the terminal and check if the selected symbol is in the "Market Watch" window?

Thank you very much )
Process started ))

 
Hello. The price at 5:30 p.m. last day. How can I find out? That is, the closing price of any bar at 5:30 p.m.
 
bij:
Hello. The price at 17:30 last day. How to know it? That is, the closing price of any bar at 5:30 p.m.

ReadCopyOpen(second form of invocation).

 
Vladimir Karputov:

ReadCopyOpen(second form of invocation).

Thanks, didn't understand how to set the time except time=D'2018.07.26 17:30';

        time=???;      //Как сюда передать 17:30 прошлого дня?
        int barIndex = iBarShift(NULL,PERIOD_M1, time);        // Определение индекса бара, соответствующего времени time
        double openPrice = CopyOpen(NULL, PERIOD_M1, barIndex);// Определение Bid цены открытия бара barIndex
 
bij:

Thank you, I didn't realise how to set the time.

I just made a quick script:

//+------------------------------------------------------------------+
//|                                                  TestOpenDay.mq5 |
//|                        Copyright 2018, MetaQuotes Software Corp. |
//|                             https://mql5.com/ru/users/artmedia70 |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, MetaQuotes Software Corp."
#property link      "https://mql5.com/ru/users/artmedia70"
#property version   "1.00"
#property script_show_inputs
//--- enums
enum ENUM_DAY
  {
   DAY_CURRENT,            // Сегодня
   DAY_YESTERDAY,          // Вчера
   DAY_BEFORE_YESTERDAY    // Позавчера
  };
//--- input parameters
input ENUM_DAY InpDay      =  DAY_YESTERDAY; // День:
input uint     InpHours    =  17;            // Часы
input uint     InpMinutes  =  30;            // Минуты
//--- global variables
datetime day;
int      day_shift;
int      hours;
int      minutes;
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   hours=int(InpHours> 23 ? 23 : InpHours);
   minutes=int(InpMinutes>59 ? 59 : InpMinutes);
   day_shift=(int)InpDay;
   day=iTime(NULL,PERIOD_D1,day_shift);
   Print("Сегодня: ",TimeToString(TimeCurrent(),TIME_DATE),", день: ",InputDayToString(),", дата/время: ",TimeToString(GetTime(day)));
//---
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
datetime GetTime(const datetime time)
  {
   MqlDateTime tm;
   if(!TimeToStruct(time,tm))
      return 0;
   tm.hour=hours;
   tm.min=minutes;   
   return StructToTime(tm);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
string InputDayToString(void)
  {
   return(InpDay==DAY_CURRENT? "Сегодня" : InpDay==DAY_YESTERDAY ? "Вчера" : "Позавчера");
  }
//+------------------------------------------------------------------+

The log will show the selected day, its date and time after launching.

 
Artyom Trishkin:

I've just made a quick script:

The log will show the selected day, its date and time after starting.

Thank you, I want to put a line in the indicator in the history to the price at 17:30, every day. How do I set every day? To not write every date, but only the time 17:30

This is how I put the line on the closing price of the day, every day.

 if(!TrendCreate(0,"close"+time[i],0,iTime(NULL,PERIOD_D1,i+1),iClose(NULL,PERIOD_D1,i+1),iTime(NULL,PERIOD_D1,i),0,clrLime,STYLE_SOLID,2,false,false,false,false,0))
        {
         continue;
        }
 
bij:

Thank you, I want to put a line in the indicator in the history to the price at 17:30, every day. How do I set every day?

This is how I set it to the closing price of the day, every day.

If the past date (year, month, day) is not equal to the current date, and the hour and minute are equal to the set one, then put a line.

Or: If the previous date (year, month, day) is equal to the current date, or the hour and minute are not equal to the set ones, then continue;

In any case, there will be skips - not every bar of the selected timeframe has the set time.

 
Artyom Trishkin:

If past date (year, month, day) is not equal to current date, and hour and minute are equal to specified...

if(iTime(NULL,PERIOD_D1,i+1)!=iTime(NULL,PERIOD_D1,i)&& here how to write? )

Reason: