Sessions London NewYork

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #245361 quote
    Schizophunk
    Participant
    New

    Hi,

    Just want to share with you an indicator to see the sessions of Londes and New York in your intraday chart. If someone has similar or want to improve it, please contribute by answering this post.

    // Indicador para marcar las sesiones de Londres y Nueva York en ProRealTime
    // Se ajusta automáticamente al horario del sistema
    
    timeLocal = BarIndex
    
    // Marcar apertura de Londres (11:00 horario local)
    iF Hour = 11 AND Minute = 0 THEN
    DRAWLINE(timeLocal, Lowest[10], timeLocal, Highest[10]) COLOURED(255, 255, 0)
    DRAWTEXT("Londres Open", timeLocal, Highest[10] + (Highest[10] - Lowest[10]) * 0.02) COLOURED(255, 255, 0)
    ENDIF
    
    // Marcar cierre de Londres (17:00 horario local)
    iF Hour = 19 AND Minute = 30 THEN
    DRAWLINE(timeLocal, Lowest[10], timeLocal, Highest[10]) COLOURED(255, 255, 0)
    DRAWTEXT("Londres Close", timeLocal, Highest[10] + (Highest[10] - Lowest[10]) * 0.02) COLOURED(255, 255, 0)
    ENDIF
    
    // Marcar apertura de Nueva York (16:30 horario local)
    iF Hour = 16 AND Minute = 30 THEN
    DRAWLINE(timeLocal, Lowest[10], timeLocal, Highest[10]) COLOURED(0, 255, 255)
    DRAWTEXT("New York Open", timeLocal, Highest[10] + (Highest[10] - Lowest[10]) * 0.02) COLOURED(0, 255, 255)
    ENDIF
    
    // Marcar cierre de Nueva York (22:00 horario local)
    iF Hour = 23 AND Minute = 0 THEN
    DRAWLINE(timeLocal, Lowest[10], timeLocal, Highest[10]) COLOURED(0, 255, 255)
    DRAWTEXT("New York Close", timeLocal, Highest[10] + (Highest[10] - Lowest[10]) * 0.02) COLOURED(0, 255, 255)
    ENDIF
    
    RETURN 0
    
    Iván González and gp38super thanked this post
    #245380 quote
    Iván González
    Moderator
    Master

    Thank you for your contribution!
    Just in case it’s useful, I’m sharing this code I published a few weeks ago: https://www.prorealcode.com/prorealtime-indicators/ict-killzones-and-pivots/

    Schizophunk and gp38super thanked this post
    #245381 quote
    Schizophunk
    Participant
    New

    Hi Ivan,

    Amazing work. Really helpful.

    Thank you,

    #246046 quote
    Schizophunk
    Participant
    New

    Hi,

    I did this indicator from the one provided by @toniyecla.

    // Author: toniyecla - contact@rescommunesomnium.com
    // Modified: Juan Diaz Maldonado
    // Tokio, London, and Newyork market session adjusted to summer time changes if your PRT is set up in Madrid
    
    DEFPARAM CALCULATEONLASTBARS  = 10000
    DEFPARAM DRAWONLASTBARONLY = True
    ONCE Tokio = 1
    ONCE London = 1
    ONCE NewYork = 1
    ONCE LunchTime = 0
    ONCE Opacity = 60
    
    // === LONDON (LSE) (Time changes dont affect) ===
    ONCE londonstart      = 090000
    ONCE londonend        = 173000
    ONCE londonlunchstart = 130000
    ONCE londonlunchsend  = 140000
    
    // === SUMMER TIME IN SPAIN ===
    esDomingo = dayofweek = 0
    esMarzo = month = 3
    esOctubre = month = 10
    esNoviembre = month = 11
    diaDelMes = day
    ultimoDiaDelMes = 31
    
    // Last Sunday of March (Summer time starts)
    esUltimoDomingoMarzo = esDomingo AND esMarzo AND (ultimoDiaDelMes - diaDelMes) < 7
    
    // Last week of October (Summer time ends)
    esUltimaSemanaOctubre = (esOctubre AND esDomingo AND (diaDelMes + 4) < 31) OR (esOctubre AND dayofweek = 1 AND (diaDelMes + 3) < 31) OR (esOctubre AND dayofweek = 2 AND (diaDelMes + 2) < 31) OR (esOctubre AND dayofweek = 3 AND (diaDelMes + 1) < 31) OR (esOctubre AND dayofweek = 4 AND diaDelMes < 31) OR (esOctubre AND dayofweek = 5 AND (ultimoDiaDelMes - diaDelMes) < 7)
    
    // General condition for summer time (only affects Tokio)
    esHorarioVerano = esUltimoDomingoMarzo OR (month > 3 AND month < 10) OR (esOctubre AND NOT esUltimaSemanaOctubre)
    
    // === TOKYO (TSE) ===
    if esHorarioVerano then
    ONCE AsianStart       = 020000
    ONCE AsianEnd         = 080000
    ONCE AsianLunchStart  = 043000
    ONCE AsianLunchEnd    = 053000
    else
    ONCE AsianStart       = 010000
    ONCE AsianEnd         = 070000
    ONCE AsianLunchStart  = 033000
    ONCE AsianLunchEnd    = 043000
    endif
    
    // === OVERLAP CEST vs ET timezones (Spain vs NYSE) in march and october ===
    // Desajuste de marzo
    // Segundo domingo de marzo
    esSegundoDomingoMarzo = esMarzo AND esDomingo AND diaDelMes >= 8 AND diaDelMes <= 14
    
    // Último domingo de marzo
    esUltimoDomingoMarzo = esMarzo AND (diaDelMes >= (ultimoDiaDelMes - 6) AND diaDelMes <= ultimoDiaDelMes) AND dayofweek = 0
    
    // Desajuste marzo: entre el segundo domingo de marzo y el último domingo de marzo
    desajusteMarzo = esMarzo AND diaDelMes >= 8 AND diaDelMes <= ultimoDiaDelMes AND esSegundoDomingoMarzo AND NOT esUltimoDomingoMarzo
    
    // Desajuste de octubre-noviembre
    // Último domingo de octubre (determinamos si estamos antes del primer domingo de noviembre)
    esUltimoDomingoOctubre = esOctubre AND (diaDelMes >= (ultimoDiaDelMes - 6) AND diaDelMes <= ultimoDiaDelMes) AND dayofweek = 0
    esPrimerDomingoNoviembre = esNoviembre AND (diaDelMes <= 7 AND dayofweek = 0)
    
    // Desajuste octubre-noviembre: entre el último domingo de octubre y el primer domingo de noviembre
    desajusteOctubreNoviembre = (esOctubre AND diaDelMes >= 25) OR (esNoviembre AND diaDelMes <= 7)
    
    // Condición final de desajuste horario (marzo o octubre-noviembre)
    desajusteHorarioNYSE = (desajusteMarzo AND NOT desajusteOctubreNoviembre)
    //OR (NOT desajusteMarzo AND desajusteOctubreNoviembre)
    
    // === NEW YORK (NYSE) ===
    
    if desajusteHorarioNYSE then
    ONCE USAStart       = 143000
    ONCE USAEnd         = 210000
    ONCE USALunchStart  = 170000
    ONCE USALunchEnd    = 180000
    else
    ONCE USAStart       = 153000
    ONCE USAEnd         = 220000
    ONCE USALunchStart  = 180000
    ONCE USALunchEnd    = 190000
    endif
    
    // === SOLAPAMIENTOS ===
    // NY + Londres
    if NewYork AND london AND (time > USAStart AND time <= londonend) then
    backgroundcolor(0, 90, 255, Opacity)
    endif
    
    // SESIONES INDIVIDUALES (solo si no hay solapamiento)
    if tokio AND (time > AsianStart AND time <= AsianEnd) then
    backgroundcolor("red", Opacity)
    endif
    
    if london AND NOT (NewYork AND (time > USAStart AND time <= londonend)) then
    if (time > londonstart AND time <= londonend) then
    backgroundcolor("cyan", Opacity)
    endif
    endif
    
    if NewYork AND NOT (london AND (time > USAStart AND time <= londonend)) then
    if (time > USAStart AND time <= USAEnd) then
    backgroundcolor("blue", Opacity)
    endif
    endif
    
    // Lunch Time (Only Tokyo is official - London and NY are estimated)
    if LunchTime then
    if time > AsianLunchStart and time <= AsianLunchEnd then
    backgroundcolor(0, 0, 0, 0)
    endif
    if time > londonlunchstart and time <= londonlunchsend then
    backgroundcolor(0, 0, 0, 0)
    endif
    if time > USALunchStart and time <= USALunchEnd then
    backgroundcolor(0, 0, 0, 0)
    endif
    endif
    
    RETURN

     

    I considered the time zone adjustments due to summer time changes.

    However, in lines 68 to 70, when I discomment “//OR (NOT desajusteMarzo AND desajusteOctubreNoviembre)”,  the first condition “desajusteHorarioNYSE = (desajusteMarzo AND NOT desajusteOctubreNoviembre) ” doesnt apply. It looks there is an overlaping but I can not find it.

    // Condición final de desajuste horario (marzo o octubre-noviembre) 
    desajusteHorarioNYSE = (desajusteMarzo AND NOT desajusteOctubreNoviembre) 
    //OR (NOT desajusteMarzo AND desajusteOctubreNoviembre)

    May someone help me directly with the code? I will appreciate also if someone gives ideas, tips, resources for codes depuration.

    Thank you very much to all the comunity ProRealCode.

    #246070 quote
    Schizophunk
    Participant
    New

    Hi everyone,

    Just wanted to share with you the debugged code. I also imporved the code structure, so it is more understable and easy to adapt to other timezones.

    Hope it is helpful for some. As this forum has provided me tons of knowlegde, i just want to give back what i consider it can be helpful.

    DEFPARAM CALCULATEONLASTBARS  = 40000
    DEFPARAM DRAWONLASTBARONLY = True
    ONCE London = 1
    ONCE Tokio = 1
    ONCE NewYork = 1
    ONCE LunchTime = 0
    ONCE Opacity = 60
    
    // Variables-Constants
    esDomingo = (DayOfWeek = 0)
    esMarzo = (Month = 3)
    esOctubre = (Month = 10)
    esNoviembre = (Month = 11)
    diaDelMes = Day
    ultimoDiaDelMes = 31
    
    // Summer time in spain is from last sunday march to last sunday october
    esUltimoDomingoMarzo = esMarzo AND esDomingo AND (ultimoDiaDelMes - diaDelMes) < 7
    esUltimoDomingoOctubre = esOctubre AND esDomingo AND (ultimoDiaDelMes - diaDelMes) < 7
    
    // Summer time in USA is from second sunday march to first sunday november
    esSegundoDomingoMarzo = esMarzo AND esDomingo AND diaDelMes >= 8 AND diaDelMes <= 14
    esPrimerDomingoNoviembre = esNoviembre AND diaDelMes <= 7 AND dayofweek = 0
    
    // Spain summer time detection
    ONCE horarioVerano = 0
    IF esUltimoDomingoMarzo THEN
    horarioVerano = 1
    ELSIF  esUltimoDomingoOctubre then
    horarioVerano = 0
    ENDIF
    
    // Spain-USA march deadjustment detection
    ONCE desajusteMarzo = 0
    if esSegundoDomingoMarzo THEN
    desajusteMarzo = 1
    ELSIF esUltimoDomingoMarzo THEN
    desajusteMarzo = 0
    ENDIF
    
    // Spain-USA October-November deadjustment detection
    ONCE desajusteoctubre = 0
    if esUltimoDomingoOctubre THEN
    desajusteoctubre = 1
    ELSIF esPrimerDomingoNoviembre THEN
    desajusteoctubre = 0
    ENDIF
    
    //// Represent in chat the affected time zones where to apply adjustments
    //if horarioVerano = 1 THEN
    //BACKGROUNDCOLOR ("white", Opacity)
    //ENDIF
    
    //if desajusteMarzo = 1 THEN
    //BACKGROUNDCOLOR ("white", Opacity)
    //ENDIF
    
    //if desajusteoctubre = 1 THEN
    //BACKGROUNDCOLOR ("white", Opacity)
    //ENDIF
    
    // === LONDON (LSE) ===
    londonstart        = 090000
    londonend          = 173000
    londonlunchstart   = 130000
    londonlunchsend    = 140000
    
    // === TOKYO (TSE) ===
    IF horarioVerano = 1 THEN
    AsianStart      = 020000
    AsianEnd        = 080000
    AsianLunchStart = 043000
    AsianLunchEnd   = 053000
    ELSE
    AsianStart      = 010000
    AsianEnd        = 070000
    AsianLunchStart = 033000
    AsianLunchEnd   = 043000
    ENDIF
    
    // === NEW YORK (NYSE) ===
    if desajusteMarzo = 1 OR desajusteoctubre = 1 then
    USAStart        = 143000
    USAEnd          = 210000
    USALunchStart   = 170000
    USALunchEnd     = 180000
    else
    USAStart        = 153000
    USAEnd          = 220000
    USALunchStart   = 180000
    USALunchEnd     = 190000
    endif
    
    // === SESSIONS ON CHART ===
    // First we will represent Londo-NewYork session overlap in a different colour. Then the rest
    if NewYork AND London AND (time >= USAStart AND time <= londonend) then
    backgroundcolor(0, 90, 255, Opacity)
    
    else
    if Tokio AND (time > AsianStart AND time <= AsianEnd) then
    backgroundcolor(255, 0, 0, Opacity)
    endif
    
    if London AND (time > londonstart AND time <= londonend) then
    backgroundcolor(0, 255, 255, Opacity)
    endif
    
    if NewYork AND (time > USAStart AND time <= USAEnd) then
    backgroundcolor(0, 0, 255, Opacity)
    endif
    endif
    
    // Lunch Time Handling. Only Japan is official, the others are estimations
    if LunchTime then
    if (time > AsianLunchStart and time <= AsianLunchEnd) or (time > londonlunchstart and time <= londonlunchsend) or (time > USALunchStart and time <= USALunchEnd) then
    backgroundcolor(0, 0, 0, 0)
    endif
    endif
    
    RETURN

    Have a nice day.

    Iván González thanked this post
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

Sessions London NewYork


ProBuilder: Indicators & Custom Tools

New Reply
Author
Summary

This topic contains 4 replies,
has 2 voices, and was last updated by Schizophunk
9 months, 3 weeks ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 03/27/2025
Status: Active
Attachments: 4 files
Logo Logo
Loading...