Multiple Time Frame RSI

Skippidooo

New member
Could someone please add necessary code to make this script multiple time frame?
Thank You In Advance.








declare lower;

input length = 14;
input price = close;
input averageType = AverageType.WILDERS;

def NetChgAvg = MovingAverage(averageType, price - price[1], length);
def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;

plot RSI = 50 * (ChgRatio + 1);



input average1Type = AverageType.SIMPLE;
input average1Length = 9;
input average2Type = AverageType.WILDERS;
input average2Length = 45;

plot avg1 = MovingAverage(average1Type, RSI, average1Length);
avg1.setDefaultColor(Color.GREEN);
plot avg2 = MovingAverage(average2Type, RSI, average2Length);
avg2.setDefaultColor(Color.RED);

avg1.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
avg1.SetLineWeight(2);

avg1.DefineColor("Up", Color.GREEN);
avg1.DefineColor("Down", Color.RED);
avg1.DefineColor("Flat", Color.GRAY);

avg1.AssignValueColor(if avg1[0] > avg1[1] then avg1.Color("Up") else if avg1[0] <
avg1[1] then avg1.Color("Down") else avg1.Color("Flat"));
def cond1 = if rsi > avg1
then Double.POSITIVE_INFINITY
else Double.NEGATIVE_INFINITY;
def cond2 = if rsi < avg1
then Double.POSITIVE_INFINITY
else Double.NEGATIVE_INFINITY;

input showclouds = yes;
AddCloud(if showclouds
then cond1
else Double.NaN,
cond2,
Color.dark_GREEN, Color.Dark_RED);
 
Solution
Could someone please add necessary code to make this script multiple time frame?
Thank You In Advance.








declare lower;

input length = 14;
input price = close;
input averageType = AverageType.WILDERS;

def NetChgAvg = MovingAverage(averageType, price - price[1], length);
def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;

plot RSI = 50 * (ChgRatio + 1);



input average1Type = AverageType.SIMPLE;
input average1Length = 9;
input average2Type = AverageType.WILDERS;
input average2Length = 45;

plot avg1 = MovingAverage(average1Type, RSI, average1Length);
avg1.setDefaultColor(Color.GREEN);
plot avg2 = MovingAverage(average2Type, RSI...
Could someone please add necessary code to make this script multiple time frame?
Thank You In Advance.








declare lower;

input length = 14;
input price = close;
input averageType = AverageType.WILDERS;

def NetChgAvg = MovingAverage(averageType, price - price[1], length);
def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;

plot RSI = 50 * (ChgRatio + 1);



input average1Type = AverageType.SIMPLE;
input average1Length = 9;
input average2Type = AverageType.WILDERS;
input average2Length = 45;

plot avg1 = MovingAverage(average1Type, RSI, average1Length);
avg1.setDefaultColor(Color.GREEN);
plot avg2 = MovingAverage(average2Type, RSI, average2Length);
avg2.setDefaultColor(Color.RED);

avg1.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
avg1.SetLineWeight(2);

avg1.DefineColor("Up", Color.GREEN);
avg1.DefineColor("Down", Color.RED);
avg1.DefineColor("Flat", Color.GRAY);

avg1.AssignValueColor(if avg1[0] > avg1[1] then avg1.Color("Up") else if avg1[0] <
avg1[1] then avg1.Color("Down") else avg1.Color("Flat"));
def cond1 = if rsi > avg1
then Double.POSITIVE_INFINITY
else Double.NEGATIVE_INFINITY;
def cond2 = if rsi < avg1
then Double.POSITIVE_INFINITY
else Double.NEGATIVE_INFINITY;

input showclouds = yes;
AddCloud(if showclouds
then cond1
else Double.NaN,
cond2,
Color.dark_GREEN, Color.Dark_RED);

Choose the mode, either current or agg
Choose the agg to whatever aggregation period desired

The image shows a 1m chart with mode = agg and agg = aggregationperiod.five_min in the upper chart and below a 5min chart with mode = current. The RSI in both are the same.

Screenshot 2024-10-29 141841.jpg
Code:
declare lower;

input mode = {default current, agg};
input agg = AggregationPeriod.FIVE_MIN;
input length = 14;
input price = FundamentalType.CLOSE;
input averageType = AverageType.WILDERS;


def modeperiod = if mode == mode.agg then agg else GetAggregationPeriod();
def NetChgAvg = MovingAverage(averageType, Fundamental(price, period = modeperiod) - Fundamental(price, period = modeperiod)[1], length);
def TotChgAvg = MovingAverage(averageType, AbsValue(Fundamental(price, period = modeperiod) - Fundamental(price, period = modeperiod)[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;

plot RSI = 50 * (ChgRatio + 1);

input average1Type = AverageType.SIMPLE;
input average1Length = 9;
input average2Type = AverageType.WILDERS;
input average2Length = 45;

plot avg1 = MovingAverage(average1Type, RSI, average1Length);
avg1.SetDefaultColor(Color.GREEN);
plot avg2 = MovingAverage(average2Type, RSI, average2Length);
avg2.SetDefaultColor(Color.RED);

avg1.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
avg1.SetLineWeight(2);

avg1.DefineColor("Up", Color.GREEN);
avg1.DefineColor("Down", Color.RED);
avg1.DefineColor("Flat", Color.GRAY);

avg1.AssignValueColor(if avg1[0] > avg1[1] then avg1.Color("Up") else if avg1[0] <
avg1[1] then avg1.Color("Down") else avg1.Color("Flat"));
def cond1 = if RSI > avg1
then Double.POSITIVE_INFINITY
else Double.NEGATIVE_INFINITY;
def cond2 = if RSI < avg1
then Double.POSITIVE_INFINITY
else Double.NEGATIVE_INFINITY;

input showclouds = yes;
AddCloud(if showclouds
then cond1
else Double.NaN,
cond2,
Color.DARK_GREEN, Color.DARK_RED);

#
 
Solution

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
341 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top