Get date of weelkly closing

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #237825 quote
    RiDA_hrn
    Participant
    New

    hello,

    I’m trying to create code that draws horizantal segment for opening each week This line extends all the week.
    i want to use this indicator for low TF like 5 min or 15-30 mins…
    so i want any trick to get weekly closing date to add it in DateToBarIndex(date) to expend the line of segment until weekly closing date ?

    thank you,

    #237831 quote
    robertogozzi
    Moderator
    Master

    There you go:

    DEFPARAM DrawOnlastBarOnly = True
    IF (OpenDayOfWeek = 1) AND (OpenDayOfWeek <> OpenDayOfWeek[1]) THEN
       StartBar = BarIndex
       WeekOpen = open
       YY       = OpenYear
       MM       = OpenMonth
       DD       = OpenDay + 7
       IF DD > 31 THEN
          DD = DD - 31
          MM = MM + 1
          IF MM > 12 THEN
             MM = 1
             YY = YY + 1
          ENDIF
       ENDIF
       NextWeek = (YY * 10000) + (MM * 100) + DD
       NextDate = (NextWeek * 1000000) + 235959
    ENDIF
    DrawSegment(StartBar,WeekOpen,DateToBarIndex(NextDate),WeekOpen)
    RETURN
    RiDA_hrn and Iván González thanked this post
    #237832 quote
    JS
    Participant
    Senior

    Hello,

    Do you mean something like this…?

    RiDA_hrn thanked this post
    #237836 quote
    RiDA_hrn
    Participant
    New

    Thank you, brother, for your effort… I guessed this way, but this way you should put many possibilities, such as if the month ends on the 28th, 29th, 30th, or 31st… I wanted something easy, such as moving to weekly and taking the time to close that candle… Is that possible?

    #237837 quote
    RiDA_hrn
    Participant
    New

    Hello,

    Do you mean something like this…?

    yes brother 🙂

    #237838 quote
    JS
    Participant
    Senior

    Hi,

    Here is the code:

     

    You can adjust the color, line type and thickness of the line…

    TimeFrame(Weekly)
    OpenWeek=Open
    
    Return OpenWeek as "OpenWeek" Coloured("Purple") Style(DottedLine,3)
    
    RiDA_hrn and Iván González thanked this post
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.

Get date of weelkly closing


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
RiDA_hrn @rida_hrn Participant
Summary

This topic contains 5 replies,
has 3 voices, and was last updated by JS
1 year, 4 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 09/19/2024
Status: Active
Attachments: 1 files
Logo Logo
Loading...