How can I extract x time( Bar) values by max

Hello

When I want to set the highest peak by a loop for ... how can I set the value on the bar (x)

  maax = 0 ;
      for ( i=0; i<BarCount; i++)
      {
                     
        
        if (H[i]>H[maax]);
            maax=i;
    
      }

Now I need to draw a point or write a number above (maax)
How can I extract x time values by maax

PlotText( "HH", :interrobang: ,H[ m1 ], colorred );

_SECTION_BEGIN("Price");
//SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleCandle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END();

   	  m1 = 0 ;
      for ( i=0; i<BarCount; i++)
      {
                     
        
        if (H[i]>H[m1]);
            m1=i;
    
      }


 
PlotText( "HH",  ,H[ m1 ], colorred );
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleCandle | ParamStyle("Style") | GetPriceStyle() ); 

hst = LastValue(Highest(H));
bi = LastValue(ValueWhen(H >= hst, BarIndex()));
 
PlotText( "HH", bi, hst, colorred );

thank you awilson

Can I control the "Highest"
and put them in 30 days, a week or 60 days?

Read here
https://www.amibroker.com/guide/afl/hhv.html

You can lookback X number of periods.

thank you travick

I was trying to find it by loop
and giving them names

Is the SYNTAX "HHVBars" equivalent to this

bi = LastValue(ValueWhen(H >= hst, BarIndex()));

How to use instead "bi"