High, low and close of RSI value for current candlestick

Esminiguu

New member
Hello,

I want to see the highest, lowest and closed RSI value for each candlestick.

Let's say the RSI close was 49. I would like to know if at any point in the candle it crossed the RSI 50 mark. Is there an easy way to achieve this with thinkscript?

Thank you,
 

Esminiguu

New member
I tried that but I don't think that's what I'm looking for exactly. I still want the previous RSI calculated off the close price but I want the "range" that the RSI was during the aggregation period.
 

Pensar

Active member
VIP
@Esminiguu I'm guessing that you just want the previous high/low RSI values. What do you mean by "range" of the RSI? How and where would you want this information displayed, on the lower RSI indicator as bubbles/labels, on the upper chart as a label? Dont know if I can do it yet, I need more information.
 

Esminiguu

New member
@Pensar For example, I trade with the 5 minute candlesticks. As the 5 minute candlestick is forming the RSI indicator value is fluctuating. At one point it may be 50, at another point it may be 47. I would like to know what the highest and lowest point the RSI value was during the 5 minute candle.
 

mashume

Well-known member
VIP
@Esminiguu I've looked into plotting the highest and lowest values of the RSI() during each pricebar . . . I'm not certain if it can be done. @mashume If you dont mind, could you please look at this? I'd appreciate your thoughts and ideas.
Thanks for the vote of confidence in my coding... Warranted or not, who can say eh?

My first thought is to do something along these lines. Assume that we want the RSI to be based on the CLOSE price, we can create two data series that have the close up to the last bar and then use the high and low of the last candle as the datum for their series, in effect giving us two data series that represent the highest and lowest values of the RSI for the last candle.
The drawback of this is that it won't be available to back test since as soon as there is a close, that will be used instead of the H/L for the bar.

Some code to illustrate:
Code:
def series_h = if isNaN(close) then HIGH else CLOSE;
def series_l = if isNan(close) then LOW  else CLOSE;

plot RSI_H = RSI(price = series_h);
plot RSI_L = RSI(price = series_l);

Now, having coded that up, I wonder if making the RSI_H and RSI_L as def statements and then plotting them separately would preserve the high and low RSI, or just muddle things up a bunch.

Of course, I haven't tested any of this in ThinkOrSwim, it's all been typed straight from brain to UseThinkScript. So it may blow up on you, or empty your accounts if you trade with it, and it probably won't do at all what either you or I think it may.

But it is an idea.

-mashume
 

mashume

Well-known member
VIP
Perhaps this:
Code:
declare lower;

def series_h = if isNaN(close[-1]) then HIGH else CLOSE;
def series_l = if isNan(close[-1]) then LOW  else CLOSE;

def RSI_H = RSI(price = series_h);
def RSI_L = RSI(price = series_l);

plot RSI_U = RSI_H;
plot RSI_D = RSI_L;
plot RSI_O = RSI();

addLabel(yes, concat("High: ", RSI_H), color.dark_green);
addLabel(yes, concat("RSI: ", RSI_o), color.dark_gray);
addLabel(yes, concat("Low: ", RSI_L), color.dark_red);

def RSI_Pct = if RSI_L != RSI_O then ((RSI_O - RSI_L) / (RSI_H - RSI_L)) * 100 else 0;

addLabel(yes, concat(RSI_Pct, " %"), color.Blue);

Shows three distinct values for the current bar, though the labels are the useful part as the differences are small.

-mashume
 
Last edited:

mashume

Well-known member
VIP
@mashume Wow that's amazing. This is exactly what I was looking for. Is it possible to show to previous highs and lows too?
Not likely with this method. To calculate the RSI by the standard, we create the data series so that only the current bar is not close. When we move to the next bar, we WANT the value for the past bars to be close, so that we calculate the RSI by the traditional method. I'm not sure how to preserve the values.

Plotting an RSI built using the series of HIGH or LOW values does NOT match the values of RSI high that this study shows.

Life, and data are transitory -- enjoy them while they're around. :)

-mashume
 

Similar threads

Top