Neowave chart cash data
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © jakklosi12

//@version=4
study(title="Neowave chart", overlay=true, max_lines_count = 500)
//Define variables
string      res = input("D")
var float   h_price = na
var float   l_price = na
var int     h_date = na
var int     l_date = na
var float   h1_price = na
var float   l1_price = na
var int     h1_date = na
var int     l1_date = na



var line z = na
var line w = na
bool isnewtbar = change(time(res)) > 0

//getting lines
if isnewtbar and bar_index > 1 
    h_price := high
    l_price := low
    h_date := time
    l_date := time
    
    z := line.new(x1=h_date, y1=h_price, x2=l_date, y2=l_price, xloc=xloc.bar_time, extend=extend.none, color=color.black, style=line.style_solid, width=2)
    w := line.new(x1=line.get_x2(z[1]), y1=line.get_y2(z[1]), x2=l_date, y2=l_price, xloc=xloc.bar_time, extend=extend.none, color=color.black, style=line.style_solid, width=2)


if high > h_price
    h_price := high
    h_date := time 


if low < l_price
    l_price := low
    l_date := time
  

if h_date <= l_date
    // low to high
    line.set_xy1(id=z, x=h_date, y=h_price)
    line.set_xy2(id=z, x=l_date, y=l_price)
    line.set_color(id=z, color=color.red)
    
    
else
    // high to low
    line.set_xy1(id=z, x=l_date, y=l_price)
    line.set_xy2(id=z, x=h_date, y=h_price)
    line.set_color(id=z, color=color.lime)

line.set_xy2(id=w, x=line.get_x1(z[0]), y=line.get_y1(z[0]))
line.set_color(id=w, color=color.blue)

// if isnewtbar and bar_index > 1 
//     h1_price := high[1]
//     l1_price := low[1]
//     h1_date := time
//     l1_date := time


// if h1_date <= l1_date and h_date <= l_date
//     line.set_xy1(id =z, x = l1_date,y=l1_price)
//     line.set_xy2(id =z, x = h_date,y=h_price)
//     line.set_color(id=z, color=color.green)
