Hey Beppe,

I'm trying to use your template to bring up only the indicators that are valid on any given day. My code isn't bringing up any results. I do get an error on line 72: Info 1001. The function LastValue() used here may be looking into the future. However, I'm getting this error with the code you put above, and your code yields results on the same symbols I'm running my code against. I messed something up, and it's probably minor. Do you see anything?

```
// Define Individual Indicators
// ATR calculations
atr1 = ATR(1);
atr5 = ATR(5);
atr25 = ATR(25);
// SMA calculations
sma200 = MA(Close, 200);
sma50 = MA(Close, 50);
IsSMA50AboveSMA200 = IIf(sma50 > sma200, 1, 0);
IsSMA50BelowSMA200 = IIf(sma50 < sma200, 1, 0);
// Access ATR using daily timeframe
ATRValue = ATR(10); // 10-day Average True Range
// Previous day values
prevClose = Ref(Close, -1);
prevHigh = Ref(High, -1);
prevLow = Ref(Low, -1);
// Conditions
closeAbovePrevHigh = Close > prevHigh;
closeBelowPrevLow = Close < prevLow;
// Calculate the previous day's range and adjustments for open positions
PrevRange = PrevHigh - PrevLow;
PrevRangeAdjusted = IIf(PrevRange == 0, 1, PrevRange); // Adjust for zero range to avoid division by zero
OpenPositionPercentage = ((Open - PrevLow) / PrevRangeAdjusted) * 100;
// Define opening position classifications within the range
WithinRange = Open >= PrevLow AND Open <= PrevHigh;
Top10 = WithinRange AND OpenPositionPercentage >= 90;
Top25 = WithinRange AND OpenPositionPercentage >= 75 AND OpenPositionPercentage < 90;
TopHalf = WithinRange AND OpenPositionPercentage >= 50 AND OpenPositionPercentage < 75;
BottomHalf = WithinRange AND OpenPositionPercentage < 50 AND OpenPositionPercentage >= 25;
BottomQuarter = WithinRange AND OpenPositionPercentage < 25 AND OpenPositionPercentage >= 10;
Bottom10 = WithinRange AND OpenPositionPercentage < 10;
// Define classifications for opening above previous day's range
AboveRange = Open > PrevHigh;
ATRAboveRange = (Open - PrevHigh) / ATRValue;
OpenATR0to25 = AboveRange AND ATRAboveRange <= 0.25;
OpenATR25to50 = AboveRange AND ATRAboveRange > 0.25 AND ATRAboveRange <= 0.5;
OpenATR50to75 = AboveRange AND ATRAboveRange > 0.5 AND ATRAboveRange <= 0.75;
OpenATR75to1 = AboveRange AND ATRAboveRange > 0.75 AND ATRAboveRange <= 1;
OpenATRGreater1 = AboveRange AND ATRAboveRange > 1;
// Define classifications for opening below previous day's range
BelowRange = Open < PrevLow;
ATRBelowRange = (PrevLow - Open) / ATRValue;
OpenBelowATR0to25 = BelowRange AND ATRBelowRange <= 0.25;
OpenBelowATR25to50 = BelowRange AND ATRBelowRange > 0.25 AND ATRBelowRange <= 0.5;
OpenBelowATR50to75 = BelowRange AND ATRBelowRange > 0.5 AND ATRBelowRange <= 0.75;
OpenBelowATR75to1 = BelowRange AND ATRBelowRange > 0.75 AND ATRBelowRange <= 1;
OpenBelowATRGreater1 = BelowRange AND ATRBelowRange > 1;
// Conditions
condition1 = Is1ATRLessThan5ATR = IIf(atr1 < atr5, 1, 0) AND WithinRange = Open >= PrevLow AND Open <= PrevHigh AND IsSMA50BelowSMA200 = IIf(sma50 < sma200, 1, 0);
condition2 = Is1ATRLessThan5ATR = IIf(atr1 < atr5, 1, 0) AND Top10 = WithinRange AND OpenPositionPercentage >= 90 AND IsSMA50BelowSMA200 = IIf(sma50 < sma200, 1, 0);
condition3 = Is1ATRLessThan5ATR = IIf(atr1 < atr5, 1, 0) AND Top25 = WithinRange AND OpenPositionPercentage >= 75 AND OpenPositionPercentage < 90 AND IsSMA50BelowSMA200 = IIf(sma50 < sma200, 1, 0);
condition4 = Is1ATRLessThan5ATR = IIf(atr1 < atr5, 1, 0) AND TopHalf = WithinRange AND OpenPositionPercentage >= 50 AND OpenPositionPercentage < 75 AND IsSMA50BelowSMA200 = IIf(sma50 < sma200, 1, 0);
condition5 = Is1ATRLessThan5ATR = IIf(atr1 < atr5, 1, 0) AND BottomHalf = WithinRange AND OpenPositionPercentage < 50 AND OpenPositionPercentage >= 25 AND IsSMA50BelowSMA200 = IIf(sma50 < sma200, 1, 0);
condition6 = Is1ATRLessThan5ATR = IIf(atr1 < atr5, 1, 0) AND BottomQuarter = WithinRange AND OpenPositionPercentage < 25 AND OpenPositionPercentage >= 10 AND IsSMA50BelowSMA200 = IIf(sma50 < sma200, 1, 0);
condition7 = Is1ATRLessThan5ATR = IIf(atr1 < atr5, 1, 0) AND Bottom10 = WithinRange AND OpenPositionPercentage < 10 AND IsSMA50BelowSMA200 = IIf(sma50 < sma200, 1, 0);
condition8 = Is1ATRLessThan5ATR = IIf(atr1 < atr5, 1, 0) AND OpenATR0to25 = AboveRange AND ATRAboveRange <= 0.25 AND IsSMA50BelowSMA200 = IIf(sma50 < sma200, 1, 0);
condition9 = Is1ATRLessThan5ATR = IIf(atr1 < atr5, 1, 0) AND OpenATR25to50 = AboveRange AND ATRAboveRange > 0.25 AND ATRAboveRange <= 0.5 AND IsSMA50BelowSMA200 = IIf(sma50 < sma200, 1, 0);
bir = Status("barinrange");
c1cum = lastValue(cum(IIf( bir, condition1, 0)));
c2cum = lastValue(cum(IIf( bir, condition2, 0)));
c3cum = lastValue(cum(IIf( bir, condition3, 0)));
c4cum = lastValue(cum(IIf( bir, condition4, 0)));
c5cum = lastValue(cum(IIf( bir, condition5, 0)));
c6cum = lastValue(cum(IIf( bir, condition6, 0)));
c7cum = lastValue(cum(IIf( bir, condition7, 0)));
c8cum = lastValue(cum(IIf( bir, condition8, 0)));
c9cum = lastValue(cum(IIf( bir, condition9, 0)));
Filter = 1;
if (c1cum) AddColumn(condition1, "Is1ATRLessThan5ATR = IIf(atr1 < atr5, 1, 0) AND WithinRange = Open >= PrevLow AND Open <= PrevHigh AND IsSMA50BelowSMA200 = IIf(sma50 < sma200, 1, 0)", 1);
if (c2cum) AddColumn(condition2, "Is1ATRLessThan5ATR = IIf(atr1 < atr5, 1, 0) AND Top10 = WithinRange AND OpenPositionPercentage >= 90 AND IsSMA50BelowSMA200 = IIf(sma50 < sma200, 1, 0);", 1);
if (c3cum) AddColumn(condition3, "Is1ATRLessThan5ATR = IIf(atr1 < atr5, 1, 0) AND Top25 = WithinRange AND OpenPositionPercentage >= 75 AND OpenPositionPercentage < 90 AND IsSMA50BelowSMA200 = IIf(sma50 < sma200, 1, 0);", 1);
if (c4cum) AddColumn(condition4, "Is1ATRLessThan5ATR = IIf(atr1 < atr5, 1, 0) AND TopHalf = WithinRange AND OpenPositionPercentage >= 50 AND OpenPositionPercentage < 75 AND IsSMA50BelowSMA200 = IIf(sma50 < sma200, 1, 0);", 1);
if (c5cum) AddColumn(condition5, "Is1ATRLessThan5ATR = IIf(atr1 < atr5, 1, 0) AND BottomHalf = WithinRange AND OpenPositionPercentage < 50 AND OpenPositionPercentage >= 25 AND IsSMA50BelowSMA200 = IIf(sma50 < sma200, 1, 0);", 1);
if (c6cum) AddColumn(condition6, "Is1ATRLessThan5ATR = IIf(atr1 < atr5, 1, 0) AND BottomQuarter = WithinRange AND OpenPositionPercentage < 25 AND OpenPositionPercentage >= 10 AND IsSMA50BelowSMA200 = IIf(sma50 < sma200, 1, 0);", 1);
if (c7cum) AddColumn(condition7, "Is1ATRLessThan5ATR = IIf(atr1 < atr5, 1, 0) AND Bottom10 = WithinRange AND OpenPositionPercentage < 10 AND IsSMA50BelowSMA200 = IIf(sma50 < sma200, 1, 0);", 1);
if (c8cum) AddColumn(condition8, "Is1ATRLessThan5ATR = IIf(atr1 < atr5, 1, 0) AND OpenATR0to25 = AboveRange AND ATRAboveRange <= 0.25 AND IsSMA50BelowSMA200 = IIf(sma50 < sma200, 1, 0);", 1);
if (c9cum) AddColumn(condition9, "Is1ATRLessThan5ATR = IIf(atr1 < atr5, 1, 0) AND OpenATR25to50 = AboveRange AND ATRAboveRange > 0.25 AND ATRAboveRange <= 0.5 AND IsSMA50BelowSMA200 = IIf(sma50 < sma200, 1, 0);", 1);
```

