ChrisMoody

Opening Range Breakout with 2 Profit Targets.

Opening Range Breakout with 2 Profit Targets.

Updated Indicator now works on all Symbols with Many Different Session Options.

***Known PineScript Issue…While the Opening Range is being Formed the lines only adjust for that individual bar. Just reset Indicator after Opening Range Completes.

***All Times are Based on New York             Time
Session Options Forex U.S. Banks Open (8:00), Gold             U.S. Open (8:20), Oil             U.S. Open (9:00), U.S. Cash Session - Stocks (9:30), NY Forex Open (17:00) , Europe Open (02:00), or if you choose Setting 0 the Session Runs from 00:00 to 00:00 (Midnight to Midnight).

***Ability to use 60 minute Opening Range, 30 minute, 15 minute, and many other options.

***However you can manually change the times in the Inputs Tab to adjust for any session you prefer. This is useful for Day Light Savings Adjustments. Also the default times work if your charts are set to EST Time. If you use A different time zone in your settings you need to Adjust the times in the inputs tab.

Initially Opening Range High and Low plot as Yellow Lines. If Price Goes Above Opening Range then Line Turns Green. If Price Goes Below Opening Range Line Turns Red.

By default the First Profit Target is 1/2 the Width of the Opening Range and the 2nd Profit Target is 1 Times the Opening Range. However these are Adjustable in the Inputs Tab.

By Default the Opening Range Length is 1 Hour. However, you can Change the Opening Range Length to 15 min, 30 min, 2 hours etc. in the Inputs Tab.

Plots a 1 Above or Below Candle when 1st Profit Target is Achieved, and a 2 when 2nd Profit Target is Achieved.
Remove from Favorite Scripts Add to Favorite Scripts
//Created by ChrisMoody on 7-07-2014, Special Thanks To "The Coding Genius Behind The Curtain"
study(title="_CM_Opening-Range-Final", shorttitle="_CM_OpenRange_PlusTargets", overlay=true)

sessNum = input(4, title="Session to use (0 = 24 Hours, Other Numbers Listed Below)", minval=0, maxval=6)
desc = input(false, title="Below---Line Plot Start Times and End Times---Change Input Above To Select")
forex_US_BankingOpen = input('0800-1700', type=session, title="1 - Forex U.S. Banks Open -- ALL START TIMES = START OF OPENING RANGE!!!")
gold_US_Open = input('0820-1700', type=session, title="2 - Gold U.S. Open -- All End Times are when Lines Stop Plotting")
oil_US_Open = input('0900-1700', type=session, title="3 - Oil U.S. Open")
usStocksOpen = input('0930-1600', type=session, title="4 - U.S. Cash Cash Session - Stocks Session")
nyForexOpen = input('1700-1600', type=session, title="5 - NY Forex Open")
europeOpen = input('0200-1700', type=session, title="6 - Europe")
pt1 = input(5, minval=1, maxval=15, title="Profit Target 1 - Multiple of Opening Range *.1, 5 = .5, 7 = .7, 10 = 1, 15 = 1.5 etc.")
pt2 = input(10, minval=1, maxval=30, title="Profit Target 2 - Multiple of Opening Range *.1, 10 = 1, 15 = 1.5, 18 = 1.8, etc.")
res = input('60', type=resolution, title="Length Of Opening Range?")
snp = input(true, title="Plot 1 and 2 When 1st and 2nd Profit Target are Achieved?")

//Session Selection Rules
sessToUse = sessNum == 1 ? forex_US_BankingOpen : sessNum == 2 ? gold_US_Open : sessNum == 3 ? oil_US_Open : sessNum == 4 ? usStocksOpen : sessNum == 5 ? nyForexOpen : sessNum == 6 ? europeOpen :'0000-0000'

//Session Rules
bartimeSess = (sessNum == 0 ? time('D') : time('D', sessToUse))
fr2to17 = (sessNum == 0 ? time(period) : time(period, sessToUse)) 
newbarSess = bartimeSess != bartimeSess[1]
high_range = valuewhen(newbarSess,high,0)
low_range = valuewhen(newbarSess,low,0)
adopt(r, s) => security(tickerid, r, s)

//Formula For Opening Range
highRes = adopt(res, high_range)
lowRes = adopt(res, low_range)
range = highRes - lowRes

