Stuck with a function: Return true if time between 8pm & 1am

Questions about MultiCharts and user contributed studies.
arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

Stuck with a function: Return true if time between 8pm & 1am

Postby arjfca » 18 Jul 2012

Hello

Amateur problem, but don't figure how.

I want a function :Asia , to return true if time of the bar is between 8pm and 1 am the following day ( 5H later).

Code: Select all

// Return true if asia session is on

Asia = False;

If time_S >= 200000 and (time_S <= calctime(time_s, 050000)) then Asia = True;
Any idea how i cant resolve this simple function

Martin

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

Re: Stuck with a function: Return true if time between 8pm &

Postby TJ » 18 Jul 2012

Hello

Amateur problem, but don't figure how.

I want a function :Asia , to return true if time of the bar is between 8pm and 1 am the following day ( 5H later).

Code: Select all

// Return true if asia session is on

Asia = False;

If time_S >= 200000 and (time_S <= calctime(time_s, 050000)) then Asia = True;
Any idea how i cant resolve this simple function

Martin

Code: Select all

// Return true if asia session is on
var:
Asia(False);

If time_S >= 200000 or time_S <= 10000 then
Asia = True
else
Asia = False;

arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

Re: Stuck with a function: Return true if time between 8pm &

Postby arjfca » 18 Jul 2012

So simple.... hehe!

Another sandwich my friend....

Martin :)

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

Re: Stuck with a function: Return true if time between 8pm &

Postby TJ » 18 Jul 2012

So simple.... hehe!

Another sandwich my friend....

Martin :)
this is a common oversight:

Code: Select all

...
else
Asia = False;

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

Re: Stuck with a function: Return true if time between 8pm &

Postby TJ » 18 Jul 2012

So simple.... hehe!

Another sandwich my friend....

Martin :)
There is no magic to it.

What you need is clarity in what you want to achieve.

If you had written your thoughts in plain English (or whatever language you normally use),
line by line,
one thought per line,
one line at a time,
you would have coded the logic with ease.


Return to “MultiCharts”