Chart label showing status of higher time frame RSI


Category:
0
0

Hi,

Can you please create a customizable script that i can add on a chart study if a condition is true from a different time frame.

Lets say,

On a 5min Chart, I want to display a text “10 min” with green background on top left hand side of a 5min chart if RSI increased/ing 1 bar ago from a 10 min time frame and vice versa. Red background if NOT.

Thank you!

 

Marked as spam
Posted by (Questions: 8, Answers: 2)
Asked on May 10, 2020 10:52 am
251 views
0
Private answer

User inputs have been included so that you can add the study multiple times to the same chart with different time frames and label text.

#---------- RSI Inputs
input rsiLength = 14;
input timeFrame = aggregationPeriod.TEN_MIN;
input labelText = "10 Min";
input rsiAverageType = AverageType.WILDERS;
Assert(timeFrame >= GetAggregationPeriod(), "The selected time frame must be greater than or equal to the chart time frame");
#---------- RSI Section
def netChangeAverage = MovingAverage(rsiAverageType, close(period = timeFrame) - close(period = timeFrame)[1], rsiLength);
def totalChangeAverage = MovingAverage(rsiAverageType, AbsValue(close(period = timeFrame) - close(period = timeFrame)[1]), rsiLength);
def changeRatio = if totalChangeAverage != 0 then netChangeAverage / totalChangeAverage else 0;
def rsi = 50 * (changeRatio + 1);
AddLabel(yes, labelText, if rsi > rsi[1] then Color.GREEN else Color.RED);

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on May 10, 2020 11:35 am
0
Thank you Pete.... Note: Typo on line 6. "GetAggregationPeriod()"
( at May 10, 2020 12:13 pm)
0
Thanks. I caught that when I tested it on t chart study but forgot to copy those changes back to the code I posted in the answer. I have updated the code in my answer to correct that.
( at May 10, 2020 1:30 pm)