I already have v-lines on the chart since I knew the shift , in the topic in the link they drew the v-lines using the shift
In my earlier posts I mentioned that I lose the v-lines I created when the VPS restart or during weekends or sometimes when rebooting MT4 , so I save the dates of the v-lines in attempt to re-create them later if they were lost.
It seems that MT4 does not have the ability to create v-lines from text dates or no one has figured how its done yet
In my earlier posts I mentioned that I lose the v-lines I created when the VPS restart or during weekends or sometimes when rebooting MT4 , so I save the dates of the v-lines in attempt to re-create them later if they were lost.
Here to recreate v-lines you don't need to split seconds digits from TimeExit_SymSymbol ..the job is done by ObjectCreate() itself ,because it doesnt take seconds in account.
Well i quickly tried a script and that certainly draws the line into the future.
//+------------------------------------------------------------------+//| Vline.mq4 |//| Copyright 2019, MarcovdHeijden, MetaQuotes Software Corp. |//| https://www.mql5.com/en/users/thecreator1/news |//+------------------------------------------------------------------+#property copyright"Copyright 2019, MarcovdHeijden, MetaQuotes Software Corp."#property link"https://www.mql5.com/en/users/thecreator1/news"#property version"1.00"#property strict//+------------------------------------------------------------------+//| Script program start function |//+------------------------------------------------------------------+voidOnStart()
{
//--- assemble time parameterdatetime time=Time[0]+50*PeriodSeconds();
//--- create v line
VLineCreate(0,"V-Line-"+TimeToString(time,TIME_DATE),0,time);
//---
}
//+------------------------------------------------------------------+ //| Create the vertical line | //+------------------------------------------------------------------+ bool VLineCreate(constlong chart_ID=0,// chart's ID conststring name="VLine", // line name constint sub_window=0, // subwindow index datetime _time=0,// line time constcolor clr=clrRed, // line color constENUM_LINE_STYLE style=STYLE_SOLID, // line style constint width=1, // line width constbool back=false, // in the background constbool selection=false,// highlight to move constbool ray=true, // line's continuation down constbool hidden=true, // hidden in the object list constlong z_order=0) // priority for mouse click
{
//--- if the line time is not set, draw it via the last bar if(!_time)
_time=TimeCurrent();
//--- reset the error value ResetLastError();
//--- create a vertical line if(!ObjectCreate(chart_ID,name,OBJ_VLINE,sub_window,_time,0))
{
Print(__FUNCTION__,
": failed to create a vertical line! Error code = ",GetLastError());
return(false);
}
//--- set line color ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);
//--- set line display style ObjectSetInteger(chart_ID,name,OBJPROP_STYLE,style);
//--- set line width ObjectSetInteger(chart_ID,name,OBJPROP_WIDTH,width);
//--- display in the foreground (false) or background (true) ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);
//--- enable (true) or disable (false) the mode of moving the line by mouse //--- when creating a graphical object using ObjectCreate function, the object cannot be //--- highlighted and moved by default. Inside this method, selection parameter //--- is true by default making it possible to highlight and move the object ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection);
ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);
//--- enable (true) or disable (false) the mode of displaying the line in the chart subwindows ObjectSetInteger(chart_ID,name,OBJPROP_RAY,ray);
//--- hide (true) or display (false) graphical object name in the object list ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden);
//--- set the priority for receiving the event of a mouse click in the chart ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);
//--- successful execution return(true);
}
//+------------------------------------------------------------------+ //| Move the vertical line | //+------------------------------------------------------------------+ bool VLineMove(constlong chart_ID=0,// chart's ID conststring name="VLine",// line name datetime _time=0) // line time
{
//--- if line time is not set, move the line to the last bar if(!_time)
_time=TimeCurrent();
//--- reset the error value ResetLastError();
//--- move the vertical line if(!ObjectMove(chart_ID,name,0,_time,0))
{
Print(__FUNCTION__,
": failed to move the vertical line! Error code = ",GetLastError());
return(false);
}
//--- successful execution return(true);
}
//+------------------------------------------------------------------+ //| Delete the vertical line | //+------------------------------------------------------------------+ bool VLineDelete(constlong chart_ID=0,// chart's ID conststring name="VLine") // line name
{
//--- reset the error value ResetLastError();
//--- delete the vertical line if(!ObjectDelete(chart_ID,name))
{
Print(__FUNCTION__,
": failed to delete the vertical line! Error code = ",GetLastError());
return(false);
}
//--- successful execution return(true);
}
//+------------------------------------------------------------------+
Well i quickly tried a script and that certainly draws the line into the future.
Dear Marco,
You are using the shift relevant to the current bar, which is the same method I used to create the V-Lines for my charts , however the problem is to create the V-Line without knowing the shift and without referencing the current time/bar, the problem is to create the V-Lines knowing the time/date ONLY
Since i lose the v-lines sometimes when the VPS restarts and other times over the weekend, that is why the only option I found is to save the time/date of the lines on the chart then try to re-create them again, saving the shift wont help much as the bars progress and also there is the weekend bars .
according the MT4 ( https://www.mql5.com/en/docs/objects/objectcreate) the V-Line can be created using the time/date only .. I would like to see how its done since I have not seen it anywhere and I tired without any luck
The function creates an object with the specified name, type, and the initial coordinates in the specified chart subwindow. During creation up to 30 coordinates can be specified. The function returns true if the command has been successfully added to the queue of the specified chart, or false otherwise. If an object has already been created, an...
here is the code if someone ever wanted to draw V-Line using the time/date only
// InputDateTime= is the time you want to use to draw the VLine
datetime TimeVLineFile = (datetime) ObjectGetInteger(0, InputDateTime, OBJPROP_TIME1);
MqlDateTime str1;
TimeToStruct(TimeVLineFile ,str1);
int Year = str1.year;
int Month = str1.mon;
int Day = str1.day;
int Hour = str1.hour;
int Minutes = str1.min;
int Seconds = str1.sec;
string VLineDateFormat= str1.year+"."+str1.mon+"."+str1.day+" "+ str1.hour+":" + str1.min;
ObjectCreate(0, "L3", OBJ_VLINE, 0, StringToTime(VLineDateFormat), High[0]);
Take the struct and convert it so a string (without the seconds.)
Take the string and convert it back to the original datetime (without the seconds.)
If all you wanted was to remove the seconds, This is how that's done:
If you looked at my previous posts you will see that I tired removing the seconds, but it didn't work, however after the conversion the code worked not sure what was wrong,
I like your version of the code its simple, elegant and it works well, thanks
This is my first time utilizing graphical articles in a pointer. I would need to draw a vertical line ordinarily in the meantime "22:00", might you be able to please direct me to an answer?
Thanks a lot Marco for the help , for some reason its working
I configured the time in the D' format , then displayed that information as an alert , which you can see matches the arrow times however
the V-Line is still created on the current candle .. see screen shot
This is the code I used
Here is a related topic: https://www.mql5.com/en/forum/233876
I already have v-lines on the chart since I knew the shift , in the topic in the link they drew the v-lines using the shift
In my earlier posts I mentioned that I lose the v-lines I created when the VPS restart or during weekends or sometimes when rebooting MT4 , so I save the dates of the v-lines in attempt to re-create them later if they were lost.
It seems that MT4 does not have the ability to create v-lines from text dates or no one has figured how its done yet
In my earlier posts I mentioned that I lose the v-lines I created when the VPS restart or during weekends or sometimes when rebooting MT4 , so I save the dates of the v-lines in attempt to re-create them later if they were lost.
If you have saved the dates as :
Here to recreate v-lines you don't need to split seconds digits from TimeExit_SymSymbol ..the job is done by ObjectCreate() itself ,because it doesnt take seconds in account.
You may simplify your codes by:
Well i quickly tried a script and that certainly draws the line into the future.
Well i quickly tried a script and that certainly draws the line into the future.
Dear Marco,
You are using the shift relevant to the current bar, which is the same method I used to create the V-Lines for my charts , however the problem is to create the V-Line without knowing the shift and without referencing the current time/bar, the problem is to create the V-Lines knowing the time/date ONLY
Since i lose the v-lines sometimes when the VPS restarts and other times over the weekend, that is why the only option I found is to save the time/date of the lines on the chart then try to re-create them again, saving the shift wont help much as the bars progress and also there is the weekend bars .
according the MT4 ( https://www.mql5.com/en/docs/objects/objectcreate) the V-Line can be created using the time/date only .. I would like to see how its done since I have not seen it anywhere and I tired without any luck
Finally I figured how its done
here is the code if someone ever wanted to draw V-Line using the time/date only
Finally I figured how its done
here is the code if someone ever wanted to draw V-Line using the time/date only
If you looked at my previous posts you will see that I tired removing the seconds, but it didn't work, however after the conversion the code worked not sure what was wrong,
I like your version of the code its simple, elegant and it works well, thanks