Breakeven rectangle overlay for move contract
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © JuicyWolf
//@version=5

indicator("Breakeven rectangle overlay for move contract", overlay=true)

//inputs
LeftInput = input.time(timestamp("19 Jan 2022 01:00 +0300"),title="Opening contract date")
rightInput = input.time(timestamp("20 Jan 2022 01:00 +0300"),title="Ending contract date")
PrixDuContrat = input.int(defval=800, title="Enter the contract price")
StrikePrice = input.int(defval=42310, title="Enter the strike price of the contract")

LineInput = input.bool(defval=true, title="Activate/unactivate strike-price line")
if LineInput == true
    line.new(x1=LeftInput, y1=StrikePrice, x2=rightInput, y2=StrikePrice, xloc=xloc.bar_time, color=color.red, style=line.style_solid, width=1)
else if LineInput == false
    line.new(x1=LeftInput, y1=StrikePrice, x2=rightInput, y2=StrikePrice, xloc=xloc.bar_time, color=color.new(color.red, 100), style=line.style_solid, width=1)

couleurInput = input.color(defval=color.new(color.green, 95), title="Interior color")
couleur_bordureInput = input.color(defval=color.gray, title="Borders color")
borderWidthInput = input.int(defval=2, title="Change border width")
BorderStyleInput = input.string(defval="solid", title="Change border style", options=["solid","dotted","dashed"])

TextInput = input.string(defval="",title="Add a title to the rectangle")
var string Border = na
Border := if BorderStyleInput == 'solid'
    line.style_solid
else if BorderStyleInput == 'dotted'
    line.style_dotted
else if BorderStyleInput == 'dashed'
    line.style_dashed


//calcul
topInput = StrikePrice + PrixDuContrat
bottomInput = StrikePrice - PrixDuContrat


//Rectangle
var a = box.new(left=LeftInput, top=topInput, right=rightInput, bottom=bottomInput, xloc=xloc.bar_time, border_color=couleur_bordureInput, border_width=borderWidthInput, border_style=Border, bgcolor=couleurInput, text=TextInput)





