luckynickva OHLC
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Nickafella

//@version=5

//@version=5
indicator(title="luckynickva OHLC",  overlay=true, max_lines_count=500)
Open                                                                                    = open
High                                                                                    = high
Low                                                                                     = low
Close                                                                                   = close
Bar_Index                                                                               = bar_index

Timeframe_1_Interval                                                                    = input.timeframe(inline = "1", title = "",   defval =  "D")
Timeframe_1_Buy_Color                                                                   = input.color(    inline = "1", title = "",     defval = color.black )     
Timeframe_1_Sell_Color                                                                  = input.color(    inline = "1", title = "",     defval = color.black)     
Timeframe_1_Buy_Color1                                                                   = input.color(    inline = "1", title = "",     defval = color.black )     
Timeframe_1_Sell_Color1                                                                  = input.color(    inline = "1", title = "",     defval = color.black)     
Timeframe_1_Transparency                                                                = input.int(      inline = "1",  title = "",     defval = 2, maxval=100, minval=1)
var float Timeframe_1_HTF_High                                                          = na 
var float Timeframe_1_HTF_Low                                                           = na
var float Timeframe_1_HTF_Open                                                          = na 
var int Timeframe_1_HTF_Index                                                           = na  
var bool Timeframe_1_Long_Candle                                                        = false 
color2                = input.color( title = "Open Line",     defval = color.orange)     

//New Candle
if ta.change(time(Timeframe_1_Interval)) != 0  
    Wick_Location          = ((Timeframe_1_HTF_Index + bar_index - 1) / 2) 

    line.new(Timeframe_1_HTF_Index,Close[1] , Bar_Index-1  , Close[1] , color = Timeframe_1_Buy_Color, width = Timeframe_1_Transparency)
    line.new(Timeframe_1_HTF_Index,Timeframe_1_HTF_Open , Bar_Index-1  , Timeframe_1_HTF_Open , color = Timeframe_1_Sell_Color, width = Timeframe_1_Transparency)

    min = math.min(Close[1], Timeframe_1_HTF_Open)
    max = math.max(Close[1], Timeframe_1_HTF_Open)
    line.new(Wick_Location,min , Wick_Location  , Timeframe_1_HTF_Low , color = Timeframe_1_Buy_Color1, width = Timeframe_1_Transparency)
    line.new(Wick_Location,Timeframe_1_HTF_High , Wick_Location  , max , color = Timeframe_1_Sell_Color1, width = Timeframe_1_Transparency)
   
    Timeframe_1_HTF_Open      := Open    
    Timeframe_1_HTF_Index     := Bar_Index
    Timeframe_1_HTF_High      := High
    Timeframe_1_HTF_Low       := Low
    lin2 = line.new(time,Timeframe_1_HTF_Open , time+ta.change(time(Timeframe_1_Interval))  , Timeframe_1_HTF_Open , color = color2, width = Timeframe_1_Transparency, xloc = xloc.bar_time)
    line.delete(lin2[1])
else
    if High > Timeframe_1_HTF_High
        Timeframe_1_HTF_High := High
    if Low < Timeframe_1_HTF_Low
        Timeframe_1_HTF_Low := Low



long = ta.crossover(close,Timeframe_1_HTF_Open)  and Timeframe_1_HTF_Open==Timeframe_1_HTF_Open[1]
short = ta.crossunder(close,Timeframe_1_HTF_Open)  and Timeframe_1_HTF_Open==Timeframe_1_HTF_Open[1]

barcolor(long?color.green:short?color.red:na )
alertcondition(long or short, "Open Line Crossed")