Trying to perform Walk Forward with same day IS and OOS periods

I am trying to do a walk forward test Using same day In Sample and Out os Sample Data.

For example , I would like the in sample period to be from midnight to 6:00 AM and the out of sample to be 06:30 to 9:00 AM. The code below is my best effort so far to do this, but it doesn't work. It seems that the backtester uses IS data for both IS and OOS periods. Any help would be appreciated.

Plot(C,"",colorred,styleCandle);

beginIS= ParamTime("BeginIS" , "00:00");//Beginning of In Sample
endIS= ParamTime("EndIS","06:00"); // End of In Sample
beginOOS=ParamTime("BeginOOS" , "06:30");//Begin Out of Sample
endOOS=ParamTime("EndOOS" , "09:00");//end of out of sample
IS=  TimeNum() >= beginIS && TimeNum() <= endIS;
OOS=TimeNum() >= beginOOS && TimeNum() <= endOOS;


period = Optimize("Period",6,3,20,1);; // number of averaging periods 
m = EMA( Close, period ); // exponential moving average
Buy = IS && Cross( Close, m ); // buy when close crosses ABOVE moving average
Sell = Cross( m, Close ); // sell when closes crosses BELOW moving average
PlotShapes(shapeUpArrow * Buy,colorLime,L);




SetCustomBacktestProc( "" );
//StaticVarSet( Name() + "ADX", ADX( 15 ) );
if ( Status( "action" ) == actionPortfolio )
{
    bo = GetBacktesterObject();
    
			bo.PreProcess();
			for( bar = 0; bar < BarCount; bar++ )
			{
				if(OOS[bar]==1)bo.ProcessTradeSignals( bar );
			}
			bo.PostProcess();
    
    bo.ListTrades( );
	
}


Title="IS  " + NumToStr(IS,1.2) + "   OOS  " + numtostr(oos,1.2);

This is my latest attempt...Obviouly there are things I don't understand about CBT
`
``
beginIS= ParamTime("BeginIS" , "00:00");//Beginning of In Sample
endIS= ParamTime("EndIS","06:00"); // End of In Sample
beginOOS=ParamTime("BeginOOS" , "06:30");//Begin Out of Sample
endOOS=ParamTime("EndOOS" , "09:00");//end of out of sample
IS= TimeNum() >= beginIS && TimeNum() <= endIS;
OOS=TimeNum() >= beginOOS && TimeNum() <= endOOS;
Plot(C,"",colorred,styleCandle);
StaticVarSet("OOS",OOS);

period = Optimize("Period",6,3,20,1);; // number of averaging periods
m = EMA( Close, period ); // exponential moving average
Buy = IS && Cross( Close, m ); // buy when close crosses ABOVE moving average
Sell = Cross( m, Close ); // sell when closes crosses BELOW moving average
PlotShapes(shapeUpArrow * Buy,colorLime,L);
StaticVarSet("Buy",Buy);

SetCustomBacktestProc("");
if (Status("action") == actionPortfolio) {
bo = GetBacktesterObject();
// Get backtester object
bo.PreProcess(); // Do pre-processing (always required)
for (i = 0; i < BarCount; i++) // Loop through all bars
{
for (sig = bo.GetFirstSignal(i); sig; sig = bo.GetNextSignal(i))
{ // Loop through all signals at this bar
if( OOS[i]==0 && Buy[i]==1) Buy[i]=False;

    }    //  End of for loop over signals at this bar
    bo.ProcessTradeSignals(i);    //  Process trades at bar (always required)
}    //  End of for loop over bars
		bo.PostProcess();
// iterate through closed trades

// generate trade list
bo.ListTrades( );

}

Sorry about the messed up format of the last post.

This is the latest attempt to solve my problem.

beginIS= ParamTime("BeginIS" , "00:00");//Beginning of In Sample
endIS= ParamTime("EndIS","06:00"); // End of In Sample
beginOOS=ParamTime("BeginOOS" , "06:30");//Begin Out of Sample
endOOS=ParamTime("EndOOS" , "09:00");//end of out of sample
IS=  TimeNum() >= beginIS && TimeNum() <= endIS;
OOS=TimeNum() >= beginOOS && TimeNum() <= endOOS;
Plot(C,"",colorred,styleCandle);
StaticVarSet("OOS",OOS);



period = Optimize("Period",6,3,20,1);; // number of averaging periods 
m = EMA( Close, period ); // exponential moving average
Buy = IS && Cross( Close, m ); // buy when close crosses ABOVE moving average
Sell = Cross( m, Close ); // sell when closes crosses BELOW moving average
PlotShapes(shapeUpArrow * Buy,colorLime,L);
StaticVarSet("Buy",Buy);

SetCustomBacktestProc("");
if (Status("action") == actionPortfolio) {
     bo = GetBacktesterObject();
       //  Get backtester object
    bo.PreProcess();    //  Do pre-processing (always required)
    for (i = 0; i < BarCount; i++)    //  Loop through all bars
    {
        for (sig = bo.GetFirstSignal(i); sig; sig = bo.GetNextSignal(i))
        {    //  Loop through all signals at this bar 
               if( OOS[i]==0 && Buy[i]==1) Buy[i]=False;
               
               
        }    //  End of for loop over signals at this bar
        bo.ProcessTradeSignals(i);    //  Process trades at bar (always required)
    }    //  End of for loop over bars
			bo.PostProcess();
    // iterate through closed trades

    // generate trade list
    bo.ListTrades( );
}