Previous day 5' candle range?

Is there a "clean" way to find the range for the first five minute candle of the previous day? I would actually like to find the average 5' candle range for the first 1/2 hour of trading the previous day.
 
Is there a "clean" way to find the range for the first five minute candle of the previous day? I would actually like to find the average 5' candle range for the first 1/2 hour of trading the previous day.


what do you mean by range, high - low ? or body height?

what do you want to see?
a label with the average number from yesterday?
a lower chart with a line ?
 
what do you mean by range, high - low ? or body height?

what do you want to see?
a label with the average number from yesterday?
a lower chart with a line ?

I had done this before dinner, but hadn't had a chance to post. Perhaps this will help.

Ruby:
input daysago    = 1;
input range      = 6;
input agg        = aggregationPeriod.FIVE_MIN;

def rth          = if GetDay() != GetDay()[1]
                   then 0
                   else if Between(GetTime(), RegularTradingStart(GetYYYYMMDD()),
                                              RegularTradingEnd(GetYYYYMMDD()))
                   then rth[1] + 1
                   else rth[1];
def rangeavg = if GetDay() == GetLastDay() - daysago and
                  Between(rth, 1, range)
               then (Sum(high(period = Agg), range) - Sum(low(period  = Agg), range)) / range
                   else rangeavg[1];
AddLabel(1, "5m Avg, 1st 30m: " + AsDollars(rangeavg), color.yellow );
 
what do you mean by range, high - low ? or body height?

what do you want to see?
a label with the average number from yesterday?
a lower chart with a line ?
I've just been looking at the larger candles in the day as a trailing stop distance. I find I get stopped out if my stop is too tight and I was thinking the opening 5' candle range might help.
 
I had done this before dinner, but hadn't had a chance to post. Perhaps this will help.

hi sleepyz,
i had an idea what the op was asking for. but sometimes i ask questions to get them to elaborate , to help others understand and help.
i asked 3 questions, and he didn't answer any of them. oh well, he did explain what he is trying to do, @lostcoastsurf , thank you for that.

that is some interesting logic in the rangeavg formula. ( if GetDay() == GetLastDay() - daysago and .... )
i think your formulas are 1 bar off. rth starts at 0, so when rth=6 , it is the 7th bar, not the 6th.

i changed the initial rth to be 1 , and added a test bubble to display some values

Code:
input daysago    = 1;
input range      = 6;
input agg        = aggregationPeriod.FIVE_MIN;

def rth          = if GetDay() != GetDay()[1]
#                   then 0
                   then 1
                   else if Between(GetTime(), RegularTradingStart(GetYYYYMMDD()),
                                              RegularTradingEnd(GetYYYYMMDD()))
                   then rth[1] + 1
                   else rth[1];
def rangeavg = if GetDay() == GetLastDay() - daysago and
                  Between(rth, 1, range)
               then (Sum(high(period = Agg), range) - Sum(low(period  = Agg), range)) / range
                   else rangeavg[1];
AddLabel(1, "5m Avg, 1st 30m: " + AsDollars(rangeavg), color.yellow );

#------------------
def y = (GetDay() == GetLastDay() - daysago) and Between(rth, 1, range);
#---------------

def diffday = if getday() != getday()[1] then 1 else 0;
def rng = high-low;
def n = 6;
def avg = average(rng, n);

addchartbubble(1, low,
rng + " r\n" +
avg + " avg\n" +
rth + " rth\n" +
y + " y\n" +
rangeavg + " rnga\n"
, (if rth == 6 then color.yellow else color.gray), no);
#

cigJsLu.jpg
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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