ChrisMoody

CM Time Based Vertical Lines

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!

Mã nguồn mở

Với tinh thần TradingView, tác giả của tập lệnh này đã xuất bản nó dưới dạng mã nguồn mở, vì vậy các nhà giao dịch có thể hiểu và xác minh nó. Chúc mừng tác giả! Bạn có thể sử dụng mã này miễn phí, nhưng việc sử dụng lại mã này trong một ấn phẩm chịu sự điều chỉnh của Nội quy nội bộ. Bạn có thể yêu thích nó để sử dụng nó trên biểu đồ.

Thông báo miễn trừ trách nhiệm

Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.

Bạn muốn sử dụng tập lệnh này trên biểu đồ?
//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)