I am trying to write some code for NT8 so that at the close of each bar, the code looks back over the previous 12 bars, and there may be anything from 0 to 2 signs on each bar. If the number of signs counted are > 10, then a diamond is drawn to the chart. The problem is that I am getting too many diamonds because the count does not appear to be resetting to 0 on the first loop after the close of a bar. The code is also written so that there should not be more than one bar without a sign on it, and no 2 consecutive bars must be without a sign. Can anyone help to identify where I have gone wrong, in particular in resetting the count.
Thank you.
int barsToCheck = Math.Min(CurrentBar, 12); //CurrentBar is 0, so it will look back to 11 to make 12.
countSigns = 0;
for (int i = 0; i < barsToCheck; i++)
{
if(variousSigns[0]==false && variousSigns [1]==false) //2 bars with no sign, reset count to 0.
{countSigns =0;}
if(sign1[0]==true)
{countSigns ++;}
if(sign2[0]==true)
{countSigns ++;}
if(sign3[0]==true)
{countSigns ++;}
}
if(countSigns > 10)
{
Diamond myDiamond = Draw.Diamond(this, "MyDiamond" + CurrentBar, false, 0, high0 + 6*TickSize, Brushes.DarkOrange);
myDiamond.OutlineBrush = Brushes.Black;
}

Comment