How to get the current month?  [SOLVED]

Questions about MultiCharts and user contributed studies.
rkhan
Posts: 65
Joined: 16 Mar 2014
Has thanked: 1 time
Been thanked: 2 times

How to get the current month?  [SOLVED]

Postby rkhan » 16 Mar 2014

//gets current month from todays date
dateToday = Currentdate;
dateInDateTimeFormat = ELDateToDateTime(dateToday);
dateReadable = FormatDate("YYYMMdd", dateInDateTimeFormat);
currentMonth = Month(dateReadable);


The above code returns the following error
Types are not compatible for line 30 which is
dateReadable = FormatDate("YYYMMdd", dateInDateTimeFormat);

Now, all i want is the current month?
is current month jan, or feb, or mar or what?

Thats all i am trying to do here?

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: How to get the current month?

Postby TJ » 16 Mar 2014

//gets current month from todays date
dateToday = Currentdate;
dateInDateTimeFormat = ELDateToDateTime(dateToday);
dateReadable = FormatDate("YYYMMdd", dateInDateTimeFormat);
currentMonth = Month(dateReadable);
The above code returns the following error
Types are not compatible for line 30 which is
DateReadable = FormatDate("YYYMMdd", dateInDateTimeFormat);
Now, all i want is the current month?
is current month jan, or feb, or mar or what?
Thats all i am trying to do here?
What kind of variable is "dateReadable"? string? numeric?

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: How to get the current month?

Postby TJ » 16 Mar 2014

ps. [FAQ] How to Post Codes (that people can read)
viewtopic.php?f=16&t=11713

rkhan
Posts: 65
Joined: 16 Mar 2014
Has thanked: 1 time
Been thanked: 2 times

Re: How to get the current month?

Postby rkhan » 16 Mar 2014

ps. [FAQ] How to Post Codes (that people can read)
viewtopic.php?f=16&t=11713
Dear Sir,

It is NumericSimple, if you are about to suggest i make it a string, how do i do that?

Code: Select all

dateInDateTimeFormat(0),
dateReadable(0),
currentMonth(0);

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: How to get the current month?

Postby TJ » 16 Mar 2014

Dear Sir,
It is NumericSimple, if you are about to suggest i make it a string, how do i do that?

Code: Select all

dateInDateTimeFormat(0),
dateReadable(0),
currentMonth(0);

Code: Select all

var:
dateReadable("");

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: How to get the current month?

Postby TJ » 16 Mar 2014

from the Wiki help file:
FormatDate

Returns a formated string expression corresponding to the date (integer) portion of the specified DateTime value.

rkhan
Posts: 65
Joined: 16 Mar 2014
Has thanked: 1 time
Been thanked: 2 times

Re: How to get the current month?

Postby rkhan » 17 Mar 2014

Dear Sir,

I thankyou for our response, but now the next line is throwing an error
"Incorrect argument type."

So it expect a numeric and returns a numeric
All i want to do is basically get the current month, so i can use it in a switch statement later.
Because depending on the month it is, i have a few different rules.

So this part of the code, all i am trying to achieve is get current month.

dateInDateTimeFormat(0),
dateReadable(""),
currentMonth(0);


array: ranges[](0);
array_setmaxindex(ranges, NoOfDaysForATR);

//gets current month from todays date
dateInDateTimeFormat = ELDateToDateTime(Currentdate);
dateReadable = FormatDate("YYYMMdd", dateInDateTimeFormat);
currentMonth = Month(dateReadable);

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: How to get the current month?

Postby TJ » 17 Mar 2014

Dear Sir,
I thankyou for our response, but now the next line is throwing an error
"Incorrect argument type."
::
rkhan:

I can give you a quick answer, like I did in the previous post. But you should start here:
viewtopic.php?f=16&t=6929

Please get an EasyLanguage ebook and go through it from cover to cover. You have bright ideas; but you need to have a working knowledge of the programming language.

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: How to get the current month?

Postby TJ » 17 Mar 2014

::
Now, all i want is the current month?
is current month jan, or feb, or mar or what?

Thats all i am trying to do here?
How do you want your months?
jan, feb, mar...?
or 1, 2, 3...?

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: How to get the current month?

Postby TJ » 17 Mar 2014

For explanation of EasyLanguage keywords,
look for "PowerLanguage Keyword Reference"
https://www.multicharts.com/trading-sof ... /Main_Page

The keywords you should look up:

MONTH
DATE

rkhan
Posts: 65
Joined: 16 Mar 2014
Has thanked: 1 time
Been thanked: 2 times

Re: How to get the current month?

Postby rkhan » 17 Mar 2014

1,2,3,..

rkhan
Posts: 65
Joined: 16 Mar 2014
Has thanked: 1 time
Been thanked: 2 times

Re: How to get the current month?

Postby rkhan » 18 Mar 2014

Dear Sir,

Yes, if you look at my initial code, that is what i have used
I have used Month

But i cannot get it working

All i want to do is, get a numerical value (1-12) corresponding to the month of the current bar

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: How to get the current month?

Postby TJ » 18 Mar 2014

Dear Sir,
Yes, if you look at my initial code, that is what i have used
I have used Month
But i cannot get it working
All i want to do is, get a numerical value (1-12) corresponding to the month of the current bar
Have you followed my instruction in post #10?

rkhan
Posts: 65
Joined: 16 Mar 2014
Has thanked: 1 time
Been thanked: 2 times

Re: How to get the current month?

Postby rkhan » 18 Mar 2014

Dear Sir,

I didnt understand it,

Thats what i had at the begining, i used month

but it needs an input.. its needs a date. and thats where i get all consfused
coz i use current date, which i then convert to appropriate format, and basically im still where i started

That initial code is what i still have and isnt working for me

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: How to get the current month?

Postby TJ » 18 Mar 2014

Dear Sir,
I didnt understand it,
Thats what i had at the begining, i used month
but it needs an input.. its needs a date. and thats where i get all consfused
coz i use current date, which i then convert to appropriate format, and basically im still where i started
That initial code is what i still have and isnt working for me
Try

Code: Select all


currentmonth = MONTH( DATE );

rkhan
Posts: 65
Joined: 16 Mar 2014
Has thanked: 1 time
Been thanked: 2 times

Re: How to get the current month?

Postby rkhan » 18 Mar 2014

I was over complicating it.

Thanks Sir.


Return to “MultiCharts”