Search code examples
pine-scriptpine-script-v5pine-script-v4

How to plot horizontal lines on high and low of the 9.30 candle in 1minute char time frame


How to plot horizontal lines for high and low on the candle formed at 9.30 in 1 minute timeframe in pinescript.


Solution

  • You can use the hour and minute built-in variables to figure out if it is 09:30.

    // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
    // © vitruvius
    
    //@version=5
    indicator("My script", overlay=true)
    
    is_930 = (hour == 9) and (minute == 30)
    
    var float hi = na
    var float lo = na
    
    hi := is_930 ? high : hi
    lo := is_930 ? low : lo
    
    plot(hi, "High", color.green, 1, plot.style_circles)
    plot(lo, "Low", color.red, 1, plot.style_circles)
    

    enter image description here