//Highlighting Line Rules For Opening Range
highColor = high > highRes ? lime : yellow
lowColor = low < lowRes ? red : yellow

//Plot Statements For Opening Range Lines
openRangeHigh = plot(fr2to17 > 0 ? highRes : na, color=highColor, style=circles, linewidth=4)
openRangeLow = plot(fr2to17 > 0 ? lowRes : na, color=lowColor, style=circles, linewidth=4)
bgcolor(fr2to17 > 0 ? silver : na, transp=85)
fill(openRangeHigh, openRangeLow, color=silver, transp=70, title="Opening Range Fill")

//Formula For Profit Target 1
pft1 = pt1*.1
highRes2 = highRes+range*pft1
lowRes2 = lowRes-range*pft1

//Highlighting Line rules for Profit Target 1
highColor2 = high > highRes2 ? lime : fuchsia
lowColor2 = low < lowRes2 ? lime : fuchsia

//Plots For Profit Target 1
p1=plot(fr2to17 > 0 ? highRes2 : na, color=highColor2, style=circles, linewidth=4)
p2=plot(fr2to17 > 0 ? lowRes2 : na, color=lowColor2, style=circles, linewidth=4)

//Formula For Profit Target 2
pft2 = pt2*.1
highRes3 = highRes+range*pft2
lowRes3 = lowRes-range*pft2

//Highlighting Line rules for Profit Target 2
highColor3 = high > highRes3 ? lime : aqua
lowColor3 = low < lowRes3 ? lime : aqua

//Plots For Profit Targe 2
plot(fr2to17 > 0 ? highRes3 : na, color=highColor3, style=circles, linewidth=4)
plot(fr2to17 > 0 ? lowRes3 : na, color=lowColor3, style=circles, linewidth=4)

//Rules for when to plot Numbers 1 or 2 When Profit Target 1 or 2 is Reached
pt1UHit = (high >= highRes2  and high[1] < highRes2 and high[2] < highRes2 and high[3] < highRes2 and high[4] < highRes2 and high[5] < highRes2) and fr2to17 > 0 
pt1LHit = (low <= lowRes2  and low[1] > lowRes2 and low[2] > lowRes2 and low[3] > lowRes2 and low[4] > lowRes2 and low[5] > lowRes2) and low > lowRes3 and fr2to17 > 0
pt2UHit = (high >= highRes3  and high[1] < highRes3 and high[2] < highRes3 and high[3] < highRes3 and high[4] < highRes3 and high[5] < highRes3) and fr2to17 > 0 
pt2LHit = (low <= lowRes3  and low[1] > lowRes3 and low[2] > lowRes3 and low[3] > lowRes3 and low[4] > lowRes3 and low[5] > lowRes3) and fr2to17 > 0

//Rules for plotting 1 or 2 When Profit Target 1 or 2 is Reached
plotchar(snp and pt1UHit ? pt1UHit : na, title='UpSide Profit Target 1 Achieved', char='1', location=location.abovebar, color=white, transp=0, offset=0)
plotchar(snp and pt1LHit ? pt1LHit : na, title='DownSide Profit Target 1 Achieved', char='1', location=location.belowbar, color=white, transp=0, offset=0)
plotchar(snp and pt2UHit ? pt2UHit : na, title='UpSide Profit Target 2 Achieved', char='2', location=location.abovebar, color=white, transp=0, offset=0)
plotchar(snp and pt2LHit ? pt2LHit : na, title='DownSide Profit Target 2 Achieved', char='2', location=location.belowbar, color=white, transp=0, offset=0)
aryahi29 PRO
2 years ago
1. The price is exceeding 2. so, at that new high the all begins?
2. Can we always wait until 2 appears and then only sell?.. any conditions?
Reply
ChrisMoody PRO aryahi29
2 years ago
I have to be blount ands say your reading to much in to this...

#1 It's a opening range breakout strategy. While different instruments act in different ways if you spend time taking a look at instruments that this strategy consistently works...You'd be better off. The strategy has worked historically...although it's better on markets that MOVE...You'll also find the Stock Index's or Futures will give false breakouts if you use 1 hour...but look at them on a 15 minute breakout.

The reason I believe your thought process of selling #2 wouldn't work is b/c those levels change based on the distance of the opening range...so one day you will have a wide opening range and target #2 is so far away if it's reached then that might be the end of the move...but the next day the opening range might be narrow and therefore profit target 2 is not far away at all and price blows through it and never looks back.

