//@version=5 indicator("S Line",overlay = true ) tz = "America/New_York" market = time(timeframe.period,"0930-1600",tz) var float mar_h = 0 var float mar_l = 0 if not na(market) and na(market[1]) mar_h := high mar_l := low if not na(market) if high>=mar_h mar_h := high if low<=mar_l mar_l := low mar_h_b = ta.valuewhen(ta.change(mar_h),bar_index,0) mar_l_b = ta.valuewhen(ta.change(mar_l),bar_index,0) // (0400-0930 pre = time(timeframe.period,"0400-0930",tz) var float pre_h = 0 var float pre_l = 0 if not na(pre) and na(pre[1]) pre_h := high pre_l := low if not na(pre) if high>=pre_h pre_h := high if low<=pre_l pre_l := low pre_h_b = ta.valuewhen(ta.change(pre_h),bar_index,0) pre_l_b = ta.valuewhen(ta.change(pre_l),bar_index,0) mar_start = not na(market) and na(market[1]) high_on = input.bool(true,"Show High Lines") low_on = input.bool(true,"Show Low Lines") var line high_l1 = na var line high_l2 = na var line low_l1 = na var line low_l2 = na if mar_start if high_on high_l1 := line.new(mar_h_b[1],mar_h[1],pre_h_b,pre_h,xloc.bar_index,extend.both,color.green ) line.delete(high_l1[1]) high_val_at_low = line.get_price(high_l1,mar_l_b[1]) diff_hl = high_val_at_low-mar_l[1] high_l2 := line.new(mar_l_b[1],mar_l[1],pre_h_b,pre_h-diff_hl,xloc.bar_index,extend.both,color.green ) line.delete(high_l2[1]) if low_on low_l1 := line.new(mar_l_b[1],mar_l[1],pre_l_b,pre_l,xloc.bar_index,extend.both,color.red ) line.delete(low_l1[1]) low_val_at_high = line.get_price(low_l1,mar_h_b[1]) diff_lh = mar_h[1] - low_val_at_high low_l2 := line.new(mar_h_b[1],mar_h[1],pre_l_b,pre_l+diff_lh,xloc.bar_index,extend.both,color.red ) line.delete(low_l2[1])