Finding baseline (reference) of nosiy data and lag/lead between 2 signals
You can try the function 'ccf' in R.
The way I would setup your data is:
df=
time | red | black | red diff | black diff |

** make sure your time interval's are constant. i.e every 5 seconds/10 seconds etc

red diff and black diff being the difference between the adjacent values in the red and black data columns, respectively. 
i.e. diff(df$red) = red diff

Then do a ccf on the 2 difference columns and adjust 'lag.max' as necessary to view the plot that is generated. There should be a peak in the graph which is the lag (that occurs the most) between red and black.