Sessions Indicator from tradingview by Aurocks_AIF

Forums ProRealTime English forum ProBuilder support Sessions Indicator from tradingview by Aurocks_AIF

Viewing 2 posts - 1 through 2 (of 2 total)
  • #189222

    Good Morning,

    I am kindly request an assistance to convert the session indicator, one is able to select the specific session the want to look at as well as adjust market open time the want.

    CODE:

    //@version=4

    study(“Sessions”, overlay=true)

    bgColor = input(title=”Activate High/Low View”, type=input.bool, defval=false)

    LondonColor = color.green
    NYColor = color.red
    AsiaColor = color.yellow
    SydneyColor = color.navy

    ///Sessions

    res = input(title=”Resolution”, type=input.resolution, defval=”D”, options=[“D”,”W”,”M”])
    london = input(title=”London Session”, type=input.session, defval=”0300-1200:1234567″)
    ny = input(title=”New York Session”, type=input.session, defval=”0800-1700:1234567″)
    tokyo = input(title=”Tokyo Session”, type=input.session, defval=”2000-0400:1234567″)
    sydney = input(title=”Sydney Session”, type=input.session, defval=”1700-0200:1234567″)

    //Bars

    is_newbar(sess) =>
    t = time(res, sess)
    na(t[1]) and not na(t) or t[1] < t

    is_session(sess) =>
    not na(time(timeframe.period, sess))

    //London

    London = input(title=”London Session”, type=input.bool, defval=true)

    londonNewbar = is_newbar(london)
    londonSession = is_session(london)

    float londonLow = na
    londonLow := if londonSession
    if londonNewbar
    low
    else
    min(londonLow[1],low)
    else
    londonLow[1]

    float londonHigh = na
    londonHigh := if londonSession
    if londonNewbar
    high
    else
    max(londonHigh[1],high)
    else
    londonHigh[1]

    plotLL = plot(londonLow, transp = 100)
    plotLH = plot(londonHigh, transp = 100)
    fill(plotLL, plotLH, color = londonSession and London and bgColor ? LondonColor : na)

    bgcolor(londonSession and London and not bgColor ? LondonColor : na)

     

    //New York

    NY = input(title=”New York Session”, type=input.bool, defval=true)

    nyNewbar = is_newbar(ny)
    nySession = is_session(ny)

    float nyLow = na
    nyLow := if nySession
    if nyNewbar
    low
    else
    min(nyLow[1],low)
    else
    nyLow[1]

    float nyHigh = na
    nyHigh := if nySession
    if nyNewbar
    high
    else
    max(nyHigh[1],high)
    else
    nyHigh[1]

    plotNYL = plot(nyLow, transp = 100)
    plotNYH = plot(nyHigh, transp = 100)
    fill(plotNYL, plotNYH, color = nySession and NY and bgColor ? color.red : na)

    bgcolor(nySession and NY and not bgColor ? NYColor : na)

    //Tokyo

    Tokyo = input(title=”Tokyo Session”, type=input.bool, defval=true)

    tokyoNewbar = is_newbar(tokyo)
    tokyoSession = is_session(tokyo)

    float tokyoLow = na
    tokyoLow := if tokyoSession
    if tokyoNewbar
    low
    else
    min(tokyoLow[1],low)
    else
    tokyoLow[1]

    float tokyoHigh = na
    tokyoHigh := if tokyoSession
    if tokyoNewbar
    high
    else
    max(tokyoHigh[1],high)
    else
    tokyoHigh[1]

    plotTL = plot(tokyoLow, transp = 100)
    plotTH = plot(tokyoHigh, transp = 100)
    fill(plotTL, plotTH, color = tokyoSession and Tokyo and bgColor ? color.yellow : na)

    bgcolor(tokyoSession and Tokyo and not bgColor ? AsiaColor : na)

     

    //Sydney

    Sydney = input(title=”Sydney Session”, type=input.bool, defval=false)

    sydneyNewbar = is_newbar(sydney)
    sydneySession = is_session(sydney)

    float sydneyLow = na
    sydneyLow := if sydneySession
    if sydneyNewbar
    low
    else
    min(sydneyLow[1],low)
    else
    sydneyLow[1]

    float sydneyHigh = na
    sydneyHigh := if sydneySession
    if sydneyNewbar
    high
    else
    max(sydneyHigh[1],high)
    else
    sydneyHigh[1]

    plotSL = plot(sydneyLow, transp = 100)
    plotSH = plot(sydneyHigh, transp = 100)
    fill(plotSL, plotSH, color = sydneySession and Sydney and bgColor ? color.navy : na)

    bgcolor(sydneySession and Sydney and not bgColor ? SydneyColor : na)

    #189241

    @tjeremiah

    Do not embed files or documents in your post, as this slows down the loading of the pages. Use the Select File button only, instead, to attach files:

    • ITF for ProRealTime coded files to be imported/exported
    • TXT for unformatted text or code
    • PDF for formatted text
    • JPG/PNG for images.

    Thank you 🙂

     

Viewing 2 posts - 1 through 2 (of 2 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login