Setup...Find instruments that the breakout works consistently...and that may not be based on a 1 hour range. You enter on Breakout and place stop at other side of opening range. Target 1 gets hit bring stop to middle of opening range or the entry price. Target two gets hit and your done for the day....I know for a fact there are major Hedge Funds that use this as one of their Major Strategies. It looks to simple to work...but it works.

Some funds take 100% profit at target 1
Some use the method I described earlier.
Some only exit if profit target 2 is hit but they bring up their stop to break even aft target 1 is reached.
Some scale out in 1/3rds....Target 1, target 2, then they leave a runner until the close. This strategy back tests the best because you have those days when you get HUGE moves..and the big moves drastically increase your Profit/Loss. Although taking 100% off at profit target 1 and being done for the day...is a nice lifestyle...That's where knowing your probabilities and position sizing accordingly comes in.

If your looking to FADE moves...there are better strategies than this one.
Reply
aryahi29 PRO ChrisMoody
2 years ago
Thank you, Chris, for your patience, wisdom, and your zeal to teach and help.. Now I have a clear picture.. Is it too much to ask about FADING STRATEGIES also? I'd greatly appreciate, if you could..
Reply
zzfx ChrisMoody
2 years ago
excellent.

hey aryahi... focus on what Chris is relay doing as a whole: he is Focusing on RR and goal achievement that he applies to a framework that makes sense to him.

Not on the actual flashing lights. he probably does not care about the outcome. he knows that if he follows these lights, that tells him, that he is respecting his RR and MM settings and that sooner or later he will succeed inside the timelines he is playing. he is focused on the right thing and that's why he is probably a profitable trader. Start all your preparation respecting RR and MM, and the ride will hopefully be less hard core.

good trading guys!
zzfx
+1 Reply
ZigaZaga PRO ChrisMoody
2 years ago
You've built a code factory! The customised timings are extremely useful. The style tab doesn't fit into my screen http://gyazo.com/f9f968d65b717471795eaaae78447205 but it's hardly a problem. Do you find that all you need can be done on an Apple Mac? I expect you have a clearer head compared to windows.
Reply
aryahi29 PRO ZigaZaga
2 years ago
hi zigzaga: I find that the opening range break out system works nicely. the central yellow circles determining the support and then the rise or the fall?
Reply
ZigaZaga PRO aryahi29
2 years ago


If I understand correctly, when it breaks up or down through the yellow dots defining the opening range, the dots turn green or red (super cool touch!). If you take that as a signal and go long or short accordingly, then you can just manage your trade like any other + you have the benefit of 2 profit targets for guidance - magenta and cyan.
snapshot
Reply
Hi Chris, this is great !!! Could you add an option to be able to select for a 9hr range. The largest is 3hrs and then 1 day. I am trying to capture the Asia session range (9hrs).
Reply
ChrisMoody PRO Ataraxia_FX
2 years ago
yes...would have to be customized since it's not a default timeframe....PM and remind me and I'll get the script done within the next week.
Reply
stefitch
2 years ago
Hi Chris.
Yet another great add on. I find that with the ftse and dax on the 2hr setting this script is excellent. about 100 pips per index per week. And the best thing is I can set and forget if i'm at work. Different money management strategy but still works well.
Reply
ChrisMoody PRO stefitch
2 years ago
Yeh...Set it and forget it...is a great thing. Don't remember if I mentioned it. But a strategy that typically tests out the best is Sell 1/3rd at PT1 (50% or Range)...AND Bring Stop To Break Even. Sell 1/3rd at 2nd profit target (1 times opening range)...And sell 1/3rd at close. While over a shorter term period you make more if you take 1/2 off at PT1 and 1/2 off at PT2....over the long term you get those HUGE trend days and that last 1/3rd can make your account grow quick...
+3 Reply
bd.barney.7
2 years ago
Dear All,

