Hello again,

I'm back with a bit of a different take on the Opening Range. This is a relatively simple indicator that analyzes movement during a specified time period and plots various lines based on that information. I am anchoring a VWAP (with standard deviations) to this start time as well to better judge the prevailing trend. The opening range is usually a daytrading tool and as such this will not display on daily or higher timeframes. There is another similar concept based on the weekly open range but that is a topic for another time.

In the image above, I have added the study twice. Once, from the European session open and once from the US Open. You will see the blue-ish lines representing the opening range for each of those periods with a mid-line and some extended targets based on the range. This study is intended to provide context to your trading system but is not a strategy in and of itself. If you are interested in learning more about why Opening Ranges are important and some different strategies to trade them, there is a more complex study with background information here: Opening Range Breakout.

There are options in this study to show the range as a label in the top left, to show/hide the extended targets and also to add additional 1/4 and 3/4 lines inside of the range. You can also enable bubbles to show that display the OR highs and lows but need to have an expansion area of 5 bars or so to display properly. And finally, there is an option to color your candles if they fall outside of the OR.

The options have two associated timeframes. One for the opening range you want to analyze (eg. 9:30 to 9:45) and another for the period for the lines to draw (eg. 9:30 to 16:00). In the image above, the first version has 2:30 to 3:30 as the European open range and 2:30 to 9:00 as the time to draw the lines. The second version (in the same chart) is 9:30 to 9:45 and then 9:30 to 16:00 for the line display. Hopefully this makes sense.

This study will work best on timeframes less than 1 hour and will perform will on tick charts. Range charts and renko charts will have some difficulties with the study and the VWAP will not work on those at all. This one was pretty fun to build. Please let me know if you have ideas for improvement.

I'm back with a bit of a different take on the Opening Range. This is a relatively simple indicator that analyzes movement during a specified time period and plots various lines based on that information. I am anchoring a VWAP (with standard deviations) to this start time as well to better judge the prevailing trend. The opening range is usually a daytrading tool and as such this will not display on daily or higher timeframes. There is another similar concept based on the weekly open range but that is a topic for another time.

In the image above, I have added the study twice. Once, from the European session open and once from the US Open. You will see the blue-ish lines representing the opening range for each of those periods with a mid-line and some extended targets based on the range. This study is intended to provide context to your trading system but is not a strategy in and of itself. If you are interested in learning more about why Opening Ranges are important and some different strategies to trade them, there is a more complex study with background information here: Opening Range Breakout.

There are options in this study to show the range as a label in the top left, to show/hide the extended targets and also to add additional 1/4 and 3/4 lines inside of the range. You can also enable bubbles to show that display the OR highs and lows but need to have an expansion area of 5 bars or so to display properly. And finally, there is an option to color your candles if they fall outside of the OR.

The options have two associated timeframes. One for the opening range you want to analyze (eg. 9:30 to 9:45) and another for the period for the lines to draw (eg. 9:30 to 16:00). In the image above, the first version has 2:30 to 3:30 as the European open range and 2:30 to 9:00 as the time to draw the lines. The second version (in the same chart) is 9:30 to 9:45 and then 9:30 to 16:00 for the line display. Hopefully this makes sense.

This study will work best on timeframes less than 1 hour and will perform will on tick charts. Range charts and renko charts will have some difficulties with the study and the VWAP will not work on those at all. This one was pretty fun to build. Please let me know if you have ideas for improvement.

Ruby:

