Repeat indicator on time intervals

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #205205 quote
    r0d0lphe
    Participant
    Average

    Hi there,

    I allow myself to request your help to create a repetition indicator but I do not know if it is possible
    Today I do it by hand

     

    1 – Calculate the amplitude of points over an hourly interval of the previous day (for example, the previous day, between 2 p.m. and 3 p.m. the max is 11,900 and the min is 11,700, the amplitude of points is 200 that I will call A later)

    2 – On the current day, from a defined time (for example 2 p.m.) identify the low point (called MIN) and draw lines from this low point: MIN+1/2A, MIN+A, MIN+ 1.5A, MIN+2A. When a new low point appears, the lines are recalculated

    3 – On the current day, from a defined time (for example 2 p.m.) identify the high point (called MAX) and draw lines from this high point: MAX-1/2A, MAX-A, MAX- 1.5A, MAX-2A. When a new low point appears, the lines are recalculated

    4 – Optional: be able to add information on the lines drawn: point value, point difference with the current price, percentage difference with the current price,

     

    I think this indicator could be useful for everyone. Our graphics are eternal repetitions

    Thanks in advance

    #205206 quote
    robertogozzi
    Moderator
    Master

    There you go (the 4 MAX and MIN lines are differently coloured, but since they overlap in most cases, the colours will be mostly the same):

    // Repeat Indicator
    //
    // https://www.prorealcode.com/topic/repeat-indicator-on-time-intervals/
    //
    DEFPARAM DrawOnLastBarOnly = True
    //YesterdayFrom = 140000
    //YesterdayTo   = 150000
    //TodayTime     = 140000
    //Multiplier1   = 0.5
    //Multiplier2   = 1.0
    //Multiplier3   = 1.5
    //Multiplier4   = 2.0
    //FutureBARS    = 5
    //
    ONCE HH              = 0
    ONCE LL              = 0
    ONCE prevHH          = 0
    ONCE prevLL          = 0
    ONCE TodayHH         = 0
    ONCE TodayLL         = 0
    ONCE TodayBarHH      = 0
    ONCE TodayBarLL      = 0
    ONCE Amplitude       = 0
    //
    IF (OpenTime >= YesterdayFrom) AND (OpenTime <= YesterdayTo) THEN
       IF (OpenTime = YesterdayFrom) OR ((OpenTime > YesterdayFrom) AND (OpenTime[1] < YesterdayFrom)) THEN
          Amplitude      = HH - LL
          Ampli1         = Amplitude * Multiplier1
          Ampli2         = Amplitude * Multiplier2
          Ampli3         = Amplitude * Multiplier3
          Ampli4         = Amplitude * Multiplier4
          prevHH         = HH
          prevLL         = LL
          HH             = high
          LL             = low
       ENDIF
       HH = max(HH,high)
       LL = min(LL,low)
    ENDIF
    //
    IF (OpenTime >= TodayTime) THEN
       IF (OpenTime = TodayTime) OR ((OpenTime > TodayTime) AND (OpenTime[1] < TodayTime)) THEN
          TodayHH = high
          TodayLL = low
       ENDIF
       TodayHH    = max(TodayHH,high)
       TodayLL    = min(TodayLL,low)
       IF TodayHH <> TodayHH[1] THEN
          TodayBarHH = BarIndex
       ENDIF
       IF TodayLL <> TodayLL[1] THEN
          TodayBarLL = BarIndex
       ENDIF
       Max1 = TodayHH - Ampli1
       Max2 = TodayHH - Ampli2
       Max3 = TodayHH - Ampli3
       Max4 = TodayHH - Ampli4
       //
       Min1 = TodayLL + Ampli1
       Min2 = TodayLL + Ampli2
       Min3 = TodayLL + Ampli3
       Min4 = TodayLL + Ampli4
    ENDIF
    DrawSegment(TodayBarHH,TodayHH,BarIndex + FutureBARS,TodayHH) coloured("SkyBlue")     style(Line,4)        //SkyBlue     (Main HIGH line)
    DrawSegment(TodayBarLL,TodayLL,BarIndex + FutureBARS,TodayLL) coloured("SkyBlue")     style(Line,4)        //SkyBlue     (Main LOW  line)
    //
    DrawSegment(TodayBarHH,Min1,BarIndex + FutureBARS,Min1)       coloured("Tomato")      style(DottedLine,2)  //Tomato
    DrawSegment(TodayBarHH,Min2,BarIndex + FutureBARS,Min2)       coloured("OrangeRed")   style(DottedLine,2)  //OrangeRed
    DrawSegment(TodayBarHH,Min3,BarIndex + FutureBARS,Min3)       coloured("Red")         style(DottedLine,2)  //Red
    DrawSegment(TodayBarHH,Min4,BarIndex + FutureBARS,Min4)       coloured("Crimson")     style(DottedLine,2)  //Crimson
    
    DrawSegment(TodayBarLL,Max1,BarIndex + FutureBARS,Max1)       coloured("DeepSkyBlue") style(DottedLine,2)  //DeepSkyBlue
    DrawSegment(TodayBarLL,Max2,BarIndex + FutureBARS,Max2)       coloured("LightBlue"  ) style(DottedLine,2)  //LightBlue
    DrawSegment(TodayBarLL,Max3,BarIndex + FutureBARS,Max3)       coloured("DodgeBlue")   style(DottedLine,2)  //DodgeBlue
    DrawSegment(TodayBarLL,Max4,BarIndex + FutureBARS,Max4)       coloured("Blue")        style(DottedLine,2)  //Blue
    RETURN

    I added a setting named FutureBARS, it’s the number of bars you want to plot lines beyond the current bar (a negative valuie will plot in the past). If you don’t need it, set it to 0.

    As to the optional data you want to be displayed, will you please attach a picture or a drawing of what you want.

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

Repeat indicator on time intervals


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
r0d0lphe @r0d0lphe Participant
Summary

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

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