DateTime for current bar?

Questions about MultiCharts and user contributed studies.
jek
Posts: 166
Joined: 24 Dec 2006
Has thanked: 1 time
Been thanked: 2 times

DateTime for current bar?

Postby jek » 14 Jan 2008

I know this sounds basic, but it isn't obvious how to get a "DateTime" from the current bar.

What is the best way to get the "date and time" for the current bar and make a string out of it? (presumably using DateTimeToString())

User avatar
Marina Pashkova
Posts: 2758
Joined: 27 Jul 2007

Postby Marina Pashkova » 15 Jan 2008

Hi jek,

Try the following:

var: datetime(0);

datetime = el_datetodatetime(date) + el_timetodatetime(time);
Print(DateTimeToString(datetime));

Should work.

Regards.

jek
Posts: 166
Joined: 24 Dec 2006
Has thanked: 1 time
Been thanked: 2 times

Postby jek » 15 Jan 2008

Thanks, Marina.

I wonder why EL doesn't have a reserved word for "DateTime". Oh well.

jek
Posts: 166
Joined: 24 Dec 2006
Has thanked: 1 time
Been thanked: 2 times

Access to number of decimal places in a price?

Postby jek » 15 Jan 2008

The following code seems to produce an approximation to a text-formatted bar and works on TS and MC:

Code: Select all

priceBarString = ElDateToString(Date) +
"," + NumToStr(Time, 0 ) +
"," + NumToStr(Open, NumDecimals) +
"," + NumToStr(High, NumDecimals) +
"," + NumToStr(Low, NumDecimals) +
"," + NumToStr(Close, NumDecimals) +
"," + NumToStr(Volume, 0)
;

Now it begs the question, is there any way to find out programmatically how many decimal places a given symbol uses for the price? e.g. YM uses 0 and ES uses 2.

User avatar
Marina Pashkova
Posts: 2758
Joined: 27 Jul 2007

Postby Marina Pashkova » 17 Jan 2008

Hi jek,

If I understand your question correctly, the following should work:

Apply a Custom Line 1 indicator to the chart, and in the input type in the following:

Log(PriceScale)/Log(10)

Regards.


Return to “MultiCharts”