ATR Pivots

Rob3

New member
Hello!

I am wanting to know if this is possible and if so would someone be able show me how. I have very limited thinkscript experience.

I want to calculate the 14 day Average True Range.
Plot the opening print for the day as a horizontal line (on the daily timeframe candle value, not the 0930 value)
In increments of 0.125 up to 2.0 plot horizontal lines based on ATR values (positive and negative)

ATR line values are calculated by going open value + (atr value * 0.125)


Thanks!
 
Hello!

I am wanting to know if this is possible and if so would someone be able show me how. I have very limited thinkscript experience.

I want to calculate the 14 day Average True Range.
Plot the opening print for the day as a horizontal line (on the daily timeframe candle value, not the 0930 value)
In increments of 0.125 up to 2.0 plot horizontal lines based on ATR values (positive and negative)

ATR line values are calculated by going open value + (atr value * 0.125)


Thanks!

Hi Rob3,

I believe that this script produces the pivot lines you requested. It places a line on daily chart candles at the open as well as at locations above and below the open in increments of 0.125 * ATR. Putting 8 lines above and 8 lines below took up so much space that I only used increments up to 1.0 * the ATR. More lines can be added by following the pattern in the code.

Open line is yellow, lines above are blue, and lines below are red (colors and increments are adjustable).
4xkHvsq.png



Code:
# ATRpivots
# Question from Rob3; plots horizontal lines on daily candle that are at the open and above and below in increments of ATR * 0.125. The open is restricted to the Day aggregation period.

input price = open;
input length = 14;
input averageType = AverageType.WILDERS;
input ATRfraction = 0.125;
def ATR = MovingAverage(averageType, TrueRange(high, close, low), length);

plot LineAtOpen = open (period = AggregationPeriod.DAY);
plot UpperPivot1 = LineAtOpen + (ATR * ATRfraction);
plot UpperPivot2 = LineAtOpen + (ATR * ATRfraction * 2);
plot UpperPivot3 = LineAtOpen + (ATR * ATRfraction * 3);
plot UpperPivot4 = LineAtOpen + (ATR * ATRfraction * 4);
plot UpperPivot5 = LineAtOpen + (ATR * ATRfraction * 5);
plot UpperPivot6 = LineAtOpen + (ATR * ATRfraction * 6);
plot UpperPivot7 = LineAtOpen + (ATR * ATRfraction * 7);
plot UpperPivot8 = LineAtOpen + (ATR * ATRfraction * 8);

plot LowerPivot1 = LineAtOpen - (ATR * ATRfraction);
plot LowerPivot2 = LineAtOpen - (ATR * ATRfraction * 2);
plot LowerPivot3 = LineAtOpen - (ATR * ATRfraction * 3);
plot LowerPivot4 = LineAtOpen - (ATR * ATRfraction * 4);
plot LowerPivot5 = LineAtOpen - (ATR * ATRfraction * 5);
plot LowerPivot6 = LineAtOpen - (ATR * ATRfraction * 6);
plot LowerPivot7 = LineAtOpen - (ATR * ATRfraction * 7);
plot LowerPivot8 = LineAtOpen - (ATR * ATRfraction * 8);

LineAtOpen.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
LineAtOpen.SetDefaultColor(Color.YELLOW);
LineAtOpen.SetLineWeight(1);

UpperPivot1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
UpperPivot1.SetDefaultColor(Color.BLUE);
UpperPivot1.SetLineWeight(1);
UpperPivot2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
UpperPivot2.SetDefaultColor(Color.BLUE);
UpperPivot2.SetLineWeight(1);
UpperPivot3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
UpperPivot3.SetDefaultColor(Color.BLUE);
UpperPivot3.SetLineWeight(1);
UpperPivot4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
UpperPivot4.SetDefaultColor(Color.BLUE);
UpperPivot4.SetLineWeight(1);
UpperPivot5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
UpperPivot5.SetDefaultColor(Color.BLUE);
UpperPivot5.SetLineWeight(1);
UpperPivot6.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
UpperPivot6.SetDefaultColor(Color.BLUE);
UpperPivot6.SetLineWeight(1);
UpperPivot7.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
UpperPivot7.SetDefaultColor(Color.BLUE);
UpperPivot7.SetLineWeight(1);
UpperPivot8.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
UpperPivot8.SetDefaultColor(Color.BLUE);
UpperPivot8.SetLineWeight(1);

LowerPivot1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
LowerPivot1.SetDefaultColor(Color.RED);
LowerPivot1.SetLineWeight(1);
LowerPivot2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
LowerPivot2.SetDefaultColor(Color.RED);
LowerPivot2.SetLineWeight(1);
LowerPivot3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
LowerPivot3.SetDefaultColor(Color.RED);
LowerPivot3.SetLineWeight(1);
LowerPivot4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
LowerPivot4.SetDefaultColor(Color.RED);
LowerPivot4.SetLineWeight(1);
LowerPivot5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
LowerPivot5.SetDefaultColor(Color.RED);
LowerPivot5.SetLineWeight(1);
LowerPivot6.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
LowerPivot6.SetDefaultColor(Color.RED);
LowerPivot6.SetLineWeight(1);
LowerPivot7.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
LowerPivot7.SetDefaultColor(Color.RED);
LowerPivot7.SetLineWeight(1);
LowerPivot8.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
LowerPivot8.SetDefaultColor(Color.RED);
LowerPivot8.SetLineWeight(1);
 
Last edited by a moderator:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Rob3,

In case you meant that both the ATR and the open should be required to always be based on the DAY chart, here is version 2 that I believe does this. On the daily chart these two scripts give the same results, but on intraday charts they are different. Version 1 will base ATR numbers on whatever time frame is being observed while Version 2 uses daily chart ATR numbers no matter what time period is on the charts.

Code:
# ATRpivots_V2
# Version 2 requires the ATR to be based on the daily chart too.
# Question from Rob3; plots horizontal lines on daily candle that are at the open and above and below in increments of ATR * 0.125. The open is restricted to the Day aggregation period.

input price = open;
input length = 14;
input averageType = AverageType.WILDERS;
input ATRfraction = 0.125;

def h = high (period = AggregationPeriod.DAY);
def c = close (period = AggregationPeriod.DAY);
def l = low (period = AggregationPeriod.DAY);
def ATR = MovingAverage(averageType, TrueRange(h, c, l), length);

plot LineAtOpen = open (period = AggregationPeriod.DAY);
plot UpperPivot1 = LineAtOpen + (ATR * ATRfraction);
plot UpperPivot2 = LineAtOpen + (ATR * ATRfraction * 2);
plot UpperPivot3 = LineAtOpen + (ATR * ATRfraction * 3);
plot UpperPivot4 = LineAtOpen + (ATR * ATRfraction * 4);
plot UpperPivot5 = LineAtOpen + (ATR * ATRfraction * 5);
plot UpperPivot6 = LineAtOpen + (ATR * ATRfraction * 6);
plot UpperPivot7 = LineAtOpen + (ATR * ATRfraction * 7);
plot UpperPivot8 = LineAtOpen + (ATR * ATRfraction * 8);

plot LowerPivot1 = LineAtOpen - (ATR * ATRfraction);
plot LowerPivot2 = LineAtOpen - (ATR * ATRfraction * 2);
plot LowerPivot3 = LineAtOpen - (ATR * ATRfraction * 3);
plot LowerPivot4 = LineAtOpen - (ATR * ATRfraction * 4);
plot LowerPivot5 = LineAtOpen - (ATR * ATRfraction * 5);
plot LowerPivot6 = LineAtOpen - (ATR * ATRfraction * 6);
plot LowerPivot7 = LineAtOpen - (ATR * ATRfraction * 7);
plot LowerPivot8 = LineAtOpen - (ATR * ATRfraction * 8);

LineAtOpen.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
LineAtOpen.SetDefaultColor(Color.YELLOW);
LineAtOpen.SetLineWeight(1);

UpperPivot1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
UpperPivot1.SetDefaultColor(Color.BLUE);
UpperPivot1.SetLineWeight(1);
UpperPivot2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
UpperPivot2.SetDefaultColor(Color.BLUE);
UpperPivot2.SetLineWeight(1);
UpperPivot3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
UpperPivot3.SetDefaultColor(Color.BLUE);
UpperPivot3.SetLineWeight(1);
UpperPivot4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
UpperPivot4.SetDefaultColor(Color.BLUE);
UpperPivot4.SetLineWeight(1);
UpperPivot5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
UpperPivot5.SetDefaultColor(Color.BLUE);
UpperPivot5.SetLineWeight(1);
UpperPivot6.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
UpperPivot6.SetDefaultColor(Color.BLUE);
UpperPivot6.SetLineWeight(1);
UpperPivot7.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
UpperPivot7.SetDefaultColor(Color.BLUE);
UpperPivot7.SetLineWeight(1);
UpperPivot8.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
UpperPivot8.SetDefaultColor(Color.BLUE);
UpperPivot8.SetLineWeight(1);

LowerPivot1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
LowerPivot1.SetDefaultColor(Color.RED);
LowerPivot1.SetLineWeight(1);
LowerPivot2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
LowerPivot2.SetDefaultColor(Color.RED);
LowerPivot2.SetLineWeight(1);
LowerPivot3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
LowerPivot3.SetDefaultColor(Color.RED);
LowerPivot3.SetLineWeight(1);
LowerPivot4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
LowerPivot4.SetDefaultColor(Color.RED);
LowerPivot4.SetLineWeight(1);
LowerPivot5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
LowerPivot5.SetDefaultColor(Color.RED);
LowerPivot5.SetLineWeight(1);
LowerPivot6.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
LowerPivot6.SetDefaultColor(Color.RED);
LowerPivot6.SetLineWeight(1);
LowerPivot7.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
LowerPivot7.SetDefaultColor(Color.RED);
LowerPivot7.SetLineWeight(1);
LowerPivot8.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
LowerPivot8.SetDefaultColor(Color.RED);
LowerPivot8.SetLineWeight(1);
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
345 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top