Exploration set to run 1min, but checking the previous candle volume

I use the below method from an indicator and try to explore the symbols which have got the desired volume.
periodicity set to 5min on the preferences and auto scan run for every 1 min.

can someone assist on how to ensure that below function does not check the current 5-minute candle and it has to look for the previous closed recent 5min candle?

function CheckVolume()
{
    lookback = 8;  // Changed from 14 to 8

    Use2Bars = "Yes";
    LowVol = "Yes";
    ClimaxUp = "Yes";  // Blue
    ClimaxDown = "Yes";
    Churn = "Yes";
    ClimaxChurn = "Yes";  // Violet

    LowVolColor = 8;
    ClimaxUpColor = 9;
    ClimaxDownColor = 1;
    ChurnColor = 5;
    ClimaxChurnColor = 0;
    DefaultBarColor = 7;
    AvgColor = 0;

    Range = High - Low;
    Value1 = IIf( Close >= Open, Volume * ( ( Range ) / ( ( 2 + ( Range * Range ) / 10 ) * Range + ( Open - Close ) ) ),
                  Volume * ( ( ( Range + Close - Open ) ) / ( 2 + ( Range * Range ) / 10 ) * Range + ( Close - Open ) ) );
    Value2 = Volume - Value1;

    Value3 = Value1 + Value2;
    Value4 = Value1 * Range;
    Value5 = ( Value1 - Value2 ) * Range;
    Value6 = Value2 * Range;
    Value7 = ( Value2 - Value1 ) * Range;
    Value8 = IIf( Range != 0, Value1 / Range, 1 );
    Value9 = IIf( Range != 0, ( Value1 - Value2 ) / Range, 1 );
    Value10 = IIf( Range != 0, Value2 / Range, 1 );
    Value11 = IIf( Range != 0, ( Value2 - Value1 ) / Range, 1 );
    Value12 = IIf( Range != 0, Value3 / Range, 1 );
    Value13 = IIf( Use2Bars == "Yes", Value3 + Ref( Value3, -1 ), 1 );
    Value14 = IIf( Use2Bars == "Yes", ( Value1 + Ref( Value1, -1 ) ) * ( HHV( High, 2 ) - LLV( Low, 2 ) ), 1 );
    Value15 = IIf( Use2Bars == "Yes", ( Value1 + Ref( Value1, -1 ) - Value2 - Ref( Value2, -1 ) ) * ( HHV( High, 2 ) - LLV( Low, 2 ) ), 1 );
    Value16 = IIf( Use2Bars == "Yes", ( Value2 + Ref( Value2, -1 ) ) * ( HHV( High, 2 ) - LLV( Low, 2 ) ), 1 );
    Value17 = IIf( Use2Bars == "Yes", ( Value2 + Ref( Value2, -1 ) - Value1 - Value1[1] ) * ( HHV( High, 2 ) - LLV( Low, 2 ) ), 1 );
    Value18 = IIf( ( Use2Bars == "Yes" AND( HHV( High, 2 ) != LLV( Low, 2 ) ) ), ( Value1 + Ref( Value1, -1 ) ) / ( HHV( High, 2 ) - LLV( Low, 2 ) ), 1 );
    Value19 = IIf( ( Use2Bars == "Yes" AND( HHV( High, 2 ) != LLV( Low, 2 ) ) ), ( Value1 + Ref( Value1, -1 ) - Value2 - Ref( Value2, -1 ) ) / ( HHV( High, 2 ) - LLV( Low, 2 ) ), 1 );
    Value20 = IIf( ( Use2Bars == "Yes" AND( HHV( High, 2 ) != LLV( Low, 2 ) ) ), ( Value2 + Ref( Value2, -1 ) ) / ( HHV( High, 2 ) - LLV( Low, 2 ) ), 1 );
    Value21 = IIf( ( Use2Bars == "Yes" AND( HHV( High, 2 ) != LLV( Low, 2 ) ) ), ( Value2 + Ref( Value2, -1 ) - Value1 - Ref( Value1, -1 ) ) / ( HHV( High, 2 ) - LLV( Low, 2 ) ), 1 );
    Value22 = IIf( ( Use2Bars == "Yes" AND( HHV( High, 2 ) != LLV( Low, 2 ) ) ), Value13 / ( HHV( High, 2 ) - LLV( Low, 2 ) ), 1 );


    Condition1 = IIf( Value3 == LLV( Value3, Lookback ), 1, 0 );
    Condition2 = IIf( ( Value4 == HHV( Value4, Lookback ) AND Close > Open ), 1, 0 );
    Condition3 = IIf( ( Value5 == HHV( Value5, Lookback ) AND Close > Open ), 1, 0 );
    Condition4 = IIf( ( Value6 == HHV( Value6, Lookback ) AND Close < Open ), 1, 0 );
    Condition5 = IIf( ( Value7 == HHV( Value7, Lookback ) AND Close < Open ), 1, 0 );
    Condition6 = IIf( ( Value8 == LLV( Value8, Lookback ) AND Close < Open ), 1, 0 );
    Condition7 = IIf( ( Value9 == LLV( Value9, Lookback ) AND Close < Open ), 1, 0 );
    Condition8 = IIf( ( Value10 == LLV( Value10, Lookback ) AND Close > Open ), 1, 0 );
    Condition9 = IIf( ( Value11 == LLV( Value11, Lookback ) AND Close > Open ), 1, 0 );
    Condition10 = IIf( Value12 == HHV( Value12, lookback ), 1, 0 );
    Condition11 = IIf( Use2Bars == "Yes" AND( Value13 == LLV( Value13, Lookback ) AND Close > Open AND Ref( Close, -1 ) > Ref( Open, -1 ) ), 1, 0 );
    Condition12 = IIf( Use2Bars == "Yes" AND( Value14 == HHV( Value14, Lookback ) AND Close > Open AND Ref( Close, -1 ) > Ref( Open, -1 ) ), 1, 0 );
    Condition13 = IIf( Use2Bars == "Yes" AND( Value15 == HHV( Value15, Lookback ) AND Close > Open AND Ref( Close, -1 ) < Ref( Open, -1 ) ), 1, 0 );
    Condition14 = IIf( Use2Bars == "Yes" AND( Value16 == LLV( Value16, Lookback ) AND Close < Open AND Ref( Close, -1 ) < Ref( Open, -1 ) ), 1, 0 );
    Condition15 = IIf( Use2Bars == "Yes" AND( Value17 == LLV( Value17, Lookback ) AND Close < Open AND Ref( Close, -1 ) < Ref( Open, -1 ) ), 1, 0 );
    Condition16 = IIf( Use2Bars == "Yes" AND( Value18 == LLV( Value18, Lookback ) AND Close < Open AND Ref( Close, -1 ) < Ref( Open, -1 ) ), 1, 0 );
    Condition17 = IIf( Use2Bars == "Yes" AND( Value19 == LLV( Value19, Lookback ) AND Close > Open AND Ref( Close, -1 ) < Ref( Open, -1 ) ), 1, 0 );
    Condition18 = IIf( Use2Bars == "Yes" AND( Value20 == LLV( Value20, Lookback ) AND Close > Open AND Ref( Close, -1 ) > Ref( Open, -1 ) ), 1, 0 );
    Condition19 = IIf( Use2Bars == "Yes" AND( Value21 == LLV( Value21, Lookback ) AND Close > Open AND Ref( Close, -1 ) > Ref( Open, -1 ) ), 1, 0 );
    Condition20 = IIf( Use2Bars == "Yes" AND( Value22 == LLV( Value22, Lookback ) ), 1, 0 );

    Color =

        IIf( ClimaxChurn == "Yes" AND( Condition10 OR Condition20 ) AND( Condition2 OR Condition3 OR Condition4 OR Condition5 OR Condition6 OR Condition7 OR Condition8 OR Condition9 ), colorViolet,
             IIf( LowVol == "Yes" AND( Condition1 OR Condition11 ) , colorYellow,
                  IIf( ClimaxUp == "Yes" AND( Condition2 OR Condition3 OR Condition8 OR Condition9 OR Condition12 OR Condition13 OR Condition18 OR Condition19 ) , colorLime,
                       IIf( ClimaxDown == "Yes" AND( Condition4 OR condition5 OR Condition6 OR Condition7 OR Condition14 OR Condition15 OR Condition16 OR Condition17 ) , colorRed,
                            IIf( Churn == "Yes" AND Condition10 OR Condition20, colorBrown, colorGrey50 ) ) ) ) );

	  ColorReturn = IIf( Color == colorViolet OR Color == colorLime, 1, Null );
      
    return ColorReturn;

}

Vol = CheckVolume();
VolumeCondition = Vol == 1;
Filter = VolumeCondition;