Inputs: LookBackPeriod(252); // Number of trading days in the look-back period Variables: MaxHighMinusOpen(0), // Variable to store the maximum value of (High - Open) HighestHighFromOpen(0), // Highest value of High - Open over the look-back period CurrentOpen(0), // Current day's open price LineValue(0), // Value to plot as the horizontal line i(0), // Loop counter PlotStartTime(0930), // Start time for plotting PlotEndTime(1600); // End time for plotting // Initialize values and calculate the highest high from open at the start of each trading day If Date <> Date[1] Then Begin HighestHighFromOpen = -999999; // Initialize for a new day // Loop through the look-back period to find the maximum value of (High - Open) For i = 0 To LookBackPeriod - 1 Begin MaxHighMinusOpen = HighD(i) - OpenD(i); If MaxHighMinusOpen > HighestHighFromOpen Then HighestHighFromOpen = MaxHighMinusOpen; End; // Calculate the value to plot as the horizontal line CurrentOpen = Open; LineValue = CurrentOpen + HighestHighFromOpen; End; // Plot the line during trading hours only If Time >= PlotStartTime And Time <= PlotEndTime Then Begin Plot1(LineValue, "52 Extreme High from Open"); End Else Begin SetPlotColor(1, Transparent); // Hide the line outside trading hours End;