Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Min-Max prior hour

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Min-Max prior hour

    Hi,

    I want to take the min and max from prior hour and draw lines in the min and max to the current hour.

    I'm using this code to show the open of current hour, but the high and low isn't working, also the idea of use the high and low lines is to show the min and max of prior hour.

    Thank you for your help in advance!

    Code:
    InicioHora = new DateTime(Time[0].Year, Time[0].Month, Time[0].Day, Time[0].Hour, 00, Time[0].Second);
    FinHora    = InicioHora.AddHours(1);
    
    [COLOR=#c0392b][B]//I don't know how to find PriorStartHour and PriorEndHour and its respectives min and max values.[/B][/COLOR]
    
    if (Time[0] >= InicioHora && Time[0] < FinHora)
    {
    HoraMax = Math.Max(High[0], HoraMax);
    HoraMin = Math.Min(Low[0], HoraMin);
    
    Print (HoraMax + " HoraMax");
    Print (HoraMin + " HoraMin");
    
    if (InicioHora == Time[0])
    {
    /// Dibujos
    /// Apertura, máximo, mínimo
    Draw.Line(this, "AperturaHora " + Dias, false, InicioHora, Open[0], FinHora, Open[0], Hora_Color, Hora_DashStyle, Hora_Width);
    Draw.Line(this, "MáximoHora" + Dias, false, InicioHora, HoraMax, FinHora, HoraMax, MinMax_Color, MinMax_DashStyle, MinMax_Width);
    Draw.Line(this, "MínimoHora" + Dias, false, InicioHora, HoraMin, FinHora, HoraMin, MinMax_Color, MinMax_DashStyle, MinMax_Width);
    }
    }
    Click image for larger version

Name:	Min-Max prior hour.png
Views:	276
Size:	10.2 KB
ID:	1202850

    #2
    Hi joselube001, thanks for posting. You can add a 60 minute series to your script to get 1 hour bars, then you can take the High and Low value from that series. We have a guide on multi time frame scrips here for reference:


    Kind regards,
    -ChrisL

    Comment


      #3
      Hi ChrisL,
      Thanks for your answer. I have added the 60 minute Dataseries, but still is using only the first bar in the chart of the current hour for min and max
      Click image for larger version

Name:	Min-Max in first bar only.png
Views:	212
Size:	24.7 KB
ID:	1202867

      Comment


        #4
        Hi Jose, to access the previous 60 minute bar use this code:

        Code:
        if(CurrentBars[0] < 1 && CurrentBars[1] < 1)
            return;
        
        if(BarsInProgress == 0)
        {
            Print(Highs[1][0]);
            Print(Lows[1][0]);
        }

        Comment


          #5
          Thank you for your help, ChrisL!!

          It is was I looking for!

          Comment


            #6
            Hi Jose, my code is also accessing the latest hour bar, you can access one hour back like this:


            Code:
            if(CurrentBars[0] < 1 && CurrentBars[1] < 1) return;
            if(BarsInProgress == 0)
            {
                Print(Highs[1][1]);
                Print(Lows[1][1]);
            }

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            647 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            369 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            108 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            572 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            573 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X