♥ 0 |
Hello Pete,
I hope all is well. The purpose of this study is to modify the current code below that plots the daily ATR on the 1-minute chart and shows a color based on if the range is tight (yellow), normal (green) or wide (red).
All I would like is instead of the code showing the value and color, please only show the word and color “tight, normal, and wide”
input length2 = 14; def dailyHigh = high(period = “DAY”); plot ATR = Round(MovingAverage(ATRaverageType, TrueRange(dailyHigh, dailyClose, dailyLow), length2)); #if yellow label tight, if red label wide, if green label normal
Marked as spam
|
Private answer
After hashing out the details in the comments section above I have the following. Word of caution to other viewers. This code has a very narrow scope and application. The values are fixed and not able to adapt to a wide range of stock prices. Instead of using fixed values for the ATR ranges most professional traders apply multipliers based on the ATR. With 0.5 x ATR being an average move, 1.0 being a wide move and 1.2 being an extreme move. So what we have to start with is given by the author of the post:
That is the logic used to update the color of the label. The author has requested that this same logic be used to set the text displayed in the label. So we simply replace the colors with text:
The AddLabel() function takes three arguments. First is the true/false condition that determines if the label should be displayed. Second is the text displayed in the label. Third is the color of the label. Details here: http://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Look---Feel/AddLabel.html So we take those two lines of code from above and insert them into positions 3 and 2 respectively.
That's it. Screenshot below shows the results. Notice the fixed values used in this solution are not suitable for AAPL. The daily ATR is currently at 3.26, and is near the bottom of its range over the last three months. For certain, the current ATR value for AAPL is "Very Tight". Yet the label displays "Wide Range". A better solution would account for this through the application of some basic math formulas. Marked as spam
|
Please log in to post questions.
You still have a discrepancy there in your last comment. First you state that if ATR > 0.50 then color RED. Later on you state that RED equals wide range and is greater than 0.75. So which is it? Your specifications and code are all over the board here and I am completely lost.
Also, please make sure you realize the ATR is dependent on the price of the stock being plotted. So these values you are specifying here will not be applicable for a wide variety of stocks. If you want something more realistic, you should be specifying these are percentage values. For example a value of today's ATR being greater than the 14 period ATR times 120. Now THAT is a wide range. These numerical values you have here are meaningless.
In your history on this forum, you seem to have a knack for specifying things that are locked into a very narrow application. This forum reaches a vast audience and the only reason I spend time here is to benefit ALL of that audience. Your participation here is important to this forum. So in the future, please be considerate of the rest of our audience and make sure your specifications can be applied to a wide range of stocks and not just the handful of stocks you are focused on.