```
# Opening Range w/VWAP
# Created by @tony_futures
# Inspired by @mighigandolf 's tweets
declare hide_on_daily;
input displayType = { "At timed start", default "From RTH Start"};
input startTime = 0930;
input End_Time = 0945;
input showTodayOnly = no;
input showLabels = yes;
input showVWAP = yes;
input showVWAPDevs = yes;
def RTH;
switch (displayType)
{
case "At Timed Start":
RTH = secondsFromTime(startTime) >= 0;
case "From RTH Start":
RTH = GetTime() >= RegularTradingStart(GetYYYYMMDD());
}
input anchorTime = 0930;
input anchorEnd = 1600;
def postAnchorTime = if SecondsFromTime(anchorTime) >= 0 then 1 else 0;
def endAchorTime = if SecondsTillTime(anchorEnd) >= 0 then 1 else 0;
def endPlot = secondsFromTime(anchorEnd) >= 0;
def Today = GetLastDay() == GetDay();
def ORActive = (Today OR !showTodayOnly) and RTH and SecondsFromTime(End_Time) < 0;
def ORhigh = if RTH and !RTH[1] then high else if RTH and ORActive and high > ORhigh[1] then high else ORhigh[1];
def ORlow = if RTH and !RTH[1] then low else if RTH and ORActive and low < ORlow[1] then low else ORlow[1];
def OROpen = if RTH and !RTH[1] then open else OROpen[1];
def ORClose = if !ORActive and ORActive[1] then close[1] else ORClose[1];
def ORFullRange = AbsValue(ORHigh - ORLow);
def midPoint = ORLow + (ORFullRange/2);
AddLabel(showLabels, "Open: " + OROpen + " | Close: " + ORClose + " | Range: " + ORFullRange + " |", Color.WHITE);
# setup Colors
DefineGlobalColor("quarterColor", CreateColor(169, 169, 169));
DefineGlobalColor("midColor", CreateColor(132, 76, 130));
DefineGlobalColor("rangeColor", CreateColor(28, 96, 109));
DefineGlobalColor("openColor", CreateColor(109, 84, 44));
DefineGlobalColor("downColor", CreateColor(109, 42, 28));
DefineGlobalColor("upColor", CreateColor(76, 133, 78));
DefineGlobalColor("vwapColor", CreateColor(174, 157, 50));
#
def OREnded = (Today OR !showTodayOnly) and RTH and SecondsFromTime(End_Time) >= 0;
plot ORL = if OREnded and !endPlot then ORlow else Double.NaN;
ORL.SetDefaultColor(GlobalColor("rangeColor"));
ORL.HideBubble();
plot ORH = if OREnded and !endPlot then ORhigh else Double.NaN;
ORH.SetDefaultColor(GlobalColor("rangeColor"));
ORH.HideBubble();
input showMidPoint = yes;
plot mid = if OREnded and !endPlot then midPoint else Double.NaN;
mid.setDefaultColor(GlobalColor("midColor"));
mid.HideBubble();
input showQuarters = no;
def oneQuarter = ORLow + (ORFullRange/4);
def threeQuarter = ORHigh - (ORFullRange/4);
plot oneQLine = if showQuarters and OREnded and !endPlot then oneQuarter else Double.NaN;
oneQLine.setDefaultColor(GlobalColor("quarterColor"));
oneQLine.HideBubble();
plot threeQLine = if showQuarters and OREnded and !endPlot then threeQuarter else Double.NaN;
threeQLine.setDefaultColor(GlobalColor("quarterColor"));
threeQLine.HideBubble();
input showMeasuredTargets = yes;
def upperTarget = (ORHigh + (ORFullRange/2));
plot upper = if showMeasuredTargets and OREnded and !endPlot then upperTarget else Double.NaN;
upper.SetDefaultColor(GlobalColor("upColor"));
upper.HideBubble();
def lowerTarget = (ORLow - (ORFullRange/2));
plot lower = if showMeasuredTargets and OREnded and !endPlot then lowerTarget else Double.NaN;
lower.SetDefaultColor(GlobalColor("downColor"));
lower.HideBubble();
input showMeasuredTargets2 = no;
def upperTarget2 = (ORHigh + (ORFullRange));
plot upper2 = if showMeasuredTargets2 and OREnded and !endPlot then upperTarget2 else Double.NaN;
upper2.SetDefaultColor(GlobalColor("upColor"));
upper2.HideBubble();
def lowerTarget2 = (ORLow - (ORFullRange));
plot lower2 = if showMeasuredTargets2 and OREnded and !endPlot then lowerTarget2 else Double.NaN;
lower2.SetDefaultColor(GlobalColor("downColor"));
lower2.HideBubble();
#plot anchored VWAP for the current day
def volumeSum = CompoundValue(1, if postAnchorTime and endAchorTime then volumeSum[1] + volume else 0, volume);
def volumeVwapSum = CompoundValue(1, if postAnchorTime and endAchorTime then volumeVwapSum[1] + volume * vwap else 0, volume * vwap);
def volumeVwap2Sum = CompoundValue(1, if postAnchorTime and endAchorTime then volumeVwap2Sum[1] + volume * Sqr(vwap) else 0, volume * Sqr(vwap));
def price = volumeVwapSum / volumeSum;
def deviation = Sqrt(Max(volumeVwap2Sum / volumeSum - Sqr(price), 0));
input stdDev = 1.0;
def numDevDn = -stdDev;
def numDevUp = stdDev;
plot anchorVWAP = if !showVWAP then Double.NAN else if showVWAP and showTodayOnly and !Today then Double.NaN else if RTH and showVWAP then price else Double.NaN;
anchorVWAP.SetStyle(Curve.FIRM);
anchorVWAP.SetDefaultColor(GlobalColor("vwapColor"));
plot anchorVWAPUpper = if !showVWAPDevs then Double.NaN else if showVWAPDevs and showTodayOnly and !Today then Double.NaN else if RTH and showVWAPDevs then (price + (numDevUp * deviation)) else Double.NaN;
anchorVWAPUpper.SetStyle(Curve.SHORT_DASH);
anchorVWAPUpper.SetDefaultColor(Color.GRAY);
anchorVWAPUpper.HideBubble();
plot anchorVWAPLower = if !showVWAPDevs then Double.NaN else if showVWAPDevs and showTodayOnly and !Today then Double.NaN else if RTH and showVWAPDevs then (price + (numDevDn * deviation)) else Double.NaN;
anchorVWAPLower.SetStyle(Curve.SHORT_DASH);
anchorVWAPLower.SetDefaultColor(Color.GRAY);
anchorVWAPLower.HideBubble();
input colorCandles = no;
AssignPriceColor(if !colorCandles then Color.CURRENT
else if colorCandles and OREnded and high < ORL and high < anchorVWAP then
GlobalColor("downColor")
else if colorCandles and OREnded and low > ORH and low > anchorVWAP then
GlobalColor("upColor")
else Color.CURRENT );
input showOpen = yes;
AddVerticalLine(showOpen and Today and RTH and !RTH[1], concat("Open", ""), GlobalColor("openColor"), curve.POINTS);
input showBubbles = no;
def showBubbleNow = !IsNaN(close) and IsNaN(close[-1]);
AddChartBubble(showBubbles and showBubbleNow[1], ORHigh[1], "OR High", Color.GRAY, yes);
AddChartBubble(showBubbles and showBubbleNow[1], ORLow[1], "OR Low", Color.GRAY, no);
```

Last edited: