PostyPivot, looking for help

Anyone who wish collaborate to port the Posty Pivot from Trading View to Tradovate is welcome
//////////////////////////////////
// This source code is subject to the terms of the Mozilla Public License 2.0 at Mozilla Public License, version 2.0
// © Serge_Trades

//@version=4

study(title=“Posty Pivots”, shorttitle=“Posty Pivots”, overlay=true)
t = “D”

text_R6 = “Bullish Target 2”
text_R5 = “Bullish Target 1”
text_R4 = “Bear Last Stand”
text_R35 = “Bearish Reversal High”
text_R3 = “Bearish Reversal Low”
text_R3R35 = “Bearish Reversal Zone”

text_S6 = “Bearish Target 2”
text_S5 = “Bearish Target 1”
text_S4 = “Bull Last Stand”
text_S35 = “Bullish Reversal Low”
text_S3 = “Bullish Reversal High”
text_S3S35 = “Bullish Reversal Zone”

var labels_enabled = input(defval = true, title = “Show labels”, type = input.bool)
var today_only = input(defval = false, title = “Today levels only”, type = input.bool)

//Start of local functions definiton

draw_line(_x1, _y1, _x2, _y2, _xloc, _extend, _color, _style, _width) =>
dline = line.new(x1 = _x1, y1 = _y1, x2 = _x2, y2 = _y2, xloc = _xloc, extend = _extend, color = _color, style = _style, width = _width)
line.delete(dline[1])

draw_box(_left, _top, _right, _bottom, _color, _width, _style, _extend, _xloc, _bgcolor) =>
dbox = box.new(left = _left, top = _top, right = _right, bottom = _bottom, border_color = _color, border_width = _width, border_style = _style, extend = _extend, xloc = _xloc, bgcolor = _bgcolor)
box.delete(dbox[1])

draw_label(_x, _y, _text, _xloc, _yloc, _color, _style, _textcolor, _size, _textalign, _tooltip) =>
dlabel = label.new(x = _x, y = _y, text = _text, xloc = _xloc, yloc = _yloc, color = _color, style = _style, textcolor = _textcolor,
size = _size, textalign = _textalign, tooltip = _tooltip)
label.delete(dlabel[1])

//End of local functions definiton

//Get data
shigh = security(syminfo.tickerid, t, high[1], barmerge.gaps_off, barmerge.lookahead_on)
slow = security(syminfo.tickerid, t, low[1], barmerge.gaps_off, barmerge.lookahead_on)
sclose = security(syminfo.tickerid, t, close[1], barmerge.gaps_off, barmerge.lookahead_on)
start_time = security(syminfo.tickerid, t, time_close[1], barmerge.gaps_off, barmerge.lookahead_on)
end_time = security(syminfo.tickerid, t, time_close[0], barmerge.gaps_off, barmerge.lookahead_on)
r = shigh - slow

//Calculate pivots
R6 = shigh / slow * sclose //Bull target 2
R4 = sclose + r * (1.1 / 2) //Bear Last Stand
R3 = sclose + r * (1.1 / 4) //Bear Reversal Low
R5 = R4 + 1.168 * (R4 - R3) //Bull Target 1
R35 = R4 - (R4 - R3) / 2 //Bear Reversal High

S3 = sclose - r * (1.1 / 4) //Bull Reversal High
S4 = sclose - r * (1.1 / 2) //Bull Last Stand
S6 = sclose - (R6 - sclose) //Bear Target 2
S35 = S3 - (S3 - S4) / 2 //Bull Reversal Low
S5 = S4 - 1.168 * (S3 - S4) //Bear Target 1

float _R6 = na
float _R5 = na
float _R4 = na
float _R35 = na
float _R3 = na
float _S3 = na
float _S35 = na
float _S4 = na
float _S5 = na
float _S6 = na

//Start of plotting

if timeframe.isintraday and today_only //Plot today only
//Bull (R levels)
draw_line(start_time, R6, end_time, R6, xloc.bar_time, extend.none, color.green, line.style_solid, 1)//Bull target 2
draw_line(start_time, R5, end_time, R5, xloc.bar_time, extend.none, color.green, line.style_solid, 1)//Bull Target 1
draw_line(start_time, R4, end_time, R4, xloc.bar_time, extend.none, color.green, line.style_solid, 2)//Bear Last Stand
draw_box(start_time, R35, end_time, R3, color.red, 1, line.style_solid, extend.none, xloc.bar_time, color.new(color.red,80))//Bear Reversal Zone
//Bear (S levels)
draw_box(start_time, S3, end_time, S35, color.green, 1, line.style_solid, extend.none, xloc.bar_time, color.new(color.green,80))//Bull Reversal Zone
draw_line(start_time, S4, end_time, S4, xloc.bar_time, extend.none, color.red, line.style_solid, 2)//Bull Last Stand
draw_line(start_time, S5, end_time, S5, xloc.bar_time, extend.none, color.red, line.style_solid, 1)//Bear Target 1
draw_line(start_time, S6, end_time, S6, xloc.bar_time, extend.none, color.red, line.style_solid, 1)//Bear Target 2

if timeframe.isintraday and not today_only //Plot all days
_R6 := R6
_R5 := R5
_R4 := R4
_R35 := R35
_R3 := R3
_S3 := S3
_S35 := S35
_S4 := S4
_S5 := S5
_S6 := S6

//Bull (R levels)
plot(_R6, title=text_R6, color=color.green, linewidth=1)//Bull target 2
plot(_R5, title=text_R5, color=color.green, linewidth=1)//Bull Target 1
plot(_R4, title=text_R4, color=color.green, linewidth=2)//Bear Last Stand
BearRevHigh = plot(_R35, title=text_R35, color=color.red, linewidth=1)
BearRevLow = plot(_R3, title=text_R3, color=color.red, linewidth=1)
fill(BearRevHigh, BearRevLow, color.new(color.red,80), title=text_R3R35)//Bear Reversal Zone
//Bear (S levels)
BullRevHigh = plot(_S3, title=text_S3, color=color.green, linewidth=1)
BullRevLow = plot(_S35, title=text_S35, color=color.green, linewidth=1)
fill(BullRevHigh, BullRevLow, color.new(color.green,80), title=text_S3S35)//Bull Reversal Zone
plot(_S4, title=text_S4, color=color.red, linewidth=2)//Bull Last Stand
plot(_S5, title=text_S5, color=color.red, linewidth=1)//Bear Target 1
plot(_S6, title=text_S6, color=color.red, linewidth=1)//Bear Target 2

//End of plotting

//Labels
string_R6 = " (" + tostring(floor(R6)) + “)”
string_R5 = " (" + tostring(floor(R5)) + “)”
string_R4 = " (" + tostring(floor(R4)) + “)”
string_R3R35 = " (" + tostring(floor(R3))+" - "+tostring(floor(R35)) + “)”

string_S6 = " (" + tostring(floor(S6)) + “)”
string_S5 = " (" + tostring(floor(S5)) + “)”
string_S4 = " (" + tostring(floor(S4)) + “)”
string_S3S35 = " (" + tostring(floor(S3))+" - "+tostring(floor(S35)) + “)”

if timeframe.isintraday and labels_enabled
draw_label(bar_index, R6, text_R6+string_R6, xloc.bar_index, yloc.price, color.new(color.white,100), label.style_label_left, color.green,
size.normal, text.align_left, “”)//Bull target 2
draw_label(bar_index, R5, text_R5+string_R5, xloc.bar_index, yloc.price, color.new(color.white,100), label.style_label_left, color.green,
size.normal, text.align_left, “”)//Bull Target 1
draw_label(bar_index, R4, text_R4+string_R4, xloc.bar_index, yloc.price, color.new(color.white,100), label.style_label_left, color.green,
size.normal, text.align_left, “”)//Bear Last Stand
draw_label(bar_index, R3+(R35-R3)/2, text_R3R35+string_R3R35, xloc.bar_index, yloc.price, color.new(color.white,100), label.style_label_left, color.red,
size.normal, text.align_left, “”)//Bear Reversal Zone
draw_label(bar_index, S3-(S3-S35)/2, text_S3S35+string_S3S35, xloc.bar_index, yloc.price, color.new(color.white,100), label.style_label_left, color.green,
size.normal, text.align_left, “”)//Bull Reversal Zone
draw_label(bar_index, S4, text_S4+string_S4, xloc.bar_index, yloc.price, color.new(color.white,100), label.style_label_left, color.red,
size.normal, text.align_left, “”)//Bull Last Stand
draw_label(bar_index, S5, text_S5+string_S5, xloc.bar_index, yloc.price, color.new(color.white,100), label.style_label_left, color.red,
size.normal, text.align_left, “”)//Bear Target 1
draw_label(bar_index, S6, text_S6+string_S6, xloc.bar_index, yloc.price, color.new(color.white,100), label.style_label_left, color.red,
size.normal, text.align_left, “”)//Bear Target 2