Get date of weelkly closing

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #237825 quote
    RiDA_hrnRiDA_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
    robertogozzirobertogozzi
    Moderator
    Legend
    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
    JSJS
    Participant
    Master
    Hello, Do you mean something like this…?
    RiDA_hrn thanked this post
    Scherm­afbeelding-2024-09-19-om-18.42.39.png Scherm­afbeelding-2024-09-19-om-18.42.39.png
    #237836 quote
    RiDA_hrnRiDA_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_hrnRiDA_hrn
    Participant
    New
    Hello, Do you mean something like this…?
    yes brother 🙂
    #237838 quote
    JSJS
    Participant
    Master

    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.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

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 JSJS
2 years ago.

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