Help calculating Bar range (Inside bars)
Just for reference :
1.Recognize first InsideBar,get the BarIndex;
2.Call function N=NBreakInside(BarIndex).
int NBreakInside(int MyTF,int MyShift) // surely MyShift>=1
{
double PH=iHigh(NULL,MyTF,MyShift);
double PL=iLow (NULL,MyTF,MyShift);
for(int i=MyShift-1;i>=0;i--)
{
if(iHigh(NULL,MyTF,i)>PH || iLow(NULL,MyTF,i)<PL)
{
return(MyShift-i);
}
}
return(0);
}
With my code below I can identify Bar 6 on the image above. How do I calculate that Bar 5 4 3 2 1 is still inside bar 7 ?