I apologize in advance if my question is a bit rudimentary. I am new in Forex and Tradingview. I did some back testing on this custom indicator. It seems to produce fruitful results. However, when I am trying to create an alert on this indicator, I am getting confused seeing an option called "Plot". Here is what I did - Clicked on the Alert button and a box popped up, In the box I changed the condition from EUR/USD to CM_Opening Range Asis Europe Session. The a new option "Plot" pops up right next to the option "condition". Could someone please tell me how to get notification when the price is breaking range in the either side.
Reply
ChrisMoody PRO bd.barney.7
2 years ago
This was coded before alert capabilities....I'll re code a new Version
Reply
bd.barney.7 ChrisMoody
2 years ago
Thank you. You are the best...
Reply
DanielDaCosta ChrisMoody
19 days ago
@ChrisMoody, Hi Chris! Did you manage too code a new version with alerts?
Reply
bd.barney.7
2 years ago
As a what is beginner, this method is turning out to be a very consistent one...
Reply
Nice to work , and i like alert idea for this ...

Surprise me with update include alert ,

Thank you CM
Reply
ZigaZaga PRO
2 years ago
Hi, Chris! I'm consistently getting distortions like this -
snapshot
- any ideas on how to fix it?
Reply
ZigaZaga PRO ZigaZaga
2 years ago
snapshot
Reply
wayne.stanley.127 PRO ZigaZaga
a year ago
Chris, sometime the charts lod with the correct market time and sometimes they to do not. I need to change the time zones but at time they work. I tried my system time but that is not working. I ask Tradingview to look into this as I use the 5min OR settings. This worked for awhile but the last week timing issue are showing up and the OR starts in Pre and AH. Just thought I would let you know. Thanks for everything
Reply
wayne.stanley.127 PRO wayne.stanley.127
a year ago
Chris, this is what going on from time to time.
snapshot
Reply
wayne.stanley.127 PRO wayne.stanley.127
a year ago
I do have the correct market settings 4. US Cas session 0930-1600 but at times need to adjust 1130-2000. What do you think the issue is?
Reply
wayne.stanley.127 PRO wayne.stanley.127
a year ago
Chris, you’re the man. I always look forward to your products!
Reply
DanLaffas
17 days ago
Hi Chris, are you able to put together a quick indicator to plot a horizontal line from the opening price of a set time? Perhaps even to have the option to plot multiple user defined opening prices.

Example here of manually drawn lines
snapshot


Thanks mate
Reply
ChrisMoody PRO DanLaffas
14 days ago
@DanLaffas, Well...I could...kind of a niche request...do me a favor...I created 2 indicators that plot the High, Low, Open, Close on different time frames the intra day one I believe is _CM_High_Low_Open_Close_Weekly-Intraday if you search for that one. Difference is on this one I let you select actual times it starts plotting. the other one I mentioned since were using the open, I didn't put user inputs to adjust the time...Example...You can pick a Daily, or 1 hour, etc and choose whether it plots today and or plots the previous days HLOC on todays bar.

Let me know if that one will work for you...hopefully it does...if not it's just taking the features from 2 separate codes an combining them isn't that hard...

just let me know...just found the link...

_CM_High_Low_Open_Close_Weekly-Intraday
Reply
DanLaffas ChrisMoody
12 days ago
@ChrisMoody, Thanks Chris. I currently use this opening range indicator for trading sessions and it can't do what I'm looking for. The '_CM_High_Low_Open_Close_Weekly-Intraday' on the other hand is very close to what I'm looking for. I've unchecked all the options and just left 'Daily Open' checked in the style tab. All it needs now is to allow the user to input which candle open to use. What do you think?

snapshot
Reply
DanLaffas DanLaffas
12 days ago
@ChrisMoody Oh and to still plot the line for 24hrs from the chosen candle. Cheers mate.
Reply
DanLaffas ChrisMoody
12 days ago
@ChrisMoody, Here is what I've done so far (by cutting out all the unnecessary options).

//Created By ChrisMoody on 6-14-2014 -- Modified by DanLaffas 11-23-2016
//Updated for Forex and Intraday traders. No plots Current and Previous Sessions Data based on Weekly, Daily, 4 hour, 2 hour, 1 hour OHLC
//Daily Session To be used on IntraDay Charts
study(title="_CM_Candle_Open", shorttitle="_CM_Candle_Open", overlay=true)
st = input(true, title="Show Todays OHLC?")
sy = input(false, title="Show Yesterdays OHLC?")

//Daily
tdo = security(tickerid, 'D', open)
pdo = security(tickerid, 'D', open)

//Daily Plots
offs_daily = 0
plot(st and tdo ? tdo : na, title="Daily Open", style=circles, linewidth=2, color=silver)
plot(sy and pdo ? pdo : na, title="Previous Days Open", style=cross, linewidth=2, color=silver)
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