calculate rth range and the average of the ranges over n days

earlyinout

New member
I am trying to figure code/formula to be able to have an input that is the lenght of days to calculate the average daily range. Currently I am using this for a 10 day average , but I want to be able to look at many different periods.
Code:
def Time =
    GetTime()
;
def Start =
    RegularTradingStart(GetYYYYMMDD())
;
def First =
    Time > Start and Time[1] <= Start
;
def Opening =
    if First then open
    else Opening[1];

input BEG = "OPENINg";





input showOnlyToday = yes;

input timeFrame = {default DAY, "2 DAYS", "3 DAYS", "4 DAYS", WEEK, MONTH, "OPTEXP"};
def RangeHigh = high(period = "DAY")[0];
def RangeLow = low(period = "DAY")[0];
def Range = AbsValue(RangeHigh - RangeLow);
def Range2 = AbsValue(RangeHigh[1] - RangeLow[1]);
def Range3 = AbsValue(RangeHigh[2] - RangeLow[2]);
def Range4 = AbsValue(RangeHigh[3] - RangeLow[3]);
def Range5 = AbsValue(RangeHigh[4] - RangeLow[4]);
def Range6 = AbsValue(RangeHigh[5] - RangeLow[5]);
def Range7 = AbsValue(RangeHigh[6] - RangeLow[6]);
def Range8 = AbsValue(RangeHigh[7] - RangeLow[7]);
def Range9 = AbsValue(RangeHigh[8] - RangeLow[8]);
def Range10 = AbsValue(RangeHigh[9] - RangeLow[9]);
def Range11 = AbsValue(RangeHigh[10] - RangeLow[10]);
def Range12 = AbsValue(RangeHigh[11] - RangeLow[11]);


def multiRange = (range + range2 + range3 +RANge4 +RANge5 + Range6 + range7 + range8 + range9 )/10;

def ran2 = range3;


AddLabel(1, " RANGE 10 DAY avg  " + multiRange ,Color.gREEN);

Iknow there has to be a btter way, please help!
 
I am trying to get code to get rth range for x number of days and print as a label, I already have code to do this by def every day and then multiplying by the number of days. I know there has to be a more efficient way to do this!

input 18 # would be the number of days to sum the daily range of and create the average.

Please Help
Thanks
 
I am trying to get code to get rth range for x number of days and print as a label, I already have code to do this by def every day and then multiplying by the number of days. I know there has to be a more efficient way to do this!

input 18 # would be the number of days to sum the daily range of and create the average.

Please Help
Thanks
Yes I have been working with a solution to relative volume, and so I am also working on a script that should solve this.

In addition to knowing the breadth of the moves you would also probably like to know if there were unusual volumes and if those volumes tend to congest the order-flow or harmonize.
 

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

Thread starter Similar threads Forum Replies Date
S RTH High and lows Index Futures 1
Branch How can I use a Range (Renko) in Custom Quotes as oppose to time Index Futures 1

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
433 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