I'm looking to get the duration (in seconds) between the bar with the lowest low within a predefined range of bars and the current bar.
In order to achieve this, I'm using the MIN command and a boolean called "Duration".
The lowest low (of the last 5 bars) is defined by the following snippet:
double lowestlow = MIN(Low, 5)[0];
So far so good.
The duration between two bars is defined by the following snippet:
TimeSpan time1 = Time[0] - new DateTime(1970,1,1,0,0,0);
TimeSpan time2 = Time[1] - new DateTime(1970,1,1,0,0,0);
int diff=(int)time1.TotalSeconds-(int)time2.TotalSeconds;
if(diff > 60)
{
Duration = true;
}
else
{
Duration = false;
}
This works as well, but the issue I'm encountering here is that I obviously don't know in advance WHICH of the last 5 bars has produced the lowest low, so I cannot call the bar in the "TimeSpan time2" command, not knowing whether it is Time[1], Time[2], Time[3], Time[4], or Time[5]
(Time[0] is always the current bar so this part of the equation obviously works.)
Thanks for helping me out here.

Comment