♥ 0 |
Hi Pete, I appreciate all the great work you do here. I was wondering if there is a way to reference a previous low’s RSI. For instance within the last 30 bars a lowest low was achieved. I would like to reference the RSI when that low occurred. Please see the pic as reference. I am able to do it with price, I believe, with the following code. Is there a way to reference the RSI for that low? input period = 30; def lo = low; I tried using the following to reference the RSI. The problem, it seems, is that it catches the previous bars RSI if that bars low is lower than the current bar. So I get false signals. def lo = RSI(); def lowrsi = Lowest(lo[1], period); Any help is appreciated. Please let me know if I need to word the question differently to understand what I mean to accomplish.
Marked as spam
|
Private answer
When providing a screenshot with your post it is imperative that you include the entire chart view. We need to be able to see the ticker symbol you have loaded on your chart as well as the time frame selected. Otherwise, how are we supposed to replicate your exact scenario when developing the solution? Despite this, I am able to come up with my own example. The code is two lines. Please examine this code compare it to yours. The code you provided makes use of extra steps which are not required. The only time you want to add extra steps to your code is when you need to make it easier to read. And I can assure you that this does not make it easier to read:
To answer your implied question, placing the '[1]' after the variable name as shown above has the affect of excluding the current bar from the test for Lowest in x bars. In order to quickly acheive your stated goals in the fewest lines we have only to incorporate two functions provided in the Thinkorswim language:
Here is the code, along with a screenshot below to show the result.
This makes for code that is easiest to read. However we could compact this further and do all the work in a single line:
This is nice and tidy, however if you need to debug your code at some point in the future it may be difficult to unravel. Marked as spam
|
Please log in to post questions.