bir = Status("barinrange");

c1cum = lastValue(cum(iif( bir, condition1, 0)));

c2cum = lastValue(cum(iif( bir, condition2, 0)));

c3cum = lastValue(cum(iif( bir, condition3, 0)));

c4cum = lastValue(cum(iif( bir, condition4, 0)));

c5cum = lastValue(cum(iif( bir, condition5, 0)));

c6cum = lastValue(cum(iif( bir, condition6, 0)));

c7cum = lastValue(cum(iif( bir, condition7, 0)));

c8cum = lastValue(cum(iif( bir, condition8, 0)));

c9cum = lastValue(cum(iif( bir, condition9, 0)));

Filter = 1;

if (c1cum) AddColumn(condition1, "Is1ATRLessThan5ATR = IIf(atr1 < atr5, 1, 0) AND WithinRange = Open >= PrevLow AND Open <= PrevHigh AND IsSMA50BelowSMA200 = IIf(sma50 < sma200, 1, 0)", 1);

if (c2cum) AddColumn(condition2, "Is1ATRLessThan5ATR = IIf(atr1 < atr5, 1, 0) AND Top10 = WithinRange AND OpenPositionPercentage >= 90 AND IsSMA50BelowSMA200 = IIf(sma50 < sma200, 1, 0);", 1);

