ChrisMoody

CM Time Based Vertical Lines

9764 obejrzeń
1558
9764 14
CM Time Based Lines

Requested by codetrader to Visually Show Day Change on Intra-Day Charts.


Custom Indicator: Ability To Plot Recurring Time Lines On Chart!

Example of Uses:
Plot Lines at Midnight to Show Daily Change.

Plot Lines at Opening of Different Sessions.

Plot Lines at Opening and Closing of Sessions.

Plot Lines Every 4 Hours (Forex) To See 4-Hour Price Action!

Ability to Change Times!

Ability to Plot Up To 6 Recurring Time Based Lines!

Plus Many Other Uses!

Ability To Turn On/Off Any of the 6 Customizable Lines in Inputs Tab!

Ability To Change Thickness of Lines to Cover Multiple Bars!
Usuń z Ulubionych Skryptów Dodaj do Ulubionych Skryptów
//Created By ChrisMoody on 9-14-2014 To plot Background Highlights for Recurring Times
//Requested by codetrader
study(title="CM_TimeBased_Vertical Lines", shorttitle="CM_TimeBased_Lines",overlay=true)
//timeinrange(res, sess) => time(res, sess) != 0

def = input(false, title="For Stocks Adjust Custom Session to 0930 or Close of Previous Days bar to see Day Change")
def2 = input(false, title="For Hourly Bars Adjust Start & End Times to 1 hour, 4 hour bars adjust to 4 hours, 5 Min Bars to 5 Minutes etc.")
def3 = input(false, title="-------------------------------------------------------------------")
sessNum = input(1, title="Plot Vertical Line On Chart-Custom 1", minval=1, maxval=1)
sh = input(true, title="Show Custom 1?")
First = input('0000-0100', type=session, title="1 - Midnight (Day Change)")
sh2 = input(false, title="Show Custom 2?")
sessNum2 = input(2, title="Plot Vertical Line On Chart-Custom 2", minval=2, maxval=2)
Second = input('0300-0400', type=session, title="Custom 2")
sh3 = input(false, title="Show Custom 3?")
sessNum3 = input(3, title="Plot Vertical Line On Chart-Custom 3", minval=3, maxval=3)
Third = input('0800-0900', type=session, title="Custom 3")
sh4 = input(false, title="Show Custom 4?")
sessNum4 = input(4, title="Plot Vertical Line On Chart-Custom 4", minval=4, maxval=4)
Fourth = input('0930-1030', type=session, title="Custom 4")
sh5 = input(false, title="Show Custom 5?")
sessNum5 = input(5, title="Plot Vertical Line On Chart-Custom 5", minval=5, maxval=5)
Fifth = input('1500-1600', type=session, title="Custom 5")
sh6 = input(false, title="Show Custom 5?")
sessNum6 = input(6, title="Plot Vertical Line On Chart-Custom 6", minval=6, maxval=6)
Sixth = input('1700-1800', type=session, title="Custom 6")

//sessToUse = sessNum == 1 ? First : sessNum == 2 ? Second : sessNum == 3 ? Third : sessNum == 4 ? Fourth : sessNum == 5 ? Fifth : sessNum == 6 ? Sixth : '0000-0000'
sessToUse = sessNum == 1 ? First : '0000-0000'
sessToUse2 = sessNum2 == 2 ? Second : '0000-0000'
sessToUse3 = sessNum3 == 3 ? Third : '0000-0000'
sessToUse4 = sessNum4 == 4 ? Fourth : '0000-0000'
sessToUse5 = sessNum5 == 5 ? Fifth : '0000-0000'
sessToUse6 = sessNum6 == 6 ? Sixth : '0000-0000'

//Custom Session 1 Rules
bartimeSess = (sessNum == 0 ? time('D') : time('D', sessToUse))
bgPlot = (sessNum == 0 ? time(period) : time(period, sessToUse)) 
//Custom Session 2 Rules
bartimeSess2 = (sessNum2 == 0 ? time('D') : time('D', sessToUse2))
bgPlot2 = (sessNum2 == 0 ? time(period) : time(period, sessToUse2)) 
//Custom Session 3 Rules
bartimeSess3 = (sessNum3 == 0 ? time('D') : time('D', sessToUse3))
bgPlot3 = (sessNum3 == 0 ? time(period) : time(period, sessToUse3))
//Custom Session 4 Rules
bartimeSess4 = (sessNum4 == 0 ? time('D') : time('D', sessToUse4))
bgPlot4 = (sessNum4 == 0 ? time(period) : time(period, sessToUse4)) 
//Custom Session 5 Rules
bartimeSess5 = (sessNum5 == 0 ? time('D') : time('D', sessToUse5))
bgPlot5 = (sessNum5 == 0 ? time(period) : time(period, sessToUse5))
//Custom Session 6 Rules
bartimeSess6 = (sessNum6 == 0 ? time('D') : time('D', sessToUse6))
bgPlot6 = (sessNum6 == 0 ? time(period) : time(period, sessToUse6))

