trade age bar count

Post Reply
Rio

trade age bar count

Post by Rio »

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?
User avatar
milanese
TechAdmin
Posts: 3293
Joined: Wed Jan 09, 2013 9:02 am
Location: btr rdx, r8 +

trade age bar count

Post by milanese »

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
Global Prime is the official SHF broker :yahoo:
Searching for Servers and Workstations with individual configuration?
Just PM
:smile: Click here to go to the BoardKnowledgeBase
NOTE: Cookies and JavaScript are required for the using the board, with full functionality
phil_trade

trade age bar count

Post by phil_trade »

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:
Rio

trade age bar count

Post by Rio »

Wow. Very elegant solution.
Cheers for that!
Post Reply

Return to “Coders Hangout”