1. Try in MetaEditor: File --> Open shared data folder. You will see the path to the folder. This issue has been discussed many times, here is a link for example
2. Try it without include at first. When you will debug it, you will start to include it.
3. Insert your sources here either by using SRC button above, or by using Attach file button below.
Please advise how to draw a horizontal line at the opening price of the bar at 07:00.
I have written this code, but the line is not drawn for some reason. Where is the error?
externstring StartTime = "07:00"; //Начальное время для анализа, 00:00 ESTexternstring AlTime = "18:55"; //Время для трейдингаexternstring EndTime = "20:00"; //Время экспирации//+------------------------------------------------------------------+//| |//+------------------------------------------------------------------+intOnInit()
{
ObjectCreate(ChartID(),"CORDON",OBJ_HLINE,0,0,Ask); //созд гор линию по цене AskObjectSetInteger(ChartID(),"CORDON",OBJPROP_COLOR,clrDarkBlue); //цвет темно-сиийObjectSetInteger(ChartID(),"CORDON",OBJPROP_WIDTH,1); //толщина линии 1ObjectSetInteger(ChartID(),"CORDON",OBJPROP_STYLE,STYLE_SOLID); //линия сплошint IndexOfBar = iBarShift(ChartID(),PERIOD_H1, StringToTime(StartTime), true); //Считаем индекс бара по заданному времени StartTimedouble StartPrice = Open[IndexOfBar]; //Получаем цену по индексуObjectMove(ChartID(),"CORDON", 0, 0, StartPrice); // меняем распол линии return(0);
}
LRA: If you remove ObjectMove, the line is visible? Try Alert(StartPrice);
If you remove ObjectMove, you cannot see the line, but ifyou write a numeric value instead of "IndexOfBar", for example, "double StartPrice = Open[5];" it draws the line at the opening price of the fifth bar.
Thanks for the idea with Alert - it shows "0" value.
By the way, the line also exists in the list of objects with the value 0.
Please advise how to draw a horizontal line at the opening price of the bar at 07:00.
I have written this code, but the line is not drawn for some reason. Where is the error?
You cannot draw and calculate in the inite, it is a gross error. The inite must finish its work as fast as possible.
The error here isint IndexOfBar = iBarShift(ChartID()_Symbol,PERIOD_H1, StringToTime(StartTime), true); //read the index of the bar by the given time StartTime
The time can be set directly in datetime format, no need to waste machine time on conversion, works like this:
#property strict#property show_inputs
externdatetime StartTime = D'07:00'; //Начальное время для анализа, 00:00 ESTexterndatetime AlTime = D'18:55'; //Время для трейдингаexterndatetime EndTime = D'20:00'; //Время экспирации//+------------------------------------------------------------------+//| |//+------------------------------------------------------------------+voidOnStart()
{
ObjectCreate(0,"CORDON",OBJ_HLINE,0,0,Ask); //созд гор линию по цене AskObjectSetInteger(0,"CORDON",OBJPROP_COLOR,clrDarkBlue); //цвет темно-сиийObjectSetInteger(0,"CORDON",OBJPROP_WIDTH,1); //толщина линии 1ObjectSetInteger(0,"CORDON",OBJPROP_STYLE,STYLE_SOLID); //линия сплошint IndexOfBar = iBarShift(_Symbol,0, StartTime, false); //Считаем индекс бара по заданному времени StartTimedouble StartPrice = Open[IndexOfBar]; //Получаем цену по индексуPrint(IndexOfBar,", ",StartPrice);
ObjectMove(0,"CORDON", 0, 0, StartPrice); // меняем распол линии
}
You can't draw and calculate in the init, it's a gross mistake. The init should complete its work as quickly as possible.
The error here -int IndexOfBar = iBarShift(ChartID()_Symbol,PERIOD_H1, StringToTime(StartTime), true); //read the index of the bar by the specified time StartTime
The time can be set directly in datetime format, no need to waste machine time on conversion, works like this:
Thanks for the valuable tips for me.
And special thanks for raising my morale by finding the error. I'm starting to believe again that I can make friends with MQL4
RichLux: version of the code doesn't work. The line on the graph still doesn't appear...
// Вставил такой код в скрипт - линию рисует синюю на черном графике слабо видно
#property strict // -------- Возможно, Дело в этой строке
externstring StartTime = "07:00"; //Начальное время для анализа, 00:00 ESTexternstring AlTime = "18:55"; //Время для трейдингаexternstring EndTime = "20:00"; //Время экспирацииvoidOnStart()
{
ObjectCreate("CORDON",OBJ_HLINE,0,0,Ask); //созд гор линию по цене Ask --- Для текущего графика ID пропускаемObjectSetInteger(0,"CORDON",OBJPROP_COLOR,DarkBlue); //цвет темно-сиий --- 0 = текущий график DarkBlue - то же самоеObjectSetInteger(0,"CORDON",OBJPROP_WIDTH,1); //толщина линии 1ObjectSetInteger(0,"CORDON",OBJPROP_STYLE,STYLE_SOLID); //линия сплош
// Первый параметр нужен типа string, а функция ChartID возвращает long
int IndexOfBar = iBarShift(NULL,PERIOD_H1, StringToTime(StartTime), true); // --- NULL = текущий график ЗДЕСЬ И БЫЛА ОШИБКА???
double StartPrice = Open[IndexOfBar]; //Получаем цену по индексуObjectMove(ChartID(),"CORDON", 0, 0, StartPrice); // меняем распол линии
}
And if you take the calculations from the inite into a separate function, and then insert this function into the inite, it will not be a gross error?
If the code is executed too long, the inite will terminate forcibly and the code simply will not have time to be executed. The executed code, including calls of secondary functions, must be in the predefined functions of MQL - OnTick() for Expert Advisors, OnStart() for scripts, OnCalculate() for indicators.
The inite must contain the minimum of code, only those things that must be executed once, right before the start of the program. For example, initialization of global variables, arrays, indicator buffers.
Reinstalling the OS. How to restore after OS reinstallation MT4 to the state it was in before reinstallation. Indicators, EAs, scripts; templates, profiles; accounts
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
1. Try in MetaEditor: File --> Open shared data folder. You will see the path to the folder. This issue has been discussed many times, here is a link for example
2. Try it without include at first. When you will debug it, you will start to include it.
3. Insert your sources here either by using SRC button above, or by using Attach file button below.
Please advise how to draw a horizontal line at the opening price of the bar at 07:00.
I have written this code, but the line is not drawn for some reason. Where is the error?
Please advise how to draw a horizontal line at the opening price of the bar at 07:00.
I have written this code, but the line is not drawn for some reason. Where is the error?
If you remove ObjectMove, the line is visible? Try Alert(StartPrice);
If you remove ObjectMove, you cannot see the line, but ifyou write a numeric value instead of "IndexOfBar", for example, "double StartPrice = Open[5];" it draws the line at the opening price of the fifth bar.
Thanks for the idea with Alert - it shows "0" value.
By the way, the line also exists in the list of objects with the value 0.
Please advise how to draw a horizontal line at the opening price of the bar at 07:00.
I have written this code, but the line is not drawn for some reason. Where is the error?
You cannot draw and calculate in the inite, it is a gross error. The inite must finish its work as fast as possible.
The error here isint IndexOfBar = iBarShift(ChartID()_Symbol,PERIOD_H1, StringToTime(StartTime), true); //read the index of the bar by the given time StartTime
The time can be set directly in datetime format, no need to waste machine time on conversion, works like this:
You can't draw and calculate in the init, it's a gross mistake. The init should complete its work as quickly as possible.
The error here -int IndexOfBar = iBarShift(ChartID()_Symbol,PERIOD_H1, StringToTime(StartTime), true); //read the index of the bar by the specified time StartTime
The time can be set directly in datetime format, no need to waste machine time on conversion, works like this:
Thanks for the valuable tips for me.
And special thanks for raising my morale by finding the error. I'm starting to believe again that I can make friends with MQL4
You can't draw and calculate in the init, it's a gross mistake. The init should be completed as quickly as possible.
And if you take the calculations from the inite into a separate function and then insert this function into the inite, it won't be a gross error?
It already works.
And if you take the calculations from the inite into a separate function, and then insert this function into the inite, it will not be a gross error?
If the code is executed too long, the inite will terminate forcibly and the code simply will not have time to be executed. The executed code, including calls of secondary functions, must be in the predefined functions of MQL - OnTick() for Expert Advisors, OnStart() for scripts, OnCalculate() for indicators.
The inite must contain the minimum of code, only those things that must be executed once, right before the start of the program. For example, initialization of global variables, arrays, indicator buffers.
Indicators, EAs, scripts; templates, profiles; accounts