Hello! Everyone!
2009.01.02 15:15;
2009.01.05 05:30;
2009.01.05 14:41;
2009.01.06 08:01;
2009.01.07 22:48;
2009.01.27 15:00;
2009.01.28 18:18;
2009.01.28 22:45;
2009.02.04 03:52;
2009.02.23 18:15;
2009.02.25 07:00;
2009.02.25 14:30;
2009.02.25 18:13;
As you see,I have saved the time list as .csv,
and I want to draw Vertical Line by the script.
But it doesn't work well,it drown only one line.
I think the reason is the file pointer,although I read the programe many times,
I don't konw the further reason.
I need some help,thanks.
what follows is my script code.
//+------------------------------------------------------------------+
//| draw vertical line.mq4 |
//| Copyright ?2009, MetaQuotes Software Corp. |
//| https://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2009, MetaQuotes Software Corp."
#property link "https://www.metaquotes.net/"
//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
int start()
{
//----
string filename="sl.csv";
string timeoftradestr;
datetime timeoftradedat;
bool endvalue=false;
int strlen=0;
int pos=1;
int origin=0;
string indexbackname="_buy";
string indexname;
int handle=FileOpen(filename,FILE_CSV|FILE_READ,";");
while(handle>0)
{
if(strlen==0)origin=SEEK_SET;
else origin=SEEK_CUR;
FileSeek(handle,strlen,origin);
timeoftradestr=FileReadString(handle);
StringLen(timeoftradestr);
timeoftradedat=StrToTime(timeoftradestr);
indexname=StringConcatenate(pos,indexbackname);
pos++;
ObjectCreate(indexname,OBJ_VLINE,0,timeoftradedat,1);
ObjectSet(indexname,OBJPROP_COLOR,Red);
endvalue=FileIsEnding(handle);
if(endvalue==true)
{
FileClose(handle);
break;
}
}
return(0);
}
Dear hexinchen,
Just remove the line FileSeek(handle,strlen,orignin); then It will work perfect. Have fun!
bro.
Down!
Thank you very much!

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello! Everyone!
2009.01.02 15:15;
2009.01.05 05:30;
2009.01.05 14:41;
2009.01.06 08:01;
2009.01.07 22:48;
2009.01.27 15:00;
2009.01.28 18:18;
2009.01.28 22:45;
2009.02.04 03:52;
2009.02.23 18:15;
2009.02.25 07:00;
2009.02.25 14:30;
2009.02.25 18:13;
As you see,I have saved the time list as .csv,
and I want to draw Vertical Line by the script.
But it doesn't work well,it drown only one line.
I think the reason is the file pointer,although I read the programe many times,
I don't konw the further reason.
I need some help,thanks.
what follows is my script code.
//+------------------------------------------------------------------+
//| draw vertical line.mq4 |
//| Copyright ?2009, MetaQuotes Software Corp. |
//| https://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2009, MetaQuotes Software Corp."
#property link "https://www.metaquotes.net/"
//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
int start()
{
//----
string filename="sl.csv";
string timeoftradestr;
datetime timeoftradedat;
bool endvalue=false;
int strlen=0;
int pos=1;
int origin=0;
string indexbackname="_buy";
string indexname;
int handle=FileOpen(filename,FILE_CSV|FILE_READ,";");
while(handle>0)
{
if(strlen==0)origin=SEEK_SET;
else origin=SEEK_CUR;
FileSeek(handle,strlen,origin);
timeoftradestr=FileReadString(handle);
StringLen(timeoftradestr);
timeoftradedat=StrToTime(timeoftradestr);
indexname=StringConcatenate(pos,indexbackname);
pos++;
ObjectCreate(indexname,OBJ_VLINE,0,timeoftradedat,1);
ObjectSet(indexname,OBJPROP_COLOR,Red);
endvalue=FileIsEnding(handle);
if(endvalue==true)
{
FileClose(handle);
break;
}
}
return(0);
}