The code for establishing the bands is below here and I'm using and offset from the band as the crossover location. I'm only showing the code for the lower band here.
Will this work as the band is repainted, but the crossing should work for the current bar an looking back at the previous bar for the comparison.
if (CurrentBar < halfLength + 1) return;
if (State != State.Realtime && !IsFirstTickOfBar) return;
for(int i=halfLength; i>=0; i--)
{
sumC = (halfLength+1) * Close[i];
sumW = (halfLength+1);
int k = halfLength;
for(int j=1; j<=halfLength; j++)
{
if(i+j > CurrentBar) break;
sumC += k * Close[i+j];
sumW += k;
if(j<=i)
{
sumC += k * Close[i-j];
sumW += k;
}
k--;
}
rngV = ATR(atrPeriod)[i] * atrFactor;
MiddlBand[i] = sumC / sumW;
UpperBand[i] = MiddlBand[i] + rngV;
LowerBand[i] = MiddlBand[i] - rngV;
LowerBandOffset[i] = (LowerBand[i] + (5 * TickSize));
UpperBandOffset[i] = (UpperBand[i] - (5 * TickSize));
}
if (CrossBelow(Low, LowerBandOffset[0], 1) && (CrossLower == false))
{
CrossLower = true;
Print(Convert.ToString(Times[0][0].TimeOfDay) + "LOWER BAND START DOWN Close: " + Close[0] + "Low: " + Low[0] + "High: " + High[0] + "LowerBand: " + LowerBand[0] + "UpperBand" + UpperBand[0] + "LowerBandOffset: " + LowerBandOffset[0] + "UpperBandOffset: " + UpperBandOffset[0]);
}
if (CrossAbove(Low, LowerBandOffset[0], 1) && (CrossLower == true))
{
CrossLower = false;
if ((Slope(SMA(20), 3, 0)) < 0)
{
trendBreak[0] = -1;
}
else
{
trendBreak[0] = 1;
}

Comment