High-Low Daily Range


Category:
0
0

I’m new to building TOS scripts and struggling to build a study which charts the daily and average price range for a stock.  I don’t know how to write the script for calculating the average trading range.   Hope you can help Pete, much appreciated.

#Study to find high daily trading range stocks as percentage of price
#plot AverageRange and daily ranges
#use to filter stock with high PercentRange

declare lower;

input Period = 7;

def Range = high – low;
def PercentRange = Range/low;

#calculate average range for the Input period
#def AveargeRange = PercentRange for the input period

Plot PercentRange;
Plot Range;

 

Marked as spam
Posted by (Questions: 1, Answers: 1)
Asked on March 31, 2022 9:35 am
223 views
0
I looked at the ATR and TRI studies and it appears they are more complicated then what I need. They both appears to calculate very large Range values that are 5-10 time the value I would expect. The more more complicated formulas also appears to change value when you change the chart length, 30 days or 90 days. I understand the concept of the studies but I obviously don't understand the calculation.
( at March 31, 2022 2:59 pm)
0
Apple today dropped approx $4 on approx $174 low. That would be approx
( at March 31, 2022 3:06 pm)
0
Sorry it appears i was having some type of conflict between added studies on my chart. deleted all and started again, working as it should.
( at March 31, 2022 3:17 pm)
0
Private answer

You don't need to write any code to do this. There is a built-in chart study named "ATR" which you can add to your chart.

If you want to see the range for each single bar on the chart then adjust the length input of the "ATR" study to a value of 1. The default length is 14. The screenshot below shows the "ATR" study added to the chart two times. Once is set to a length of 1 and the other is set to a default length of 14.

Now you have learned the very first rule in writing code. Which is:

  1. Don't write code unless you absolutely have to
Attachments:
Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on March 31, 2022 10:37 am