England and United States Session Indicator

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #193419 quote
    1Randy
    Member
    New

    I have searched for a session indicator, but not found one.

    What I would appreciate is a box surrounding the session for England and United States session. I would also like the box to print the pip spread for each session. I am not that good at the coding just learning to code. Plan to use for back testing of strategies.

     

    Any help would be greatly appreciated.

    #193635 quote
    robertogozzi
    Moderator
    Master

    I used the background colour to identify both sessions, as rectangles would move as new highs and lows are set.

    DEFPARAM DrawOnLastBarOnly = true
    ONCE UKstart  = 090000
    ONCE UKend    = 180000
    ONCE USstart  = 150000
    ONCE USend    = 230000
    ONCE UKhh     = 0
    ONCE UKll     = 9999999
    ONCE UShh     = 0
    ONCE USll     = 9999999
    TimeRef       = OpenTime
    IF TimeRef = 000000 OR ((TimeRef > 000000) AND (TimeRef < TimeRef[1])) THEN
       UKhh       = 0
       UKll       = 9999999
       UShh       = 0
       USll       = 9999999
    ENDIF
    //
    UKsession     = TimeRef >= UKstart AND TimeRef <= UKend
    USsession     = TimeRef >= USstart AND TimeRef <= USend
    //
    backgroundcolor(255,255,255,255)                          //WHITE background (default)
    IF TimeRef >= UKstart AND TimeRef < USstart AND TimeRef <= UKend THEN
       backgroundcolor(176,226,255,80)                        //CYAN  background (overlapping sessions)
    ELSIF TimeRef >= UKstart AND TimeRef <= UKend THEN
       backgroundcolor(0,128,0,40)                            //GREEN background (UK session)
    ELSIF TimeRef >= USstart AND TimeRef > UKend AND TimeRef <= USend THEN
       backgroundcolor(255,187,255,40)                        //PINK  background (US session)
    ENDIF
    //
    IF UKsession THEN
       UKhh  = max(UKhh,high)
       UKll  = min(UKll,low)
       UKgap = UKhh - UKll
    ENDIF
    IF USsession THEN
       UShh  = max(UShh,high)
       USll  = min(USll,low)
       USgap = UShh - USll
    ENDIF
    //
    Offset   = max(UKhh,UShh)
    Rng      = average[100,0](range)
    DrawText("UK #UKgap#",BarIndex,Offset + rng)     coloured(0,0,0,255)
    DrawText("US #USgap#",BarIndex,Offset + rng * 2) coloured(0,0,0,255)
    RETURN
    

    Most used colours can be found at http://cloford.com/resources/colours/500col.htm.

    The 4th parameter used with colours in PRT is usually named Alpha or Transparency, it’s optional and can range from 0 (invisible)  to 255 (fully visible),

    #193638 quote
    robertogozzi
    Moderator
    Master

    You may want to change times to make them suit your needs.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

England and United States Session Indicator


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
1Randy @1randy Member
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by robertogozzi
3 years, 8 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 05/19/2022
Status: Active
Attachments: 2 files
Logo Logo
Loading...