NexusFi: Find Your Edge


Home Menu

 





2 ATRs in one indicator. Having a problem


Discussion in ThinkOrSwim

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




 
Search this Thread

2 ATRs in one indicator. Having a problem

  #1 (permalink)
 
LittleFinger's Avatar
 LittleFinger 
Denver Colorado/USA
 
Experience: Intermediate
Platform: SierraChart
Broker: AMP
Trading: ES
Posts: 116 since May 2017
Thanks Given: 132
Thanks Received: 145

Hello, I am trying to accomplish something that should be easy to do without any code modification.

I simply want 2 ATR lines drawn in one indicator window so that I can compare the behavior of a longer and shorter term reading. The problem is that the scaling of the chart changes the positioning of the lines relative to each other as you scroll forward or backward in time. I need the ATR lines to be static, so a numerical scale might do the trick instead of the default % scale.

Here's what I mean:

the overlapping is done in the edit studies window:


Below is 2 pics of the same data, but in the 2nd one i scrolled forward one day so you can see what I mean about the positioning of the lines changing relative to each other.



I want the lines to remain static, not float up and down to fit to the scaling.

Can anyone help with this?

Thanks

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
What broker to use for trading palladium futures
Commodities
Cheap historycal L1 data for stocks
Stocks and ETFs
Better Renko Gaps
The Elite Circle
About a successful futures trader who didnt know anythin …
Psychology and Money Management
MC PL editor upgrade
MultiCharts
 
  #2 (permalink)
 ocpb 
Hartford CT, USA
 
Experience: Beginner
Platform: None
Trading: ES
Posts: 126 since Jan 2015
Thanks Given: 152
Thanks Received: 125

It looks like in order to display two plots that properly maintain their relative y-scaling, they must be in the same study.

In TOS, the ATR is done in a built-in "TrueRange" function, so the study is one line of code, at the top level.
So here's a dual ATR for you . Not a general solution or setting, but I think it will work the way you want, in this case.

(In Edit Studies, click Create, paste in this code, give it a name and click OK.)

 
Code
declare lower;

input length1 = 14;
input length2 = 50;
input averageType = AverageType.WILDERS;

plot ATR1 = MovingAverage(averageType, TrueRange(high, close, low), length1);
ATR1.SetDefaultColor(GetColor(8));

plot ATR2 = MovingAverage(averageType, TrueRange(high, close, low), length2);
ATR2.SetDefaultColor(GetColor(1));

Reply With Quote
Thanked by:
  #3 (permalink)
 
LittleFinger's Avatar
 LittleFinger 
Denver Colorado/USA
 
Experience: Intermediate
Platform: SierraChart
Broker: AMP
Trading: ES
Posts: 116 since May 2017
Thanks Given: 132
Thanks Received: 145


Hey that works great! Seeing how simple that scripting was I think it might be worth it for me to finally dig into this stuff. I have other indicator ideas I wanted to implement like cumulative volume for zig zags and volume profile broken up into multiple time periods.

You win the award for the coolest person I interacted with today!


Started this thread Reply With Quote
Thanked by:
  #4 (permalink)
 ocpb 
Hartford CT, USA
 
Experience: Beginner
Platform: None
Trading: ES
Posts: 126 since Jan 2015
Thanks Given: 152
Thanks Received: 125


LittleFinger View Post
Hey that works great! Seeing how simple that scripting was I think it might be worth it for me to finally dig into this stuff. I have other indicator ideas I wanted to implement like cumulative volume for zig zags and volume profile broken up into multiple time periods.

You win the award for the coolest person I interacted with today!


Thanks! I accept this award, and I'd like to thank the Academy.

The learning curve for thinkscript is probably the easiest. The error messages that you get in the code editor can be cryptic sometimes, but the thinkscript online docs have gotten a lot better recently.

Maybe this would help with the volume studies you are working on.
It's from a well known ThinkScript blog.

https://readtheprospectus.wordpress.com/2010/02/15/cumulative-volume-by-time-indicator-for-think-or-swim/

The code is all listed somewhere here: https://sites.google.com/site/prospectus/welcome/released-thinkscript-studies

I believe there are ways within a script to access multiple time period data, if you use minute data only and are accessing higher timeframes.

Also, you may know, you can examine and copy thinkscript code from any of the built-in indicators, such as the code for Zig-Zag. Good luck!

Reply With Quote
Thanked by:
  #5 (permalink)
 
LittleFinger's Avatar
 LittleFinger 
Denver Colorado/USA
 
Experience: Intermediate
Platform: SierraChart
Broker: AMP
Trading: ES
Posts: 116 since May 2017
Thanks Given: 132
Thanks Received: 145

yes! that looks like about 3/4 of the puzzle for the zig zag thing. I'll definitely be perusing these. That RSI divergence indicator would be handy too.

Great stuff, thanks again

Started this thread Reply With Quote
Thanked by:




Last Updated on February 3, 2019


© 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