NexusFi: Find Your Edge


Home Menu

 





ATR Box


Discussion in ThinkOrSwim

Updated
    1. trending_up 14,609 views
    2. thumb_up 6 thanks given
    3. group 4 followers
    1. forum 3 posts
    2. attach_file 1 attachments




 
Search this Thread

ATR Box

  #1 (permalink)
 
TonyB's Avatar
 TonyB 
Bay Area, CA - US
 
Experience: Beginner
Platform: TOS, TS & MC
Broker: TDA & TS
Trading: Stock, Options and now Futures (ES)
Posts: 516 since Dec 2010
Thanks Given: 227
Thanks Received: 140

Anyone aware of a Thinkscript code that would provide the ATR on a chart, within a box? It would seem easy enough, but my first two attempts have failed...

For anyone interested, try this:

declare upper;
input price = close;
input ATR_Length = 14;
input Show_Labels = yes;
def ATR = WildersAverage(TrueRange(high(period = aggregationPeriod.DAY)[1], close(period = aggregationPeriod.DAY)[1], low(period = aggregationPeriod.DAY)[1]), ATR_length);
def r_atr = round(ATR, 2);
#AddChartLabel(show_labels, concat("ATR(14d)=", r_atr), color.white);
AddChartLabel(if r_atr[1] < r_atr then yes else no, concat("ATR(14d)=", r_atr), Color.GREEN);
AddChartLabel(if r_atr[1] > r_atr then yes else no, concat("ATR(14d)=", r_atr), Color.RED);

++++++

Ok, it works great on a daily chart, but it's not working on a hourly or weekly (the other two I've tried thus far). I'll keep playing with it and ask for help on the TOS chat room... Ah, I see it.

Ok, this does the trick:

declare upper;

input ATRLength = 14;

def ATR = Average(TrueRange(high, close, low), ATRLength);
AddChartLabel(yes,concat("ATR(" ,concat(ATRLength, concat(") = ", ATR))),color.YellOW);
+++++

I was playing around with "getAggregationPeriod" as that gets the period on the chart, but I was doing something wrong. I checked the above against TOS's native ATR offering, and it matches-up...

Attached Thumbnails
Click image for larger version

Name:	Capture.PNG
Views:	713
Size:	14.6 KB
ID:	69371  
Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NexusFi Journal Challenge - April 2024
Feedback and Announcements
Are there any eval firms that allow you to sink to your …
Traders Hideout
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
Better Renko Gaps
The Elite Circle
ZombieSqueeze
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
61 thanks
Funded Trader platforms
39 thanks
NexusFi site changelog and issues/problem reporting
26 thanks
Battlestations: Show us your trading desks!
26 thanks
The Program
18 thanks
  #2 (permalink)
jmhjrh245
Raleigh, NC
 
Posts: 1 since Dec 2012
Thanks Given: 0
Thanks Received: 1

Thanks for the code! This is exactly what I was looking for. I did change the function AddChartLabel to AddLabel. I don't have AddChartLabel in my version of think or swim. That's all I did and it works beautifully. Thanks again!

Reply With Quote
Thanked by:
  #3 (permalink)
 mabr0408 
Minneapolis, MN
 
Experience: Advanced
Platform: Market Delta, Think or Swim
Broker: CQG
Trading: ES, NQ, 6E, CL, GOOG, AAPL, AMZN, GS
Posts: 26 since Sep 2012
Thanks Given: 1
Thanks Received: 17



TonyB View Post
Anyone aware of a Thinkscript code that would provide the ATR on a chart, within a box? It would seem easy enough, but my first two attempts have failed...

For anyone interested, try this:

declare upper;
input price = close;
input ATR_Length = 14;
input Show_Labels = yes;
def ATR = WildersAverage(TrueRange(high(period = aggregationPeriod.DAY)[1], close(period = aggregationPeriod.DAY)[1], low(period = aggregationPeriod.DAY)[1]), ATR_length);
def r_atr = round(ATR, 2);
#AddChartLabel(show_labels, concat("ATR(14d)=", r_atr), color.white);
AddChartLabel(if r_atr[1] < r_atr then yes else no, concat("ATR(14d)=", r_atr), Color.GREEN);
AddChartLabel(if r_atr[1] > r_atr then yes else no, concat("ATR(14d)=", r_atr), Color.RED);

++++++

Ok, it works great on a daily chart, but it's not working on a hourly or weekly (the other two I've tried thus far). I'll keep playing with it and ask for help on the TOS chat room... Ah, I see it.

Ok, this does the trick:

declare upper;

input ATRLength = 14;

def ATR = Average(TrueRange(high, close, low), ATRLength);
AddChartLabel(yes,concat("ATR(" ,concat(ATRLength, concat(") = ", ATR))),color.YellOW);
+++++

I was playing around with "getAggregationPeriod" as that gets the period on the chart, but I was doing something wrong. I checked the above against TOS's native ATR offering, and it matches-up...


thanks for this info...i was looking for the same thing as well. Since I trade off a small timeframe I would like the have the daily chart ATR value pull up on the smaller timeframe I trade off of in this format. Would you know how to code this? I am too lazy to look at a daily chart... from an organizational standpoint I like to have several equities/futures products up on my screens at once so higher time frame charts just take up space.

Reply With Quote
  #4 (permalink)
 
TonyB's Avatar
 TonyB 
Bay Area, CA - US
 
Experience: Beginner
Platform: TOS, TS & MC
Broker: TDA & TS
Trading: Stock, Options and now Futures (ES)
Posts: 516 since Dec 2010
Thanks Given: 227
Thanks Received: 140

For some reason my futures.io (formerly BMT) emails notification were in my spam folder! Glad the code has served some well...

Honestly, it has been over a month since I've logged into TOS. Between getting on-board with TS in late Jan, two toddlers and being in escrow with a pending move, TOS has not been a priority... I must say that I really like TS. Their options offering, a forte of TOS, has improved and is quite competent actually.

Thankfully, the new house has a dedicated office with an incorporated desk that will support my 4-monitor set-up beautifully. It will also have sufficient space for my gym equipment: weight bench, inversion table, recumbent bike and some other items. The bad news, it will take nearly 2 months before we can move-in as the place will need some TLC. Painted-over wallpaper in almost every room!

To get us back on topic, I'll be keeping TOS for sure. IRA accounts are free there, among other neat offerings...

Started this thread Reply With Quote




Last Updated on May 13, 2013


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts