Approach to Determine Short-Term Delay Between Two Signals
Unless I misunderstood completely, you are looking for the lag between the two waveforms red and green over smaller windowed intervals of that function as the window is moved over the sequence? In this case it can simply be done with a moving window using the following function in Matlab:

[corr, lag] = xcorr(a,b)


This will return the cross-correlation as corr, and the lag variable is the delay between a and b associated with each cross correlation.

Given you want to do this as a moving window, that can be achieved by setting a window size and index, and then index the window through your data:

Note this may be pseudo code below as I haven't tested the actual code written, but should give you the idea, as shown is a moving window of size K indexing 1 sample at a time, and will compute the relative delay between the waveforms within the window view.

x= green-mean(green);    % remove mean
x=x(:)';                 % ensure row vector
y = red-mean(red);
y=y(:)';
[~,n]=size(x);

for shift = 1:n-K    % ensure x and y same size
 xwin= x(shift:shift+K); % K is the window size
 ywin= y(shift:shift+K);
 [corr,lag]= xcorr(xwin,ywin);
 disp(shift)= lag(corr==max(corr));
end 


If this is on track to what you are looking for, I would also consider normalizing the correlation by the standard deviation of the two waveforms within each window, thus giving you the correlation coefficient. This could allow for the option of optimally weighting the results for estimation of overall delay (or ignoring regions where the match was poor etc).