ChrisMoody

New Indicator!!! Opening Range_V1

5048 53 437
Plots the Opening Range for the First Hour for Stocks and Forex . Option to Plot the first 30 Minutes Opening Range, or Both. See first Post for Specifics.
Remove from Favorite Scripts Add to Favorite Scripts
//Created by user ChrisMoody, with help from Alex in TechSupport and TheLark
//Currently works on Stocks
//Currently works on Forex but only based on the New York Session starting at 1700 East Coast Time
//Futurer Versions will have options to plot sessions bsed on Forex Europe Opening Range , Asia, etc.
study(title="CM_Opening-Range-V1", shorttitle="CM_OpenRnge-V1", overlay=true)
up60on = input(true, title="60 Minute Opening Range High")
down60on = input(true, title="60 Minute Opening Range Low")
up30on = input(false, title="30 Minute Opening Range High")
down30on = input(false, title="30 Minute Opening Range Low")

is_newbar(res) => change(time(res)) != 0 

adopt(r, s) => security(tickerid, r, s) 

high_range = valuewhen(is_newbar('D'),high,0)
low_range = valuewhen(is_newbar('D'),low,0)

high_rangeL = valuewhen(is_newbar('D'),high,0) 
low_rangeL = valuewhen(is_newbar('D'),low,0) 

