I'm new to quantmod and I would like to know if the indicators that I can add have a lagging as part of their calculation.
For example, will RSI
calculate the RSI based on the last 14 days without the current day or with the current day? If I would like to get the RSI of the last day should I wrap the code with the lag function as my second line of code below?
# The 14-period relative strength index calculated off the open
RSI_14 <- RSI(Op(Data),n=14)
# The 14-period relative strength index calculated off the prior day's open
RSI_14_lastDay <- lag(RSI(Op(Data),n=14),K=1)
I checked it with SMA
and it seems that indicators include current row (last new row) as part of the calculation, so there is a need to add a lag function in order to get the last period value on the current row. Here is an example:
RSI_14_lastDay <- lag(RSI(Op(Data),n=14),K=1)