Plot Open Of Day

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #210051 quote
    gadetrading
    Participant
    New

    Hello,
    I have borrowed some code from another post (https://www.prorealcode.com/topic/high-low-close-yesterday-premarket/)
    I use only the part to plot yesterdays high, low and close and have added text to describe the levels.

    My question is, can someone add the code to plot the of the open of the current day? I want the segment to look exactly like the others, with the segment ending at the current bar.

    Help is very appreciated.

    DEFPARAM DrawOnLastBarOnly = true
    ONCE PrevHH = high
    ONCE PrevLL = low
    ONCE PrecCL = close
    ONCE HH     = high
    ONCE LL     = low
    ONCE CL     = close
    If OpenTime = 000000 OR (OpenTime >= 000000 AND OpenTime < OpenTime[1])THEN
    PrevHH = HH
    PrevLL = LL
    PrevCL = CL//close[1]
    LL     = low
    HH     = high
    CL     = close
    BarID  = BarIndex
    ENDIF
    IF (OpenTime >= 093000) AND (OpenTime <= 161500) THEN
    HH = max(HH,high)
    LL = min(LL,low)
    CL = close
    ENDIF
    DrawText("HoY",barindex-2,PrevHH+1.5*pipsize,SansSerif,Bold) coloured(0,128,0,75)
    DrawText("LoY",barindex-2,PrevLL+1.5*pipsize,SansSerif,Bold) coloured(0,0,255,75)
    DrawText("CoY",barindex-2,PrevCL+1.5*pipsize,SansSerif,Bold) coloured(255,0,0,75)
    //
    DrawSegment(BarID,PrevHH,BarIndex,PrevHH) coloured(0,128,0,75)   style(dottedline)       //Green
    DrawSegment(BarID,PrevLL,BarIndex,PrevLL) coloured(0,0,255,75)   style(dottedline)       //Blue
    DrawSegment(BarID,PrevCL,BarIndex,PrevCL) coloured(255,0,0,75)   style(dottedline)       //Red
    //
    //DrawSegment(pmBarID,pmHH,BarIndex,pmHH)   coloured(0,178,238,255) style(dottedline,3) //Cyan
    //DrawSegment(pmBarID,pmLL,BarIndex,pmLL)   coloured(0,178,238,255) style(dottedline,3) //Cyan
    RETURN
    
    Screenshot.png Screenshot.png
    #210067 quote
    gadetrading
    Participant
    New

    As a last request, this is only if possible and straightforward to do: plotting the high, low and open of the last week like the segments in the screenshot.
    Thank you.

    #210073 quote
    gadetrading
    Participant
    New

    As a last request, this is only if possible and straightforward to do: plotting the high, low and open of the last week like the segments in the screenshot.

    Thank you.

    Sorry, I meant to say high and low of last week and open of the current week.

    #210080 quote
    robertogozzi
    Moderator
    Master

    This is the one with the addition of today’s OPEN:

    DEFPARAM DrawOnLastBarOnly = true
    ONCE PrevHH = high
    ONCE PrevLL = low
    ONCE PrecCL = close
    ONCE HH     = high
    ONCE LL     = low
    ONCE CL     = close
    If OpenTime = 000000 OR (OpenTime >= 000000 AND OpenTime < OpenTime[1])THEN
    PrevHH = HH
    PrevLL = LL
    PrevCL = CL//close[1]
    LL     = low
    HH     = high
    CL     = close
    OP     = open
    BarID  = BarIndex
    ENDIF
    IF (OpenTime >= 093000) AND (OpenTime <= 161500) THEN
    HH = max(HH,high)
    LL = min(LL,low)
    CL = close
    ENDIF
    DrawText("Open",barindex-2,OP+1.5*pipsize,    SansSerif,Bold) coloured("Fuchsia")
    DrawText("HoY", barindex-2,PrevHH+1.5*pipsize,SansSerif,Bold) coloured(0,128,0,75)
    DrawText("LoY", barindex-2,PrevLL+1.5*pipsize,SansSerif,Bold) coloured(0,0,255,75)
    DrawText("CoY", barindex-2,PrevCL+1.5*pipsize,SansSerif,Bold) coloured(255,0,0,75)
    //
    DrawSegment(BarID,OP,    BarIndex,OP)     coloured("Fuchsia")    style(dottedline)       //Fuchsia
    DrawSegment(BarID,PrevHH,BarIndex,PrevHH) coloured(0,128,0,75)   style(dottedline)       //Green
    DrawSegment(BarID,PrevLL,BarIndex,PrevLL) coloured(0,0,255,75)   style(dottedline)       //Blue
    DrawSegment(BarID,PrevCL,BarIndex,PrevCL) coloured(255,0,0,75)   style(dottedline)       //Red
    //
    //DrawSegment(pmBarID,pmHH,BarIndex,pmHH)   coloured(0,178,238,255) style(dottedline,3) //Cyan
    //DrawSegment(pmBarID,pmLL,BarIndex,pmLL)   coloured(0,178,238,255) style(dottedline,3) //Cyan
    RETURN
    #210083 quote
    robertogozzi
    Moderator
    Master

    This is the one with the weekly data, just add both on your chart:

    DEFPARAM DrawOnLastBarOnly = true
    ONCE PrevHH = high
    ONCE PrevLL = low
    ONCE HH     = high
    ONCE LL     = low
    If OpenDayOfWeek < OpenDayOfweek[1] THEN
    PrevHH = HH
    PrevLL = LL
    LL     = low
    HH     = high
    OP     = open
    BarID  = BarIndex
    ENDIF
    HH = max(HH,high)
    LL = min(LL,low)
    CL = close
    DrawText("Open",barindex-2,OP+1.5*pipsize,    SansSerif,Bold) coloured("Fuchsia")
    DrawText("HoY", barindex-2,PrevHH+1.5*pipsize,SansSerif,Bold) coloured(0,128,0,75)
    DrawText("LoY", barindex-2,PrevLL+1.5*pipsize,SansSerif,Bold) coloured(0,0,255,75)
    //
    DrawSegment(BarID,OP,    BarIndex,OP)     coloured("Fuchsia")    style(dottedline)       //Fuchsia
    DrawSegment(BarID,PrevHH,BarIndex,PrevHH) coloured(0,128,0,75)   style(dottedline)       //Green
    DrawSegment(BarID,PrevLL,BarIndex,PrevLL) coloured(0,0,255,75)   style(dottedline)       //Blue
    RETURN
    gadetrading thanked this post
    #210092 quote
    gadetrading
    Participant
    New

    Thank you very much @robertogozzi
    Is it possible to make the weekly line segments drawn at the current day only? Just like the other lines.
    See screenshot

    Weekly.png Weekly.png
    #210285 quote
    robertogozzi
    Moderator
    Master

    There you go:

    DEFPARAM DrawOnLastBarOnly = true
    ONCE PrevHH = high
    ONCE PrevLL = low
    ONCE HH     = high
    ONCE LL     = low
    If OpenDayOfWeek < OpenDayOfweek[1] THEN
       PrevHH = HH
       PrevLL = LL
       LL     = low
       HH     = high
       OP     = open
       BarID  = BarIndex
    ELSE
       If OpenTime = 000000 OR (OpenTime >= 000000 AND OpenTime < OpenTime[1])THEN
          BarID  = BarIndex
       ENDIF
    ENDIF
    HH = max(HH,high)
    LL = min(LL,low)
    CL = close
    DrawText("Open",barindex-2,OP+1.5*pipsize,    SansSerif,Bold) coloured("Fuchsia")
    DrawText("HoY", barindex-2,PrevHH+1.5*pipsize,SansSerif,Bold) coloured(0,128,0,75)
    DrawText("LoY", barindex-2,PrevLL+1.5*pipsize,SansSerif,Bold) coloured(0,0,255,75)
    //
    DrawSegment(BarID,OP,    BarIndex,OP)     coloured("Fuchsia")    style(dottedline)       //Fuchsia
    DrawSegment(BarID,PrevHH,BarIndex,PrevHH) coloured(0,128,0,75)   style(dottedline)       //Green
    DrawSegment(BarID,PrevLL,BarIndex,PrevLL) coloured(0,0,255,75)   style(dottedline)       //Blue
    RETURN
    gadetrading thanked this post
Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.

Plot Open Of Day


ProBuilder: Indicators & Custom Tools

New Reply
Author
Summary

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

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 02/21/2023
Status: Active
Attachments: 2 files
Logo Logo
Loading...