The built in RSI study provided by Thinkorswim is our starting point. I have modified the code to reference the daily time frame. Screenshot attached. You see the Daily on the left and the Hourly on the right. The cross-hairs on the charts point to the same day. You can see the value on the RSI Daily is a nearly exact match for the RSI plotted on the Hourly chart.
Be sure to up-vote this answer if it correctly answered your question! Thanks.
Here is the code:
#
# TD Ameritrade IP Company, Inc. (c) 2007-2016
#
declare lower;
input length = 14;
input over_Bought = 70;
input over_Sold = 30;
input averageType = AverageType.WILDERS;
def NetChgAvg = MovingAverage(averageType, close(period = AggregationPeriod.DAY) - close(period = AggregationPeriod.DAY)[1], length);
def TotChgAvg = MovingAverage(averageType, AbsValue(close(period = AggregationPeriod.DAY) - close(period = AggregationPeriod.DAY)[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
plot RSI = 50 * (ChgRatio + 1);
plot OverSold = over_Sold;
plot OverBought = over_Bought;
RSI.DefineColor("OverBought", GetColor(5));
RSI.DefineColor("Normal", GetColor(7));
RSI.DefineColor("OverSold", GetColor(1));
RSI.AssignValueColor(if RSI > over_Bought then RSI.color("OverBought") else if RSI < over_Sold then RSI.color("OverSold") else RSI.color("Normal"));
OverSold.SetDefaultColor(GetColor(8));
OverBought.SetDefaultColor(GetColor(8));
Kevin,
I am pretty new to tos, which code did you apply and where did you apply it to (I see the declare lower from pete and your declare upper, kind of confused on where to apply this to)? I know how to add studies, however when i do add pete’s code from above I am not seeing the RSI value shown circled red in that screenshot from above. My apologies in advance if these are dumb questions, just trying to learn and make my money back from my early mistakes in trading.
TIA
Alex
I’ll let Kevin respond regarding his own code. But I understand your confusion and wanted to let you know that the code I provided is a completely different study than the code that Kevin plotted. In regards to your question about the screenshots I provided. The RSI value circled in red. That screenshot shows the RSI value on the hourly chart to the right matches the RSI value on the daily chart to the left. Those values are circled to ensure the matching values are clearly seen. Simply put, the code I published plots the daily value of the RSI on a intraday timeframe chart.
Hi try this study in TOS but I am getting error in these line. please fix it and post it again. Thanks
# Define a variable for RTH Alert Active
def periodStart = if secondsTillTime(periodStartEST) 0 then 1 else 0;
def periodEnd = if secondsTillTime(periodEndEST) 0 then 1 else 0;