i am working on an indicator that uses dictionaries for each bar of each candle.
i have a piece of code that checks the previous bar's dictionary values, it works properly :
if ( Low[0] < Low[1] )
{
qw = Low[1];
while ( qw >= Low[0] )
{
if ( sa[0].ContainsKey(qw) ) sumsells0+= sa[0][qw];
qw = qw - 0.25;
cnts0 = cnts0 + 1;
}
qw2 = Low[1];
int f = 0;
while ( f <= cnts0 )
{
if ( sa[1].ContainsKey(qw2) ) sumsells1+= sa[1][qw2];
f++;
qw2 = qw2 + 0.25;
}
}
if ( sumsells0 >= sumsells1 * 1.5 && GetCurrentBid(0) > Low[0] && Low[0] < Low[1] )
Draw.Square(this, @"trs"+CurrentBar, false, 0, Low[0] , Brushes.Blue);
else RemoveDrawObject("trs"+CurrentBar);
if ( CurrentBar > 6 )
{
if ( IsFirstTickOfBar && Cr[1] == 1)
{
// BULLISH STACKED IMBALANCE
//Print(rt+ " > "+rt2);
//if ( rt == 0 || rt-rt2 < 1) return;
if ( sa[1].Keys.Min() > 0 && ba[1].Keys.Min() > 0)
{
double rt = ba[1].Keys.Max();
double rt2 = ba[1].Keys.Min();
while ( rt >= (ba[1].Keys.Min())+0.75 )
{
if (
(
ba[1].ContainsKey(rt)
&& (( !sa[1].ContainsKey(rt-0.25)) || (sa[1].ContainsKey(rt-0.25) && ba[1][rt]/sa[1][rt-0.25] >=2.5 ) )
)
&&
(
ba[1].ContainsKey(rt-0.25)
&& (( !sa[1].ContainsKey(rt-0.5)) || (sa[1].ContainsKey(rt-0.5) && ba[1][rt-0.25]/sa[1][rt-0.5] >=2.5 ) )
)
&&
(
ba[1].ContainsKey(rt-0.5)
&& (( !sa[1].ContainsKey(rt-0.75)) || (sa[1].ContainsKey(rt-0.75) && ba[1][rt-0.5]/sa[1][rt-0.75] >=2.5 ) )
)
)
{
Print("imb found on bar" + (CurrentBar-1));
// Draw.Rectangle(this, "BSI"+CurrentBar, false, 1, rt , 0, rt-0.75 , Brushes.Transparent, Brushes.Blue, 10);
break;
}
rt = rt-0.25;
}
}
}
}
if i disable the second sequence, the indicator works properly.
Am i missing something?
Thanks for your hlp

Comment