up = plot(up60on ? adopt('60', high_range):na, color = lime, style=circles, linewidth=4)
down = plot(down60on ? adopt('60', low_range): na, color = #DC143C, style=circles, linewidth=4) 

trans60 = up60on ?  75 : 100
fill(up, down, color = white, transp=trans60)

up30 = plot(up30on ? adopt('30', high_rangeL): na, color = #7FFF00, style=circles, linewidth=2) 
down30 = plot(down30on ? adopt('30', low_rangeL): na, color = red, style=circles, linewidth=2) 

//trans30 = up30on ?  70 : 100
//fill(up30, down30, color = white, transp=trans30)
Current Version:
-Plots High and Low of Opening Range for first Hour (default) for Stocks and Forex. Option to plot 30 minute Opening Range.
-For Stocks - Only uses Cash Session and Pre/Post market hours must be turned off. (Will fix in future update.
-For Forex - Only plots Opening Range of New york session opening at 5pm East Coast time. (Will add Europe, Asia, Australia session options in future release).
*** IntraDay Futures are coming soon and will adjust Opening range times for those sessions.

Known Issue: Transparent background isn’t plotting if you only choose the 30 minute Opening Range. Will be fixed soon in a future release.

Video on how to import this Indicator:
http://blog.tradingview.com/?p=265


Link to Code for Indicator:
http://pastebin.com/ehNrkpCd
Reply
Also...if you using the first Hours Opening Range the max Bar size is 60 minute or 1 hour. Max Bar size is 30 Minute if your using the 30 Minute Opening Range Option.
Reply
This is a work in progress. There will be MANY updates. So if you like this indicator comment below and you will be notified when I post future updates.
Reply
Algokid PRO
2 years ago
Great job again Chris. Very useful for day trader, especially if paired with a Pivot Point Indicator.
Reply
fcha PRO
2 years ago
Thank you, this is really great!
Reply
uninformed
2 years ago
thank you!
Reply
Barabaszek
2 years ago
Very interesting.Good job.
Reply
johnmathew9
2 years ago
Is this Indicator is available for free subs.?
Reply
ChrisMoody PRO johnmathew9
2 years ago
All the indicators I post are for everyone. For this indicator you do need access to intraday timeframes. I use on 5 minute charts but a 60 minute chart would be the largest timeframe it will work on since it's using the first hours opening range. This video shows you to import the indicator. I'll have a updated indicator coming out soon that is more advanced. I'll post the update here so you'll be notified. Here is the link to the video http://blog.tradingview.com/?p=265
Reply
Dany2k
2 years ago
Great job Chris as always! I use this indicator on my Think or Swim platform is a great intraday tool. I got the code from think scrip website. The one I have has
a mid range line plus fibo extension lines at 1.382 and 1.618 something you could consider adding to yours. I am sure the peeps at TV will appreciate as we all
appreciate all you do. Cheers
Reply
4apprentice08
2 years ago
Thx for this....BTW FOREX NY does not start at 1700. That is the Wellington session.
Reply
4apprentice08
2 years ago
BTW, I posted a link to this script in the TradvingView support forum as someone was looking for something like this. See it here:
https://getsatisfaction.com/tradingview/topics/a_good_suggestion_from_some_tradingview_members_an_opening_range_breakout_indicator

FYI, Admin responded with the following suggestion:

"maybe you don't know about Pine Script new features:
https://www.tradingview.com/study-scr...
Inputs for session, resolution and symbol. You may use them in this script and make it more usable than now."
Reply
ChrisMoody PRO 4apprentice08
2 years ago
I sent you a private message regarding this.
Reply
ChrisMoody PRO ChrisMoody
2 years ago
Beyond the private message I sent you this is where we have gotten to.:
Stocks work perfect.
Forex works perfect based on NY Session open at 1700
We could code Europe etc but the problem is we couldn't get the lines to stop at 1700 when the day resets in Forex. So Europe was going from 0300 to 0300...this creates a problem b/c the typical use is to look at current days ranges on the timezone yuoo trade and then in comparison to the Opening Range of Other markets around the world. The issue is we need all the lines to stop plotting at the same time. I'll let you know as soon as this feature becomes available....which it may have been updated this week I just haven't heard back yet to verify or seen any documentation on how the function would be written.
Reply
4apprentice08 ChrisMoody
2 years ago
Thx....BTW I think the only sessions that would be of interest is the OPEN to the end of the ASIA session (and maybe LONDON). I got it to work for this range. If I need to include London, I could overlay to the end of London but I don't think that is used much. SO, as it stands, it works just fine.

All I would say is code it so the option is there for either the Stock market (30/60mins) or FOREX (to end of Asian session = 300 mins).

I would also ask it if is possible to only draw the respective indicator based on the Symbol used...i.e. draw ASIAN range when FOREX symbol selected, draw 30/60 mins when Equities selected. Not sure if one of the functions currently provides that info (or a work around using TICKID to ID the market?).
Reply
ChrisMoody PRO 4apprentice08
2 years ago
Will you email me the code you changed you mentioned in the 1st paragraph....I'll PM you my email address.

I'll have to check regarding recognizing Forex Vs. Stocks etc. Not sure on that one... I know you can specify a specific symbol, not sure if you can specify a group of symbols...Might be possible to create True condition for certain forex pairs since most forex traders don't actually trade that many symbols....
Reply
4apprentice08 ChrisMoody
2 years ago
I monitor many pairs, which also can change based on what the market does, so not worth it if limited to just a few pairs. So, good only if you can catch ALL forex vs not.
Reply
4apprentice08 4apprentice08
2 years ago
Maybe can simplify by using list of Exchanges. For example, if can do a conditional like if TICKID contains FX, draw Asian Session, else draw 30/60 mins. (Or If TICKID contains NASDAQ, NYSE, TSX, etc).
Reply
4apprentice08 ChrisMoody
2 years ago
Sure...send me a PM.
Reply
ChrisMoody PRO 4apprentice08
2 years ago
Did a while ago...check the pm tab
Reply
4apprentice08 4apprentice08
2 years ago
Oh, just a reminder, NY Open is NOT 1700. That is the Wellington open, though some mix it in and call it the Aussie open or even the Asia open...That said, the range from 1700-0300 works just fine for me as the "Asian Session Range".

So what I meant to say is that the "Asian Range" in FOREX is used similarly to the 30/60 min opening range.

Note however people may use different times for the "Asian Range". I currently have it set to 300 mins = 1700-2200 (oops, that is wrong, should be 480 = 1700-0300...I have to change my code). But others may want to use 2400, so would need to use a setting of 350. Is there a way to make this an input value?
Reply
ChrisMoody PRO 4apprentice08
2 years ago
Unless fomenting was released the last few days then no. We cab create input options like Enter 1 = SMA, 2 = EMA, 3 = HMA, so you can pick to use whichever one you want in your calculation...but currently we can't make Time an Input...have to actually code it manually.

As far as NY not opening at 1700 it is true and false...so I'll give that one to you. NY official trading day starts at 1700 and goes to 1700 the next day. BUT since for all the other sessions I'm using their active when the banks are open I'll change NY to 0800 when US banks open. Initially we couldn't that. But the added in the sessions function...Before that ALL Forex was based on the day starting at 1700 NY time and ending and 1700... Making good progress but we're just no there yet to make THIS CURRENT Project work perfectly TODAY...Maybe we will get a gift next week....
Reply
4apprentice08 ChrisMoody
2 years ago
So you CAN request a # input? If so, for now, I'm suggesting an input of # mins from open, so enter 30, 60, 300, etc. for mins from open.

BTW, Start of FOREX day = 1700. That is when swaps are settled and is official start of trading day. Start of NY = 0800.

So, as for sessions, the more I think about it, the more I think all that is needed is what I have added to your code. In other words, Just code for the open/start of the FOREX day at 1700 to soem close, eg. the end of Asian Session. 2 settings often used: 2400 (=420 mins from open) or 0200(=540 mins). But if can make the input user defined, with defaults, then that would be very good.
Reply
4apprentice08 4apprentice08
2 years ago
so maybe just have 2 entries for FOREX and 2 for stocks and let users decide?
Reply
4apprentice08 4apprentice08
2 years ago
FYI, Just stumbled across this. If you look at the Indicators Marketplace addons, check out AOS FX Primer. The first picture shows their implementation of identifying the opening range for each session (in the case they choose to show only 3). It is clear to that the capability is built into the background of TV for developers to draw the elements needed to create this indicator. I guess these features, such defining start and end times for shading an area have not been carried over to PINE yet. I look forward to seeing it happen there too. Do you have any pull in the matter? ;-)
Reply
sublimares2
2 years ago
Great tool - thank you. I have a code that I cannot make it work on the script. Can you have a peak and maybe you can make it work? Thank you again

//************************************************
// Inverse Fisher Transform Stochastic Oscillator
//************************************************
stochper = parameter("Stoch Period");
slowing = parameter("Stoch Slowing");
MA=Mov(C,2,W); RBW=5*MA;
MA=Mov(MA,2,W); RBW=RBW+4*MA;
MA=Mov(MA,2,W); RBW=RBW+3*MA;
MA=Mov(MA,2,W); RBW=RBW+2*MA;
MA=Mov(MA,2,W); RBW=RBW+MA;
MA=Mov(MA,2,W); RBW=RBW+MA;
MA=Mov(MA,2,W); RBW=RBW+MA;
MA=Mov(MA,2,W); RBW=RBW+MA;
MA=Mov(MA,2,W); RBW=RBW+MA;
MA=Mov(MA,2,W); RBW=(RBW+MA)/20;
RBWStoch=(Sum(RBW- low(RBW, stochper ) , slowing ) /
(Sum(high(RBW,stochper)- low(RbW,stochper),slowing)+0.0001)*100);
x = .1*(RBWStoch-50);
IFTStoch=((Exp(2*x)-1)/(Exp(2*x)+1)+1)*50;
Reply
ChrisMoody PRO sublimares2
2 years ago
I Think I have it done...Problem is I don't know what it is supposed to look like…This is a 1 year Daily chart of Apple.
Settings are below. Does this look right?
And what platform did that code come from So I can try and check it?

length = input(14, minval=1)
smoothK = input(1, minval=1)
smoothD = input(3, minval=1)
k = sma(stoch(close, high, low, length), smoothK)
d = sma(k, smoothD)

snapshot
Reply
ChrisMoody PRO sublimares2
2 years ago
Never mind....I found code on line for several platforms I own....I will plug in the code and make it match. The settings suggested are not what I have below.

Ay take me a couple of days but I will get it done.
Reply
ChrisMoody PRO sublimares2
2 years ago
This should be closer based on settings...I still need to verify I'm applying the settings to the correct inputs. Same AAPL Daily 1 year Chart...Using a 30 Period Stoch, with 10 period Smoothing

snapshot
Reply
sublimares2 ChrisMoody
2 years ago
Thank you Chris- I do not want to be time consuming for you. If this is something you can work off and on- its ok, otherwise we have like tons of indicators and oscillators on TV. Really appreciate your work and sharing.
Reply
ChrisMoody PRO sublimares2
2 years ago
Were getting close.... Check out this guys indicators. https://www.tradingview.com/u/LazyBear/

He's actually already coded the Inv fisher RSI and several others. I'm consulting with him and he is helping us out. He's also already coded the Cyber Cycle that I found when I started researching this code. Most people use it with this the Inv Indicators....
+1 Reply
pcmourao
2 years ago
Hey Chris, Great posts....Great Indicators, what can I say... On this Indicator, I don't seem to have the High/Low of the Range begining at the start of New York time on Forex.... any suggestions?
Reply
ChrisMoody PRO pcmourao
2 years ago
Currently it Plots US Stocks at open 9:30am EST correctly. For Forex it plots the open at 1700 EST. Right now all forex symbols are set to a session of 1700 to 1700 or 1659. I am actively trying to fix this b/c I want to see the Opening Range of Asia, Europe, and NY starting at 0800 EST.

The closest I've gotten is Plotting the Europe Session but the problem is the lines go for an entire 24 hours to 0300 the following day, so NY would plot from 0800 to 0800, which of course creates overlapping of session lines that are from the previous day. I need to get the lines to stop at 1700 for all sessions. It's my top priority right now...and I will post the update here so you will automatically be notified.
Reply
pcmourao
2 years ago
Any chance that when you create the script, it can actually signal a BUY/SELL sign visually on the chart?
Reply
ChrisMoody PRO pcmourao
2 years ago
I know what you are asking b/c I have that indicator on all my other platforms. Currently we can't plot "Markers" on the charts. The feature is coming as well as many other advanced features. One day we will be able to create entire strategy and systems that plot entries, pre defined profit targets, and stops. We will also have the ability to set alerts based on the signals for any instrument on any timeframe. It's all coming....It's just not Here Yet...

Here is a little secret for you. The founders of TV have created the most advanced Institutional grade platforms in existence. I know b/c I own them. People purchase those platforms that run extremely advanced systems, and they do everything your talking about with ease. A lot of the same programmers are working on TV. It's not a "Hope" these features come....what will be released in the next several months to a year will be advanced features 99.9% of all retail traders have never seen. TV users will have the most advanced platform ever created...that's is why I am here b/c I want to be a small part of it. We are working with a developer and will soon be implementing his system on TV. I have this developers system and your talking thousand and thousands of lines of code. The technology they have on the back end will give a TV user with a basic computer and or an iPad more features and capabilities than I have with "Very" expensive platforms and a 10K state of the art computer. ....And all for $20 a month plus a few add ons here and there.

Lots of great stuff coming.....Great time to be a Trader...
Reply
pcmourao ChrisMoody
2 years ago
thanks
Reply
NYORKA ChrisMoody
2 years ago
Chris, can you please notify me for any updates. I have added your script on my charts. however I am not sure If It updates automatically for any you do. Thanks
Reply
ChrisMoody PRO NYORKA
2 years ago
Yes....I have new code but haven't confirmed it works perfectly yet. I'll work on it tomorrow...If I haven't updated it by Tuesday morning please send me a PM and remind me....I need to get on that one.
Reply
ZigaZaga PRO ChrisMoody
2 years ago
Very interesting. I'm a long way off using it yet. just setting up a view...

snapshot

i think i saw the video of your ichimoku friend - he appeared to say to use a 12 minute interval for index trading....
snapshot
Reply
ChrisMoody PRO ZigaZaga
2 years ago
Good work...I have a new version I need to code...will keep you posted
Reply
ZigaZaga PRO ChrisMoody
2 years ago
Chris, thank you. Your remote session went very well - very clear and without unnecessary "static". I would love to learn more about trading this elusive Wall Street FX CFD - or FXCM(?) - is it popular in the US trading community? I believe it is in Europe. It's listed as simply "Wall Street" in many dealing platforms around the world and tracks the futures market. I'm anxious to learn more about it as I have been trading options based on this. Its relevant opening range is Wall Street hours and not the actual trading sessions of the instrument itself. I suppose what I'm getting is also useful information - just that its active trading is 9:30-10am New York time. Would be so useful to project specific exchange times with the important trading hour marked in the future.
Reply
ZigaZaga PRO ZigaZaga
2 years ago
snapshot
Reply
ZigaZaga PRO
2 years ago
Just setting up a workspace with this -
snapshot
would love to see and hear how best tu utilise this tool. would be cool to see the upcoming opens with a vertical line, don't you think?
Reply
pcmourao
2 years ago
Hey Chris, maybe you can help me uut here. Why is it that from the 19th to the 20th of June, SPY chart Gapped down at the open on the tradingview chart, when actually we gapped up ? Now, prior support/resistance line mismatch due to a chart glitch? Any idea?
Reply
ChrisMoody PRO pcmourao
2 years ago
I'll look in to it...have a new version I'm going to try and code today...slammed next few hours...If I don't respond by end of day remind me tomorrow...
Reply
pcmourao ChrisMoody
2 years ago
Have u checked the glitch out yet?
Reply
ChrisMoody PRO pcmourao
2 years ago
Interesting...The answer is they payed out a dividend. Here is what is confusing me. I just opened two platforms that both use Premium data from two different sources. One of the platforms back adjusted for the dividend and shows a gap up. The platform with what I would consider the highest quality data you can get...Period... Shows the same Gap down. Both of those platforms show a closing price of 198.20 based on the 7/3/2014 close... TradingView shows the same.

I'll call the Premium Data Vendor tomorrow and ask why they didn't back adjust the price and see what they say. And I'll call the other data vendor and see why they did back adjust the price. I don't trade stocks...but I know if a individual stock pays a dividend the price droops b/c the company has less money on their balance sheet so Wall Street adjusts the price accordingly. So my gut call is this is a rare situation where the SPY didn't show the same intraday chart as the SPX Index. I'll try and find out why one data vendor would show the historical prices different from the other one and TradingView....
Reply
pcmourao ChrisMoody
2 years ago
thanks
Reply
ZigaZaga PRO
2 years ago
Anxious to learn how many here are familiar with this instrument -
snapshot
and why it doesn't seem to get much attention. It trades round the clock and tracks the futures markets of the Dow 30, if I understand correctly. However, it's not the Far East but the Wall Street trading hours that are important in this market - it's when the real action happens - 9am-9:30am I believe. For me in London it's 2:30-9:00PM, which already can be confusing. Do you think I will ever be able to apply this code to track the wall street opening range, or would you propose a more suitable code for this issue? If ANYONE can shed any light on their experience trading this, please do so here or by PM.
+1 Reply
ChrisMoody PRO ZigaZaga
2 years ago
First why doesn't it seem to get much attention:

US residents can't trade it...unless they ca no pen up a trading account overseas with roughly a million dollars. Theres a few loopholes regarding creating a LLC (Business entity) and documenting you have a high net worth.

So this leaves us with people who live outside the United States who have a spot Forex Account...which is the majority of traders outside the US. The vast majority of those traders trade the Forex market exclusively. If they do trade (CFD's) I may have misspelled that...then the vast majority will trade the equivalent of the ES futures contract (S&P 500) vs. the Dow, or Spot Gold or Oil. Even in the US the Dow futures have pretty light volume...although there is plenty of volume to trade it.

How can you trade it:
The session can be customized to start plotting that indicator at the US open 9:30 New York time. Or you could simply use symbol DIA, the Dow 30 ETF on your chart...and if it breaks the opening range enter in the US30 you have access to. Th entries and exits should be 99.9% the same no matter which symbol you plot on the chart...Since the US30 is based on the DOW 30 if the prices were different their would be huge Arbitrage opportunities institutions would capitalize on...due to the liquidity those almost never exist. In my opinion the Dow futures trade "Cleaner" than the ES contract by far. One benefit of plotting the DIA symbol is you will be able to see gaps that the US30 won't show you. And you have to take Gaps in to account with the opening range trade....but that's a topic for another time....
Reply
Hi Chris, Great indicator. I see others have asked about different settings but to add to other comments, I am a forex trader and would like to be able to plot the range in Asia from 17:00 EST to 02:00 EST (540mins).
Many thanks for your great work.
Reply
Alphaoptions
2 years ago
Nice work!
Reply
traderfib236
a year ago
Hi Chris, Is there anyway to update this for futures? I'm looking to plot the 9:30am -10:30am EST opening range for Emini S&P futures. Thanks
Reply
Ideas Scripts Chart
United States
United Kingdom
India
España
Italia
Brasil
Россия
Türkiye
日本
한국
Home Stock Screener Economic Calendar How It Works Chart Features House Rules Moderators For the WEB Widgets Stock Charting Library Priority Support Feature Request Blog & News FAQ Help & Wiki Twitter
Private Messages Chat Ideas Published Followers Following Priority Support Public Profile Profile Settings Billing Sign Out