You are on page 1of 2

// This source code is subject to the terms of the Mozilla Public License 2.

0 at
https://mozilla.org/MPL/2.0/
// © adelghaeinian

//@version=5
indicator("SKYROCKET | CBDR Range", overlay=true, max_lines_count = 500)

range_start_hour = input.int(defval=12, minval=0, maxval=23, title="Range Start


Hour", group="START", inline="start")
range_start_minute = input.int(defval=0, minval=0, maxval=59, title="Minutes",
group="START", inline="start")
range_end_hour = input.int(defval=13, minval=0, maxval=23, title="Range End Hour",
group="END", inline="end")
range_end_minute = input.int(defval=0, minval=0, maxval=59, title="Minutes",
group="END", inline="end")

// Timezone offset inputs


timezone_offset_hours = input.int(defval=0, title="Timezone UTC Offset
Hours",group="Time Zone Offset", minval=-12, maxval=14, step=1)
timezone_offset_minutes = input.int(defval=0, title="Timezone UTC Offset
Minutes",group="Time Zone Offset", minval=-59, maxval=59, step=1)

count = input(3, title="Count")

colorTop = input(color.green, group = "STYLING")


colorBetween = input(color.new(color.gray, 50), group = "STYLING")
colorBottom = input(color.red, group = "STYLING")

colorRange = input(color.blue, group = "STYLING")


rangeIsDotted = input(true, "Dash Line Style For The Range", group = "STYLING")

plot_mid = input(true)

close_to_close = input(false, "Close To Close (instead of low to high distance)")

total_start_minutes = range_start_hour * 60 + range_start_minute +


timezone_offset_hours * 60 + timezone_offset_minutes
adjusted_start_hour = total_start_minutes / 60 % 24
adjusted_start_minute = total_start_minutes % 60

total_end_minutes = range_end_hour * 60 + range_end_minute + timezone_offset_hours


* 60 + timezone_offset_minutes
adjusted_end_hour = total_end_minutes / 60 % 24
adjusted_end_minute = total_end_minutes % 60

isInRange = hour*60 + minute<= (adjusted_end_hour*60+adjusted_end_minute) and


hour*60 + minute > adjusted_start_minute+adjusted_start_hour*60

isOnEnd = hour[1]*60 + minute[1] < adjusted_end_hour*60+adjusted_end_minute and


hour*60 + minute >= adjusted_end_hour*60+adjusted_end_minute
isOnStart = hour[1]*60 + minute[1] < adjusted_start_minute+adjusted_start_hour*60
and hour*60 + minute >= adjusted_start_minute+adjusted_start_hour*60
var startIDX = -1

var range_high = -100000.0


var range_low = 99999999.9

var distance = 0.0

if isOnStart
startIDX:=bar_index

if isInRange
if not close_to_close
range_high := math.max(range_high, high)
range_low:= math.min(range_low, low)

if close_to_close
range_high := math.max(range_high, close)
range_low:= math.min(range_low, close)
distance := range_high - range_low

if isOnEnd
line.new(startIDX, range_high, bar_index, range_high, xloc=xloc.bar_index,
style=rangeIsDotted?line.style_dashed:line.style_solid, color=colorRange)
line.new(startIDX, range_low, bar_index, range_low, xloc=xloc.bar_index,
style=rangeIsDotted?line.style_dashed:line.style_solid, color=colorRange)
for i = 1 to count
line.new(startIDX, range_high + i*distance, bar_index, range_high +
i*distance, xloc=xloc.bar_index, style=line.style_solid, color=colorTop)
if plot_mid
for i = 1 to count
line.new(startIDX, range_high + (i-1)*distance + distance/2, bar_index,
range_high + (i-1)*distance + distance/2, xloc=xloc.bar_index,
style=line.style_dashed, color=colorBetween)
for i = 1 to count
line.new(startIDX, range_low - (i-1)*distance - distance/2, bar_index,
range_low - (i-1)*distance - distance/2, xloc=xloc.bar_index,
style=line.style_dashed, color=colorBetween)

for i = 1 to count
line.new(startIDX, range_low - i*distance, bar_index, range_low -
i*distance, xloc=xloc.bar_index, style=line.style_solid, color=colorBottom)

range_high := -100000.0
range_low := 99999999.9

You might also like