Daily ATR Support/Resistance Lines for ThinkorSwim

T

TraderKevin

New member
Hey all,

Created this simple "indicator" that draws lines at the previous day's close and the daily ATR levels. These often act as support/resistance, as in general the market stays within the ATR. If the price gets above/below these levels then it is unlikely to continue moving very far in that direction unless there is very strong buying/selling pressure.

Code:
input length = 14;
input averageType = AverageType.WILDERS;

def ATR = MovingAverage(averageType, TrueRange(high(period=”DAY”)[1], close(period=”DAY”)[1], low(period=”DAY”)[1]), length);

plot DailyClose = close(period=”DAY”)[1];
plot hatr = dailyclose + ATR;
plot latr = dailyclose - ATR;
 
Last edited by a moderator:
T

TraderKevin

New member
That's all of it... doesn't take much! Is something not working for you?
 
T

TraderKevin

New member
I edited it to add lines for the current day's trading range vs the ATR, which can be indicative that moves won't continue or will reverse soon in the same way. Also added a label to show the % that the day's trading range has fulfilled the average trading range.

Code:
input length = 14;
input averageType = AverageType.WILDERS;
input BasePeriod = AggregationPeriod.DAY;

def ATR = MovingAverage(averageType, TrueRange(high(period=”DAY”)[1], close(period=”DAY”)[1], low(period=”DAY”)[1]), length);
def Today_High = Highest(high(period = baseperiod)[0], 1);
def Today_Low = Lowest(low(period =baseperiod)[0], 1);
def DR = Today_High - Today_Low;

plot DailyClose = close(period=”DAY”)[1];
plot hatr = dailyclose + ATR;
plot latr = dailyclose - ATR;
plot hdtr = Today_Low + ATR;
plot ldtr = Today_High - ATR;

AddLabel(visible = Yes, text = "DTR: " + round(DR/ATR, 2)*100 + "%", color = Color.LIGHT_GRAY);
 
Last edited by a moderator:
A

alvaro

New member
Hi TraderKevin, I´m glad I found this thread. I am looking for something similar, based on my day trading strategy, I found using ATR´s as support and resistance is pretty powerful and simple at the same time, especially if you combine them with meaningful areas of support/resistance and VWAP. Your idea is very similar to mine, this is what I have in mind:
  1. Plot daily ATR from today (period:14), using daily close from today, for tomorrow's price activity
  2. 4 different ATR plots, with length being the variable value differentiating each ATR
  3. Horizontal lines plot on 15 min time frame or less
  4. Any of the 4 ATR's can be turned on / off from the studies menu
  5. Any of the 4 ATR length's can be modified from the studies menu
  6. Include label with S1 and R1 values and with ATR % (useful to determine volatility = (ATR/Close)*100 - in percentage )
Below an example on CWH ATRs lines :





Don´t mind the blue closing price line, I don´t think is very useful. I think fine dotted lines is cleaner. Hopefully you find it interesting and want to write the code. Best of luck!
 
T

TraderKevin

New member
Hi TraderKevin, I´m glad I found this thread. I am looking for something similar, based on my day trading strategy, I found using ATR´s as support and resistance is pretty powerful and simple at the same time, especially if you combine them with meaningful areas of support/resistance and VWAP. Your idea is very similar to mine, this is what I have in mind:
  1. Plot daily ATR from today (period:14), using daily close from today, for tomorrow's price activity
  2. 4 different ATR plots, with length being the variable value differentiating each ATR
  3. Horizontal lines plot on 15 min time frame or less
  4. Any of the 4 ATR's can be turned on / off from the studies menu
  5. Any of the 4 ATR length's can be modified from the studies menu
  6. Include label with S1 and R1 values and with ATR % (useful to determine volatility = (ATR/Close)*100 - in percentage )
Below an example on CWH ATRs lines :





