Date and time of a bar to a string: How to?

Questions about MultiCharts and user contributed studies.
arjfca
Posts: 1273
Joined: 23 Nov 2010
Has thanked: 721 times
Been thanked: 222 times

Date and time of a bar to a string: How to?

Postby arjfca » 31 Mar 2011

Hello

I want to create an indicator that will save information string in a file the value of a bar
Main information that i want to kept is the tick volume for a given bar for further analysis

Format of the information will be
Instrument name, Date Time:,Volume, Open, High,Low,Close

I'm trying to assign the date and time of a bar to a string. How can i do that? Actual result
give me 4939-12-24 00:00:00 for the date and time

4939-12-24 00:00:00:,440,1.41940,1.42050,1.41930,1.42010

Also Is it possible to put in a variable the name of the instrument under tested.

Instrument_ = { Name of the instrument)

Martin

User avatar
TJ
Posts: 6583
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 970 times
Been thanked: 1907 times

Re: Date and time of a bar to a string: How to?

Postby TJ » 31 Mar 2011

arjfca wrote:Hello

I want to create an indicator that will save information string in a file the value of a bar
Main information that i want to kept is the tick volume for a given bar for further analysis

Format of the information will be
Instrument name, Date Time:,Volume, Open, High,Low,Close

I'm trying to assign the date and time of a bar to a string. How can i do that? Actual result
give me 4939-12-24 00:00:00 for the date and time

4939-12-24 00:00:00:,440,1.41940,1.42050,1.41930,1.42010

Also Is it possible to put in a variable the name of the instrument under tested.

Instrument_ = { Name of the instrument)

Martin


you should post your snippet.

arjfca
Posts: 1273
Joined: 23 Nov 2010
Has thanked: 721 times
Been thanked: 222 times

Re: Date and time of a bar to a string: How to? Resolve

Postby arjfca » 31 Mar 2011

Your ,

How could I expect a responce if I don't describe my actual work.....:)

Actually, I did resolve the problem. Here is my code

Code: Select all

{The function will save the information of each bar in new files for each week
Saved information will have

Market,Date time, volume, Open, High,Low, Close
}

Variables:

FileName (Text),
DataString (Text),
SP      (Text),
coma      (Text);

SP= " ";
Coma = ",";
//Create  a file name
If dayofweek(0) = 0 then begin
   Filename =datetostring(date);
end;

// For each bar, create a new Data String
If Barstatus = 2 then begin      // Work done on the end of a bar
   Datastring =symbolname data1 + coma + DateToString(eldatetodatetime(date)) + sp + TimeToString(eltimetodatetime(time))+":" +  NumToStr(volume,0) + coma + NumToStr(Open,5) + coma + NumToStr(High,5)+ coma + NumToStr(Low,5) + coma + NumToStr(close,5);

    FileAppend("c:\data\mydata.txt", datastring);


For each complete bar, the function will save the name of the instrument, date time:, Volume, Open, High, Low, Close.


Other question wiill be post about file modification

Martin


Return to “MultiCharts”