Hi there!
I have "starred myself blind" on this Loop to Array conversion problem, so I need your help to get a working Array solution:
An Inside Bar is defined as follows: InsideBar = High <= Ref( High, -1 ) AND Low >= Ref( Low, - 1 );
Let's expand that and say that every bar which has a high and a low within the initiating bar's High and Low (that gave us the first Inside Bar) is defined as an Inside Bar Cluster.
To make it clear what I mean, this picture explains it better:
An Inside Bar Cluster can be from 1 bar to many, many bars! As soon as a candle's high Or low crosses the Initiating bar's High Or Low, that's the end of the Inside Bar Cluster.
This is a fully working loop and I want to convert this loop to an Array solution instead:
PrcH = High;
PrcL = Low;
HighPoint = PrcH;
LowPoint = PrcL;
// locate the inside bar "clusters"
// the inside bar can be a sequence or cluster of bars
barpriorto_insidebarcluster = 0;
insidebarcluster = 0;
insidebarclusterH = 0;
insidebarclusterL = 0;
cntarray = 0;
newH = HighPoint;
newL = LowPoint;
idx = 0;
idxH = HighPoint[0];
idxL = LowPoint[0];
Hloop = 0;
Lloop = 1e12;
for( i = 0; i < BarCount; i++ )
{
if( PrcH[i] <= idxH AND PrcL[i] >= idxL )
{
insidebarcluster[i] = 1;
barpriorto_insidebarcluster[idx] = 1;
cntarray[idx] = cntarray[idx] + 1;
newH[i] = idxH;
newL[i] = idxL;
Hloop = Max( Hloop, PrcH[i] );
Lloop = Min( Lloop, PrcL[i] );
insidebarclusterH[idx] = Hloop;
insidebarclusterL[idx] = Lloop;
}
else
{
idx = i;
idxH = PrcH[i];
idxL = PrcL[i];
Hloop = 0;
Lloop = 1e12;
}
}
BarColor = IIf( InsideBarCluster, colorWhite, colorBlack );
Plot( Close, "Close", BarColor, styleCandle, Null, Null, Null, 1, 1 );
I hope that it is clear what I am trying to achieve and if not please let me know.
Thanks and Regards,
Jorgen