if (c3cum) AddColumn(condition3, "Is1ATRLessThan5ATR = IIf(atr1 < atr5, 1, 0) AND Top25 = WithinRange AND OpenPositionPercentage >= 75 AND OpenPositionPercentage < 90 AND IsSMA50BelowSMA200 = IIf(sma50 < sma200, 1, 0);", 1);

if (c4cum) AddColumn(condition4, "Is1ATRLessThan5ATR = IIf(atr1 < atr5, 1, 0) AND TopHalf = WithinRange AND OpenPositionPercentage >= 50 AND OpenPositionPercentage < 75 AND IsSMA50BelowSMA200 = IIf(sma50 < sma200, 1, 0);", 1);

if (c5cum) AddColumn(condition5, "Is1ATRLessThan5ATR = IIf(atr1 < atr5, 1, 0) AND BottomHalf = WithinRange AND OpenPositionPercentage < 50 AND OpenPositionPercentage >= 25 AND IsSMA50BelowSMA200 = IIf(sma50 < sma200, 1, 0);", 1);

if (c6cum) AddColumn(condition6, "Is1ATRLessThan5ATR = IIf(atr1 < atr5, 1, 0) AND BottomQuarter = WithinRange AND OpenPositionPercentage < 25 AND OpenPositionPercentage >= 10 AND IsSMA50BelowSMA200 = IIf(sma50 < sma200, 1, 0);", 1);

if (c7cum) AddColumn(condition7, "Is1ATRLessThan5ATR = IIf(atr1 < atr5, 1, 0) AND Bottom10 = WithinRange AND OpenPositionPercentage < 10 AND IsSMA50BelowSMA200 = IIf(sma50 < sma200, 1, 0);", 1);

if (c8cum) AddColumn(condition8, "Is1ATRLessThan5ATR = IIf(atr1 < atr5, 1, 0) AND OpenATR0to25 = AboveRange AND ATRAboveRange <= 0.25 AND IsSMA50BelowSMA200 = IIf(sma50 < sma200, 1, 0);", 1);

if (c9cum) AddColumn(condition9, "Is1ATRLessThan5ATR = IIf(atr1 < atr5, 1, 0) AND OpenATR25to50 = AboveRange AND ATRAboveRange > 0.25 AND ATRAboveRange <= 0.5 AND IsSMA50BelowSMA200 = IIf(sma50 < sma200, 1, 0);", 1);

SetSortColumns(-2);