bgcolor(sh and bgPlot > 0 ? yellow : na, transp=40)
bgcolor(sh2 and bgPlot2 > 0 ? orange : na, transp=40)
bgcolor(sh3 and bgPlot3 > 0 ? aqua : na, transp=40)
bgcolor(sh4 and bgPlot4 > 0 ? fuchsia : na, transp=40)
bgcolor(sh5 and bgPlot5 > 0 ? maroon : na, transp=40)
bgcolor(sh6 and bgPlot6 > 0 ? lime : na, transp=40)
I'm not quite sure what Im looking at but I want a vertical line to always be placed at the 940am est mark. Does on of these codes accomplish that?
Odpowiedź
How do you remove the recurring timelines on the chart?
Odpowiedź
NCR321 NCR321
@NCR321, I figured it out. Sorry! I'm new to tradingview.
Odpowiedź
Hi Chris .. great indicator .. having a problem with it skipping long periods.
All my times are laid out sequentially starting after midnight.
It plots perfectly for 4 days .. then it completely skips 2 days.
Same results regardless of timescale or currency.
Any suggestions to fix this?
Thanks
Odpowiedź
How do I change the timeline from showing 00:00 to 18:00? I want it to show my days starting at 18:00.. Is that possible?
+1 Odpowiedź
It doesn't work with weekends, why? How to fix that? The only way is UNIX time?
+5 Odpowiedź
Hello, could I have a question with you?
I want to print a vertical line on specific dates;
01/15/2018
02/19/2018
.
.
.
08/20/2018
I can not do it, would that be possible?
Thank you very much!!!
+2 Odpowiedź
He man I made this code. was my first code you have to look at it in a 5 minute chart else does not work. can you improve it?
//@version=3
study(title="buybuypig timming when things are happening")

//get the last smaller price to set the mtiplier for the scale
adjsc_temp = close<open?close:open//adjusting_scale
adjsc = adjsc_temp<.5?.5:adjsc_temp
//function
showmetime(hours,minutes)=>hset=hour==hours,mset=minute==minutes,

//default is 14 hours and 30 minutes but it can be adjusted
hourtoadd1 = input(14, title="Hour A")
minutetoadd1 = input(30, title="Minute A")
// //default for the minutes B
minutetoadd2 = input(45, title="Minute B")


=showmetime(hourtoadd1,minutetoadd1)
plot(hset?.5*adjsc:0)
plotchar(hset?minute==minutetoadd1?true:0:0, text='H A', location=location.belowbar, char='A')
plot(hset?mset?.7*adjsc:0:0)

msetb=minute==minutetoadd2
plot(msetb?.3*adjsc:0)

//lets you konw that the hour is next
earlywarninga=hour==hourtoadd1-1
plot(earlywarninga?.2*adjsc:0)
earlyminituea=minute==45
//plot(earlywarninga?earlyminituea?.5*adjsc:0:0)
plotchar(earlywarninga?earlyminituea?true:0:0, location=location.top, text="\n\n\n\n-1")
///////////
//lets you konw that the hour is next
earlywarning2=hour==hourtoadd1-2
plot(earlywarning2?.1*adjsc:0)

earlywarning3=hour==hourtoadd1-3
plot(earlywarning3?-.1*adjsc:0)

earlywarning4=hour==hourtoadd1-4
plot(earlywarning4?-.2*adjsc:0)

/////////
//lets you konw next after
earlywarning5=hour==hourtoadd1+1
plot(earlywarning5?.2*adjsc:0)

earlywarning6=hour==hourtoadd1+2
plot(earlywarning6?.1*adjsc:0)

earlywarning7=hour==hourtoadd1+3
plot(earlywarning7?-.1*adjsc:0)

earlywarning8=hour==hourtoadd1+4
plot(earlywarning8?-.2*adjsc:0)
///////////////////////////////

earlywarningc=hour==hourtoadd1-7
earlyminituec=minute==45
plot(earlywarningc?earlyminituec?.5*adjsc:0:0)
plotchar(earlywarningc?earlyminituec?true:0:0, location=location.top, text="\n\n\n\n-7")

earlywarningd=hour==hourtoadd1-14
earlyminitued=minute==45
plot(earlywarningd?earlyminitued?.5*adjsc:0:0)
plotchar(earlywarningd?earlyminitued?true:0:0, location=location.top, text="-\n\n\n\n-14")

earlywarninge=hour==hourtoadd1+7
earlyminituee=minute==45
plot(earlywarninge?earlyminituee?.5*adjsc:0:0)
plotchar(earlywarninge?earlyminituee?true:0:0, location=location.top, text="\n\n\n\n-17")
/////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////


Odpowiedź
Hey Chris, love your work man - fantastic! I had a quick question about this indicator/line add on.. How do I set it for a certain number of periods, say 9 days for example? Thoughts?
+2 Odpowiedź
Thanks Chris, if it's not too much to ask, how might i code a script to draw lines periodically in the future, for example, 5 bars from a swing high, or 20 bars, or both a line 5 bars from a certain bar, and another one 20 bars in the future? Must I input a bar number either hard coded in the script or could it be as input when the script is first run, and have the vertical lines then overlaid as future points in time?
Thank you in advance...
+2 Odpowiedź
Strona główna Skaner akcji Skaner Forex Skaner Krypto Kalendarz ekonomiczny Jak to działa Funkcje wykresów Cena Dobre Praktyki Moderatorzy Rozwiązania internetowe i brokerskie Widżety Wykresy Uzyskaj Pomoc Zgłoś dodatkową funkcjonalność Blog i wiadomości Często zadawane pytania Wiki Twitter
Profil Ustawienia profilu Konto i płatności Monety TradingView Wiadomości do działu obsługi Uzyskaj Pomoc Opublikowane Pomysły Obserwujący Lista obserwowanych Wiadomość prywatna Czat Wyloguj