Don´t mind the blue closing price line, I don´t think is very useful. I think fine dotted lines is cleaner. Hopefully you find it interesting and want to write the code. Best of luck!
So, if I understand correctly, you want the following as compared to my original study:
  • Use just the ATR based on previous day's close, leaving out the daily trading range
  • 4 ATR lines that are different based on length? What do you mean by length? The period (ie, one based on 14 period ATR, one on 9, 5, and 20, or something like that?) Or do you mean to introduce a multiplier (ie, 1 x ATR, 1.25 x ATR, 1.5 x ATR, 1.75 x ATR)?
  • include labels for S1 and R1 pivot points, and for ATR/Close * 100 (which will by definition not change much throughout the day, as compared to the formula I used in my original study which shows the percentage of the ATR that has been filled by the current day's trading action). Also, what formula would you like me to use for S1 and R1? There are several slightly different pivot point formulas folks use.

It sounds like this should be pretty easy once I fully understand the above.
 
A

alvaro

New member
Yeah I think is pretty easy one
  • Use just the ATR based on previous day's close, leaving out the daily trading range
  • that is correct
  • 4 ATR lines that are different based on length? What do you mean by length? The period (ie, one based on 14 period ATR, one on 9, 5, and 20, or something like that?) Or do you mean to introduce a multiplier (ie, 1 x ATR, 1.25 x ATR, 1.5 x ATR, 1.75 x ATR)?
  • I mean 4 upper ATRs (ATRX1 ATRX2 ATRX3 ATRX4) And same for lower atrs. The reason is I´ve seen a few cases when a stock is ripping or getting destroyed and runs 3 or even 4 atrs.
  • Include labels for S1 and R1 pivot points, and for ATR/Close * 100 (which will by definition not change much throughout the day, as compared to the formula I used in my original study which shows the percentage of the ATR that has been filled by the current day's trading action). Also, what formula would you like me to use for S1 and R1? There are several slightly different pivot point formulas folks use.
  • In the pics I sent you, S1 = Lower ATR1 as support and R1 = Upper ATR1 as resistance.
  • I find it very useful to determine if a stock has volatility (for next day trading) or not based on it´s ATR%, so based on my experience 5%+ indicates good volatility. That percentage is useful. This is the table I use to plan my trading for the next day: https://prnt.sc/uie7ov
 
T

TraderKevin

New member
Try this out:

Code:
input ATRperiod = 14;
input averageType = AverageType.WILDERS;
input BasePeriod = AggregationPeriod.DAY;
input ATRMultiplier = 1;
input ATRMultiplier2 = 2;
input ATRMultiplier3 = 3;
input ATRMultiplier4 = 4;

def ATR = MovingAverage(averageType, TrueRange(high(period = ”DAY”)[1], close(period = ”DAY”)[1], low(period = ”DAY”)[1]), ATRperiod);


def DailyClose = close(period = ”DAY”)[1];
plot HighATR = DailyClose + ATR;
plot LowATR = DailyClose - ATR;
plot HighATR2 = DailyClose + ATR * ATRMultiplier2;
plot LowATR2 = DailyClose - ATR * ATRMultiplier2;
plot HighATR3 = DailyClose + ATR * ATRMultiplier3;
plot LowATR3 = DailyClose - ATR * ATRMultiplier3;
plot HighATR4 = DailyClose + ATR * ATRMultiplier4;
plot LowATR4 = DailyClose - ATR * ATRMultiplier4;

HighATR.SetDefaultColor(color = Color.RED);
HighATR2.SetDefaultColor(color = Color.RED);
HighATR3.SetDefaultColor(color = Color.RED);
HighATR4.SetDefaultColor(color = Color.RED);
LowATR.SetDefaultColor(color = Color.GREEN);
LowATR2.SetDefaultColor(color = Color.GREEN);
LowATR3.SetDefaultColor(color = Color.GREEN);
LowATR4.SetDefaultColor(color = Color.GREEN);

HighATR.SetPaintingStrategy(PaintingStrategy.DASHES);
HighATR2.SetPaintingStrategy(PaintingStrategy.DASHES);
HighATR3.SetPaintingStrategy(PaintingStrategy.DASHES);
HighATR4.SetPaintingStrategy(PaintingStrategy.DASHES);
LowATR.SetPaintingStrategy(PaintingStrategy.DASHES);
LowATR2.SetPaintingStrategy(PaintingStrategy.DASHES);
LowATR3.SetPaintingStrategy(PaintingStrategy.DASHES);
LowATR4.SetPaintingStrategy(PaintingStrategy.DASHES);


AddLabel(visible = yes, text = "ATR: " + Round(ATR / close * 100, 2)  + "%", color = Color.LIGHT_GRAY);
AddLabel(visible = Yes, text = "S1: " + Round(LowATR, 2), color = Color.Green);
AddLabel(visible = Yes, text = "R1: " + Round(HighATR, 2), color = Color.Red);
 
A

alvaro

New member
That is awesome, Thank you!
One question, for the label, how can I change it so it shows next day´s ATR% and S1 R1?
 
T

TraderKevin

New member
That is awesome, Thank you!
One question, for the label, how can I change it so it shows next day´s ATR% and S1 R1?
Since those are calculated based off the day's closing price, you can't calculate the next day's values until the current day closes. If this is what you are wanting to see, then use the following code for the labels instead, just knowing that the values will be updating throughout the current day but won't be correct until the market closes:

Code:
AddLabel(visible = yes, text = "ATR: " + Round(ATR[-1] / close[-1] * 100, 2)  + "%", color = Color.LIGHT_GRAY);
AddLabel(visible = Yes, text = "S1: " + Round(LowATR[-1], 2), color = Color.Green);
AddLabel(visible = Yes, text = "R1: " + Round(HighATR[-1], 2), color = Color.Red);
Also, just as a note, the more I use both ATR and the Daily trading range compared to ATR (see my updated study above), the more I realize that the daily trading range is the better support/resistance. I'd encourage you to try out this instead. It updates throughout the day as new daily highs/lows are created and seems far better. For example, look at how it did on Monday (September 14th) on the SPY... it acted as strong resistance as the price bounced off it at least 6 times and never broke it.
 
Last edited:
A

alvaro

New member
Sweet, thank you TraderKevin, you´re the man!

That sounds very interesting, I´ll check it out and let you know. I day trade stocks and options, I don´t trade penny stocks, I trade mainly Nasdaq tech stocks and some large and small caps. I also swing trade. I learned from Brian Shanon, SMB Capital and Kunal Desai. How about you?
 
Last edited by a moderator:
S

shisha1999

New member
Is it possible to modify this indicator to display % change instead of ATR? So looking for lines to display % change positive and negative from the previous day close in increments of 0.25% to 2% or 3%
 
T

TraderKevin

New member
Is it possible to modify this indicator to display % change instead of ATR? So looking for lines to display % change positive and negative from the previous day close in increments of 0.25% to 2% or 3%
Sorry, but I'm not sure what you mean. % change of what.. the stock price from the previous day's close? If so, that's the regular % Change feature in thinkorswim (and every other website/platform) is. You just want lines drawn on the chart that show where each 0.25% change is?
 
S

shisha1999

New member
Correct, draw lines at 0.25 % change from yesterday's close. So draw a line at 0.25, 0.50, 0.75, etc from yesterday's closing price. And the same in the negative direction.
 
rad14733

rad14733

Active member
VIP
Correct, draw lines at 0.25 % change from yesterday's close. So draw a line at 0.25, 0.50, 0.75, etc from yesterday's closing price. And the same in the negative direction.
Kinda sorta like a VWAP with Standard Deviations, but based on yesterdays close... Hmmm...
 
T

TraderKevin

New member
Kinda sorta like a VWAP with Standard Deviations, but based on yesterdays close... Hmmm...
That's not what I got from what he said. Think he literally just wants to have horizontal lines at each 0.25% interval from previous day's close. I think these lines would be irrelevant and just clutter up the chart big time. Not something I'm interested in, personally.
 

Similar threads

Top