Time Counter from Last Trade

Questions about MultiCharts and user contributed studies.
haxen
Posts: 6
Joined: 06 Feb 2010
Has thanked: 2 times
Been thanked: 3 times

Time Counter from Last Trade

Postby haxen » 27 Jun 2011

Guys, I came up with a time counter that measures how much time in minutes has passed since the last trade, so that i can set a desired delay between trades and setups.

Code: Select all

entrydelta=timetominutes(time)-timetominutes(exittime(1))+(date-exitdate(1))*1440;
This calculates the minutes including the change over midnight from previous day and works on a 24 hour basis.

You can then kick off some code based up this entrydelta, for example

Code: Select all

if condition1 and condition2 and entrydelta>30 then ...
Hope it helps, I looked all over for something similar.

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

Re: Time Counter from Last Trade

Postby TJ » 27 Jun 2011

Bear in mind that the keyword "time" refers to the end of bar time, not real time.

haxen
Posts: 6
Joined: 06 Feb 2010
Has thanked: 2 times
Been thanked: 3 times

Re: Time Counter from Last Trade

Postby haxen » 27 Jun 2011

Right, which is exactly when I would want the time to be tested, as the next action would be buy next bar at open.

So if the time test at the end of this bar was satisfied, I can continue with my buy next bar action.


Return to “MultiCharts”