
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Also you do not have to recreate the object on every tick this will flood the error log with a 4200 Object already exists, so in stead create the object in the on init function once and then you can move it to the desired date later on.
to avoid that issue :
Or additionally you can check up front to see if the object already exists by:
ObjectFind(...
Marco, Paul
Thanks a lot for the reply and the help
However , the issue I am facing right now is to convert the information (date) I retrieve from the file and use it to draw the lines
In the code the file is saved as # Lines in the MT4 files section and the date saved is for example 2019.05.18 05:30:00 , first step I remove the
last 3 digits from the date and convert it to 2019.05.18 05:30 .. now the next step is what I am failing to achieve to make the time in the D' format
I tried this following
but that did not work , so I convert the string to time
In both cases the line is created at 1970.01.01 00:00 so the issue is to convert the date from the file into something meaningful MT4 can use to create the v-line
I am attaching the code , maybe you can spot my mistake .. in the code I created two lines but none of the lines are created on the date i retrieve from the file
you are doing that wrong by writing the date between quotes
as it is :
D'2019.05.18 05:30'
Both are datetimes. Just as
are both doubles.you are doing that wrong by writing the date between quotes
as it is :
D'2019.05.18 05:30'
I am doing so because I am converting the text into a datetime format as William Roeder illustrated above .. I am not sure where is my mistake since i save the date correctly and convert it to D' format but still unable to create the line , though if I copied the date from the file and manually created a line it goes into the correct date
I think you will have more luck saving and reading time as long integer values like seconds since epoch in stead of these string to datetime conversions.
The date is saved including seconds, for example this is the time pulled from the file 2019.05.19 15:00:00
However during my tests , I found out that if I used the date with seconds it will create the line in 1970.01.01 ,thats the reason why I remove the seconds , but still unable to create the file on the correct location of the date
In that case i think you can also look at the time structure:
You can use
TimeToStruct()
Function as follows:
Then you can extract all desired values from this.
These are integer values so no strings to mess with.