counting seconds inside the bar

Questions about MultiCharts and user contributed studies.
JoulVern
Posts: 13
Joined: 23 Sep 2008

counting seconds inside the bar

Postby JoulVern » 20 Nov 2008

hi
i hope you could help me to find a function that counts the # fo seconds since the bar started
if i use 5 min bars and i want to check a condition that can be met only after 4 min and not before
thanks

User avatar
Januson
Posts: 119
Joined: 18 Apr 2007
Location: Denmark

Postby Januson » 20 Nov 2008

I suggest that you use Time_s[1] that will point to the previous bars end time!

User avatar
TJ
Posts: 7739
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1032 times
Been thanked: 2221 times

Postby TJ » 20 Nov 2008

ComputerDateTime

Returns a double-precision decimal DateTime value indicating the computer's current date and time.

The integer portion of the DateTime value indicates the number of days that have elapsed since January 1st, 1900, and the fractional portion of the DateTime value indicates the fraction of the day that has passed since midnight.

Usage

ComputerDateTime

Example

ComputerDateTime will return a value of 39448.25000000 for 6:00 AM on January 1st, 2008

JoulVern
Posts: 13
Joined: 23 Sep 2008

Postby JoulVern » 20 Nov 2008

TJ: but how would you connect it to the last bar? i need it to check the time before sending an order if it still on 2 sec. before the bar is closed
i am trying (using 2 min bars)
if (time_s + 118) >= time_s[1] then fire

User avatar
TJ
Posts: 7739
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1032 times
Been thanked: 2221 times

Postby TJ » 20 Nov 2008

you need to work on some basics...

may i suggest:

http://www.amazon.com/Ask-Mr-Easylangua ... 337&sr=8-1

JoulVern
Posts: 13
Joined: 23 Sep 2008

Postby JoulVern » 20 Nov 2008

is there any short answer?
how would you do that?

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Postby bowlesj3 » 20 Nov 2008

Here is what you want exactly. the value 10 in the command below is your bar size in terms of seconds. So in my case it is a 10 second bar so I use value value 10. If you want to trigger on the 8th second and 9th second of the bar you set the variable MidBarStall to value 8 for the code below. Works perfectly.

John.

Code: Select all


SecondsInBar = 10;
MidBarStall = 8;
If Mod(SecondsfromDateTime(ComputerDateTime),SecondsInBar) >= MidBarStall then
begin
do whatever you want in here;
end;

User avatar
geizer
Posts: 375
Joined: 16 Jun 2008
Has thanked: 40 times
Been thanked: 38 times

Re: counting seconds inside the bar

Postby geizer » 20 Nov 2008

see response in User "Contributed studies" topic.
http://forum.tssupport.com/viewtopic.php?p=22761#22761
Cheers

JoulVern
Posts: 13
Joined: 23 Sep 2008

Postby JoulVern » 21 Nov 2008

thanks all for your help!


Return to “MultiCharts”