UPDATE: 14 Feb 09 – Added the option to only display the current day’s opening range for a cleaner appearance on charts.
This script will plot the opening range high and low for the specified time period. A great video on opening range trading can be found at MarketGauge.com




Great Scripts! This one doesn’t work for me though. It just plots both lines at 0. From what I can tell it copied over fine, but doesn’t seem to work.
Great blog! You have some good scripting techniques that I never thought of before. We could be long lost twin brothers–Mastering the Trade, Pivots, TICK, Thinkscript code… Spooky.
Good to find another Swimmer out in the blogonets!
Hi Thinkscripter,
You have programmed some awesome indicators from J. Carter and the opening range from Market Gauge. Is it possible for you to do the 3 DAY PIVOT HIGH AND LOW indicator. I will be glad to give you the definitions if you don’t have it…it is also from MG for swing trading.
Thanks, Randy
from the graph, the range is from 9:30-10:00 AM.
The definition of input openingRangeMinutes = 60;
will set the range to 9:300 – 10:300 AM as it plots on my chart – please advise
I have a wordpress tip: if you don’t like your script codes to be full justified (I don’t) just put this HTML around your code:
<p align=left > thinkscript </p>
Thanks!
I was hoping TOS or someone would code this. Great job. Thanks. Flex market hours are great for things like bonds and such that have their own hours.
Ok, I still like it, but. I can’t figure out why from the script but it appears that 15 is the minimum opening range period. I would like a 5 minute opening range. But I notice there is no change in the plot once you get to 15. Further reductions don’t change anything.
So that is true with a 5 minute bar. When I go to a 1 minute bar it appears to set the opening range using the 1st 6 bars.
So I changed the line to
def pastOpeningRange = if(secondsFromOpen >= (openingRangeMinutes * 60), 1, 0); when it used to add 1 to the opening range in seconds and now it behaves like I think it should behave. It gives me a 5 minute opening range even using 5 minute candles.
I am very pleased with myself for troubleshooting this and I remain grateful to you for being able to organize it and code it in the first place.
Good Trading, and keep coding. Thanks again.
Eric,
I think I found a bug in the OR code. When I set this up to give me a 5 min OR and set the value to 5, it actually gives me the OR of the first 2 five minute bars instead of just the first. Same thing happens with the 30. However — a workaround that I found is just to set the value 1 minute less than you want, i.e. 4 for the 5 min OR and 29 for the 30 min OR.
Also — for other uses. I am sure you know this, but you can actually set up more than one study if you like to trade with more than one OR on your charts. I personally use the 5 min and 30 min ORs.
Thanks for all that you do TS!
John
Yep…thanks. I have it on my to-do list to fix. I appreciate the help.
Eric
i had this when it was free how long ago did you start charging for this? mine got deleted today
yes, keith, michele, and geoff at marketgauge are experts at the opening range. made it easy for me to use with stocks
Check to make sure you have set your local market opening time in the panel. The default is 0930 for EST, but if you live in another time zone, you’ll need to put in your local times.
Thanks.
-TS
You can make the opening range minutes anything you like in the control panel. Some strategies use 30 some use 60 some use 15….whatever works for you.