//Created by user ChrisMoody 2-17-2014 //Forex Session Templates Based on EST-New York Time Zone //Special Thanks to TheLark AKA The Coding Genius for helping me with the "On - Off" CheckBoxes in the inputs tab study(title="CM_Forex-Sessions-Highlight_V1",shorttitle="CM_forex_Sess_Highlight", overlay=true) timeinrange(res, sess) => time(res, sess) != 0 //Change true to false = You have to turn on, won't show up by default //****Always use lowercase letters doNYOpen = input(defval=true, type = bool, title="NY Open On") doNYSession = input(defval=true, type = bool, title="NY Session On") doNYClose = input(defval=true, type = bool, title="NY Close On") doAussieOpen = input(defval=true, type = bool, title="Aussie Open On") doAussieSession = input(defval=true, type = bool, title="Aussie Session On") doAussieClose = input(defval=true, type = bool, title="Aussie Close On") doAsiaOpen = input(defval=true, type = bool, title="Asia Open On") doAsiaSession = input(defval=true, type = bool, title="Asia Session On") doAsiaClose = input(defval=true, type = bool, title="Asia Close On") doEurOpen = input(defval=true, type = bool, title="Euro Open On") doEurSession = input(defval=true, type = bool, title="Euro Session On") doEurClose = input(defval=true, type = bool, title="Euro Close On") //You can copy and paste these colors. white - silver - gray - maroon - red - purple - fuchsia - green - lime // olive - yellow - navy - blue - teal - aqua - orange nySessionStart = white nySession = white nySessionEnd = white australiaSessionStart = #A9A9A9 australiaSession = #A9A9A9 australiaSessionEnd = #A9A9A9 asiaSessionStart = #DAA520 asiaSession = #DAA520 asiaSessionEnd = #DAA520 europeSessionStart = #1E90FF europeSession = #1E90FF europeSessionEnd = #1E90FF //****Note ---- Use Military Times --- So 3:00PM = 1500 bgcolor(doNYOpen and timeinrange(period, "0800-0810") ? nySessionStart : na, transp=20) bgcolor(doNYSession and timeinrange(period, "0800-1700") ? nySession : na, transp=75) bgcolor(doNYClose and timeinrange(period, "1650-1700") ? nySessionEnd : na, transp=20) bgcolor(doAussieOpen and timeinrange(period, "1700-1710") ? australiaSessionStart : na, transp=20) bgcolor(doAussieSession and timeinrange(period, "1700-0200") ? australiaSession : na, transp=75) bgcolor(doAussieClose and timeinrange(period, "0150-0200") ? australiaSessionEnd : na, transp=20) bgcolor(doAsiaOpen and timeinrange(period, "1900-1910") ? asiaSessionStart : na, transp=20) bgcolor(doAsiaSession and timeinrange(period, "1900-0400") ? asiaSession : na, transp=75) bgcolor(doAsiaClose and timeinrange(period, "0350-0400") ? asiaSessionEnd : na, transp=20) bgcolor(doEurOpen and timeinrange(period, "0300-0310") ? europeSessionStart : na, transp=20) bgcolor(doEurSession and timeinrange(period, "0300-1200") ? europeSession : na, transp=75) bgcolor(doEurClose and timeinrange(period, "1150-1200") ? europeSessionEnd : na, transp=20)
This is a simple code but since the sessions overlap I had a VERY touch time finding colors that allowed you to tell the plots were overlapping. You can modify based on the background color of your chart. Video Below Gives Tips and Shows the Easiest Way!!!
This Indicator is based on East Coast - NY Time. Currently you have to go into the code to change the times. Detailed Video below shows how to do this. Also there is a new video showing a better way to share and import indicators. Credit goes to TheLark for showing me.
Good News is TheLark showed me how to place Check Boxes in the inputs tab so you can easily turn on and off any of the sessions you want. Also I created a Darker plot the first 10 minutes of each session beginning and end, So you can plot all of those on 1 chart and uncheck the Highlight for the whole session. Because the Opening/closing session plots are 10 minutes each you need to use a lower timeframe or they will not plot correctly. If using a 4 hour bar for example uncheck the Open/Close of session and just use background highlight.
Titled - Importing Custom Indicators In TradingView Charts
New Video Showing how to change the times in the code to match your time zone.
Titled: How To: Change Time In Code - Background Highlights
***Recommend watching this video to understand Indicator, Shows How To Change Time in Code, Shows easier way to Change Colors, also shows a demo of similar Indicators I’m about to release.
Link To Both Videos:
I'm happy to help..just not sure what steps you've taken...to get an error at line 1:0....
Maybe this could easily be constructed using your 30min/1hr high/low code as a starting point. Let me know what you think.
2. That code just does the Opening Range in Stocks, 9:30 East Coast, or 1700 or 5pm New York Time for Forex.
3. It could only be coded for Forex for different sessions like the Europe or Asia Session making a different indicator. That may have been fixed. I'll check b/c I wanted to create options for all forex sessions.
4. I like the idea of coding the sessions to plot on a lower indicator...I'll look in to it.
5. I'll look at the code regarding your first question regarding labels, my initial resposnse is no b/c normally I would have done that. But I will double check. If they were horizontal lines you could b/c you could address each upper an dlower plot seperately and apply a name to them, and then just create a fill between the two. Plotting background highlights like this indicator does uses a new feature where it is all one plot and I don't think it allows to name it...but again I willl check...
Copy and paste this code over line #5 ---- Then Press SAVE and then Apply to chart - you will still have original one that plots on price chart and this new one that plots on lower indicator.
This will rename the study with a LowerStudy at the end of the name. And the overlay=false means it will plot as lower study
The chart shows adding the study two times and plotting two of the time zones on each that don't overlap.
You could also plot two of the time zones on the upper chart and then just have one lower study with the other two so none overlap.
Also in the code you can find where it lists the code below....if you change the defval=true to defval=false then it won't automatically plot that when you apply to chart. So you can make two of the sessions false and then on Line#5 change the first title tobe named title="CM_Fores_Sess_Highlight_NYSess_EuropeSess" and that indicator will just plot those two sessions...then create another indicator and make false the other two sessions and name those sessions in the title.
If you do the above just SAVE the indicator after you change the title, then make changes for the other two sessions and SAVE it again...
doNYOpen = input(defval=true, type = bool, title="NY Open On")
doNYSession = input(defval=true, type = bool, title="NY Session On")
doNYClose = input(defval=true, type = bool, title="NY Close On")
doAussieOpen = input(defval=true, type = bool, title="Aussie Open On")
doAussieSession = input(defval=true, type = bool, title="Aussie Session On")
doAussieClose = input(defval=true, type = bool, title="Aussie Close On")
doAsiaOpen = input(defval=true, type = bool, title="Asia Open On")
doAsiaSession = input(defval=true, type = bool, title="Asia Session On")
doAsiaClose = input(defval=true, type = bool, title="Asia Close On")
doEurOpen = input(defval=true, type = bool, title="Euro Open On")
doEurSession = input(defval=true, type = bool, title="Euro Session On")
doEurClose = input(defval=true, type = bool, title="Euro Close On")
Let me know if you have any more questions.
As for FX Sessions, This is good but for some reason the Close "bar" will not draw when I use add this as a lower study, only the open and session. Note sure why since I see it shows on yours above.
Also, any way to replace Open & Close with just vertical lines?
Also, would love to see a version with Horizontal lines on chart, if you can figure it out. ;-)
BTW, I suggest ordering your sessions so NY is the 3rd one, to keep them in the order they actually occur. Just my 2 cents.
Regarding The order...I thought you were crazy...but since I'm using the Banking Hours or Active sessions for each major zone, your right. But shouldn't New York go last.
I've got Australia starting at 1700 Eastern TIme, Asia starting at 1900, Europe Starting at 0300, and US starting at 0800.
Do you disagree with those times? I do need to modify b/c Europe just had Day Light Savings.
What are the actual Banking Centers so I can look up exact times and see if Daylight Savings affected any others?
Australia - Sydney??? Asia - Tokyo ??? Europe - London??? U.S. - New York....
As for sessions, correct NY should be last.
Times are correct, except Wellington is 1700, Australia is 1900. Frankfurt is usually 0200 1 hour before Europe but right now looks like on same time
Here is a trading clock you can see all times (I believe factors in Daylight Savings times for each region, though not 100% sure)
To Fix if you primarily use 60 minute chart...in the code find the section that has
bgcolor(doNYOpen and timeinrange(period, "0800-0810") ? nySessionStart : na, transp=20)
And you would change the doNYOpen time to 0800-0900...same for doNYClose
I'm not a forex expert so let me know what cities that are listed on the link above to use for different Forex Sessions. And let me know which city goes with the main name for each session....Example Frankfurt = Europe.....???? = Asia etc.
Once I have that I will recode with correct sessions and names and I will put in correct order...I would wait until then to change the opening and closing times to a hour b/c the code I send you won't reflect that.
That said, how hard would it be to change this to draw actual vertical lines instead of the time range used for the OPEN or CLOSE?
As for the session times for the FOREX there are as follows (highlighting zones of greatest interest to set default ON):
Kiwi -> Wellington (New Zealand) = 1700-23:45 OPEN ONLY (Close often ignored. often considered with Sydney as part of Aussie session )
Aussie session -> Sydney (Australia) = 1900-0100 OPEN & CLOSE
Asian session -> Tokyo (Japan) = 1900-0200 OPEN ONLY (CLOSE often considered with Singapore as part of Asian session)
Asian Session -> Singapore/Hong Kong = 2100-0300 CLOSE ONLY (CLOSE often considered with Japan as part of Asian session)
Euro Session -> Frankfurt (Germany) = 0200-1000 OPEN ONLY (CLOSE often considered with London as part of Euro session)
Euro Session -> London (UK) = 0300-1100 OPEN & CLOSE
NY Session -> NY (US) = 0800-1700 OPEN & CLOSE
The open & Close will change based on daylight savings observances that vary from country to country.
So I would list then as Session (City), e.g. Aussie Session (Wellington), Aussie Session (Sydney), etc.
The 2nd paragraph is unclear so please explain in detail.
"That said, how hard would it be to change this to draw actual vertical lines instead of the time range used for the OPEN or CLOSE?"
I need more detail on that one...It does draw vertical lines at open and close, I can just use those or take them off. I f I use them you will have issue with changing to different timeframes as you are now. Currently we can't use an adjustable input where you can switch any sort of times in the Inputs window...you actually have to go in to the code.
I can just have the background color without Open and Close line but it's just as easy to change those to False so they won't automatically show up.
Tell me what I'm missing and I will let you if currently it can be done....
My thought was whether or not it is possible to use a single vertical line, like one produced by the Vertical Line drawing tool and use PINE to draw that. When you don it manually, you do not need to worry about the time range to make the line show up. No matter what time resolution you are on, a line is a line. And the manual drawing tool allows colour and line thickness choices.
BTW, I was just looking at the "Script Language Reference Manual" and I see function called hline. I think what I am thinking about is the equivalent but a vline function that takes date and time as inputs, where the date is optional and the vline is drawn at every time that matches. I think that would be the ideal.....
BTW, if a vline function is created, I have a few other uses for it too. I assumed it was there but since I do not , I see some other things I will not be able to have scripted, e.g. drawing a vertical line on my chart when say MACD crosses the 0 line.
P.S. Though I have done some coding in the past (20 years ago), and have been in IT for over 20 yrs, I am not a strong programmer. So I can decipher code to some extent.
I use hlines a lot....no vline option yet. Don't get discouraged and keep letting me know features you want...
The advantage I have is I know the long term vision of the company and the features they are currently working on. What most people don't know is the creators of TradingView have a long track record of developing High End Institutional Grade Trading Platforms. I can assure you that T.V. Will offer advanced capabilities never seen before in the industry. Pine Script is still in Beta and although today it lacks features we all want...It's already the most advanced custom coding language ever made available on a 100% pure web browser based platform. They are releasing one or two new capabilities at a time so any bugs can be fixed quickly. Just know the developers have already created award winning platforms with Institutional Grade Coding Capabilities. We will have all the bells and whistles in due time.
For the next few years every 3-6 months you'll see so many feature enhancements you'll look back and laugh at the time when we couldn't plot a simple vertical line. We will go from basic indicators to being able to code complete systems before you know it...
Keep the ideas and requests coming...
If time is way off as the video says the times are based on New York timezone. So if it was working before and not now you just have to go on to you chart, Right Click and select TIMEZONE and make sure it is set to EST. If you don't want your TimeZone on EST you have to manually adjust ALL of the times in the code. I'll help if you need help....
1. A Price Action Alarm? --- Be more Specific. If your speaking of placing lines on a chart and being alerted when price reaches those levels...the capability is not there yet....but it is coming. No Alarms can be set for any criteria. But the feature is coming.
2. PinBar Detector? - That is actually on my list of items to code. Currently it will have to be coloring the candlestick of price bar a certain color. By the way are you a Chris Capre Student? Or Where did you learn about PinBars?
3. Engulfed Candle? - I'm in the process of coding many candlestick patterns. That one is easy and I may have already coded that...if so I will post code to indicator below.