stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

trade age bar count
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=3617
Page 1 of 1
Author:  Rio [ Tue May 13, 2014 3:15 am ]
Post subject:  trade age bar count

Maybe somebody has already done this, but I'm trying to determine how many bars have passed since a trade has been opened. I'm trying to think about ways of counting the bars that have passed (let's say on the M15) as opposed to finding out how many seconds old it is.

I know one way of doing it would be to get the time of the open trade from selecting it, and subtracting it from the current time. Maybe dividing the result by the time period?
Author:  milanese [ Tue May 13, 2014 8:19 am ]
Post subject:  trade age bar count

Rio » Tue May 13, 2014 3:15 am wrote:Maybe somebody has already done this, but I'm trying to determine how many bars have passed since a trade has been opened. I'm trying to think about ways of counting the bars that have passed (let's say on the M15) as opposed to finding out how many seconds old it is.

I know one way of doing it would be to get the time of the open trade from selecting it, and subtracting it from the current time. Maybe dividing the result by the time period?
this will give you the result:

Code: Select all

double BarsAfterOpen=iBarShift(NULL,Period(),OrderOpenTime(),false);
Cheers :)

Tommaso
Author:  phil_trade [ Tue May 13, 2014 8:28 am ]
Post subject:  trade age bar count

milanese » 7 minutes ago wrote:
Rio » Tue May 13, 2014 3:15 am wrote:Maybe somebody has already done this, but I'm trying to determine how many bars have passed since a trade has been opened. I'm trying to think about ways of counting the bars that have passed (let's say on the M15) as opposed to finding out how many seconds old it is.

I know one way of doing it would be to get the time of the open trade from selecting it, and subtracting it from the current time. Maybe dividing the result by the time period?
this will give you the result:

Code: Select all

double BarsAfterOpen=iBarShift(NULL,Period(),OrderOpenTime(),false);
Cheers :)

Tommaso
What is great with Tomamaso, is you don't have even think about your question...he already have the answer :good:
Author:  Rio [ Wed May 14, 2014 1:45 am ]
Post subject:  trade age bar count

Wow. Very elegant solution.
Cheers for that!
All times are UTC Page 1 of 1