Plotting the previous day high/low on intraday chart

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #209192 quote
    Tom.J
    Participant
    New

    Hello!

    With the great help from this forum I have the indicator below on my charts. Thanks!

    But I realise I need some modification which I am struggling with. What I want is that the line of the previous high and low should be drawn (one single horisantal line not connected with the other days) on each day, not just the current day. Keeping in mind that the day in the intraday chart should be defined as midnight to midnight according to the set timezone.

     

    Anyone could help me with this?

    Thank you!

     

    DEFPARAM DrawOnLastBarOnly = True
    ONCE NYtime = 000000
    ONCE CurO = open
    ONCE CurH = high
    ONCE PrevH = high
    ONCE CurL = low
    ONCE PrevL = low
    ONCE CurHw = high
    ONCE CurLw = low
    ONCE PrevHw = high
    ONCE PrevLw = low
    ONCE OdW = 0
    IF OpenDayOfWeek < OpenDayOfWeek[1] THEN
    OdW = 1
    ENDIF
    IF (OpenTime = NYtime) OR ((OpenTime > NYtime) AND (OpenTime[1] < NyTime)) THEN
    IF OdW = 1 THEN
    PrevHw= CurHw
    PrevLw= CurLw
    CurHw = high
    CurLw = low
    OdW = 0
    ENDIF
    CurO = open
    PrevH = CurH
    PrevL = CurL
    CurH = high
    CurL = low
    Start = BarIndex
    ENDIF
    CurH = max(high,CurH)
    CurL = min(low,CurL)
    CurHw = max(high,CurHw)
    CurLw = min(low,CurLw)
    DrawSegment(Start,CurO,BarIndex,CurO) coloured("Black") style(Line,2)
    DrawSegment(start,PrevH,BarIndex,PrevH) coloured("red") style(Line,2)
    DrawSegment(start,PrevL,Barindex,PrevL) coloured("red") style(Line,2)
    RETURN PrevH coloured("Blue") style(Line,2) AS "Previous DAY high",PrevL coloured("Red") Style(Line,2) AS "Previous DAY low",PrevHw coloured("Gold") style(Line,2) AS "Previous WEEK high",PrevLw coloured("Fuchsia") Style(Line,2) AS "Previous WEEK low"
    
    #209218 quote
    JS
    Participant
    Senior

    Hi Tom,

    When I use your indicator, the “previous high” and “previous low” are already drawn every day… (or do I not understand your question?)

    Tom.J thanked this post
    #209223 quote
    JS
    Participant
    Senior

    By the way, a very good and effective indicator…

    #209225 quote
    Tom.J
    Participant
    New
    Yes, sorry for the confusion. It does that, my mistake with setting it up. But is it possible to get rid of the connecting lines between the different days? I only want the horisontal lines.
    #209226 quote
    JS
    Participant
    Senior

    Hi Tom,

    In its current form, that is not possible…

    Otherwise, you have to calculate the whole indicator differently using arrays…

    #209249 quote
    pableitor
    Participant
    Master
    Hi, I  used this trick with some indicator sometime ago and it worked:
    if opentime >=235900 and opentime <= 000100 then  //if we work in the 1min TF
    alpha = 0
    else 
    alpha = 255
    endif
    
    .....
    
    return prevh coloured (0,0,255,alpha) //repeat with the rest of the lines
    As you see the trick is just zero the alpha (intensity of the color )  between the last and first candles of the day (235900 and 000100 in the 1 min TF) to hide the ugly vertical lines.
    JS thanked this post
    #209258 quote
    pableitor
    Participant
    Master
    below snippet is simple and works on all TF’s  😉
    alpha= 255
    if opentime =000000 then  
    alpha = 0
    endif
     
    .....
     
    return prevh coloured ("blue",alpha) //repeat with the rest of the lines
Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.

Plotting the previous day high/low on intraday chart


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Tom.J @tom-j Participant
Summary

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

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