FIRST-HOUR TOOL V.1.8.08.23
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// author: © tumiza999

//@version=5
indicator("1H FIRST-HOUR TOOL V.2.01", overlay = true)
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// ©tumiza999

//@version=5
//strategy("1H FIRST-HOUR V.2.01", overlay=true, pyramiding = 1, slippage = 1,
 //        initial_capital=10000, 
 //        default_qty_type=strategy.percent_of_equity, default_qty_value=10,
 //        commission_type=strategy.commission.percent, commission_value=0.0750, use_bar_magnifier = false) 


// -----------------------------------------------------------------------------
// Trigger Point 
// -----------------------------------------------------------------------------

open_1H = request.security(syminfo.tickerid, "60", open)
high_1H = request.security(syminfo.tickerid, "60", high)
low_1H= request.security(syminfo.tickerid, "60", low)

SessionHigh(sessionTime, sessionTimeZone=syminfo.timezone) =>
    insideSession = not na(time(timeframe.period, sessionTime, sessionTimeZone))
    var float sessionHighPrice = na

    if insideSession and not insideSession[1]
        sessionHighPrice := high
    else if insideSession
        sessionHighPrice := high_1H
    
    sessionHighPrice

SessionLow(sessionTime, sessionTimeZone=syminfo.timezone) =>
    insideSession = not na(time(timeframe.period, sessionTime, sessionTimeZone))
    var float sessionLowPrice = na

    if insideSession and not insideSession[1]
        sessionLowPrice := low
    else if insideSession
        sessionLowPrice := low_1H
    
    sessionLowPrice

SessionOpen(sessionTime, sessionTimeZone=syminfo.timezone) =>
    insideSession = not na(time(timeframe.period, sessionTime, sessionTimeZone))
    var float sessionOpenPrice = na

    if insideSession and not insideSession[1]
        sessionOpenPrice := open
    else if insideSession
        sessionOpenPrice := open_1H
    
    sessionOpenPrice

InSession(sessionTimes, sessionTimeZone=syminfo.timezone) =>
    not na(time(timeframe.period, sessionTimes, sessionTimeZone))

session  = input.session("0000-0100", title="Data Session")
timeZone = input.string("GMT", title="Time Zone")

sessHigh = SessionHigh(session, timeZone)
sessLow= SessionLow(session, timeZone)
sessOpen= SessionOpen(session, timeZone)

plot(sessHigh, color=color.rgb(92, 217, 255), title="Session High")
plot(sessOpen, color=color.rgb(255, 244, 92), title="Session Open")
plot(sessLow, color=color.rgb(255, 117, 244), title="Session Low")
bgcolor(InSession(session, timeZone) ? color.new(#00ffdd, 95) : na)

if ta.crossover(close,sessHigh)
    alert(message = "High First Hour Crossover", freq = alert.freq_once_per_bar)
    

if ta.crossunder(close, sessOpen)
    alert(message = "Open First Hour Crossunder", freq = alert.freq_once_per_bar)

if ta.crossunder(close,sessLow)
    alert(message = "Low First Hour Crossunder", freq = alert.freq_once_per_bar)

if ta.crossover(close, sessLow)
    alert(message = "Low First Hour Crossover", freq = alert.freq_once_per_bar)

plotshape(ta.crossover(close, sessHigh), "CrossOvHIGH", shape.triangleup, location = location.belowbar, color=color.yellow)
plotshape(ta.crossover(close, sessOpen), "CrossOvOPEN",shape.triangleup, location = location.belowbar, color= color.red)
plotshape(ta.crossover(close, sessLow), "CrossoOvLOW",shape.triangleup, location = location.belowbar, color = color.green)
//plotshape(ta.crossunder(close, sessHigh), "CrossovHigh",shape.triangleup, location = location.belowbar)
//plotshape(ta.crossunder(close, sessHigh), "CrossovHigh",shape.triangleup, location = location.belowbar)
//plotshape(ta.crossunder(close, sessHigh), "CrossovHigh",shape.triangleup, location = location.belowbar)
