PriceCatch Bank FD Return Level
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © PriceCatch

//@version=5
indicator(title="PriceCatch Bank FD Return Level", shorttitle="PriceCatch BankFD RL", precision=0, overlay=true)

ln_X2 							= time_close + (time-time[20])
float _buyPrice = input.price(defval=1,confirm = true,title="Buy Price",tooltip="You may also click on chart and drag the line to select price")

string _bankName = input.string(title="Bank Name", defval="State Bank of India",options=["State Bank of India", "HDFC Bank","Kotak Mahindra Bank", "Axis Bank", "ICICI Bank"],tooltip="Interest rate for 1 year will be used")


float _bankRate = switch _bankName
    "State Bank of India"   => 5.40
    "HDFC"                  => 5.60
    "Kotak Mahindra Bank"   => 4.90
    "Axis Bank"             => 5.75
    "ICICI Bank"            => 5.00
    

float _fdRateGainPrice = _buyPrice + (_buyPrice * _bankRate / 100)

_showGainLevel = input.bool(title="Show Gain Level",defval=true)
_GainLineColor = input.color(color.red, "Line color")
var line _GainLine = na
string gainPrice = str.tostring(_fdRateGainPrice,format.mintick)
string fdRate = str.tostring(_bankRate,format.mintick)
if _showGainLevel
    line.delete(_GainLine)
    _GainLine := line.new(time[bar_index],_fdRateGainPrice, ln_X2, _fdRateGainPrice, extend=extend.none,color=_GainLineColor, style=line.style_dashed, xloc=xloc.bar_time)

    // Show guide text
    var label lbl_guide = na
    label.delete(lbl_guide)
    lbl_guide := label.new(bar_index,0, text="")
    label.set_xloc(lbl_guide, bar_index, xloc.bar_index)
    label.set_yloc(lbl_guide,yloc.price)
    label.set_x(lbl_guide,bar_index)
    label.set_y(lbl_guide,_fdRateGainPrice)
    label.set_text(lbl_guide, "When price reaches " + gainPrice + " you have gained\n" + _bankName + " (" + fdRate + ") FD Interest Rate")
    label.set_style(lbl_guide,label.style_none)
    //label.set_color(lbl_guide, _GainLineColor)
    label.set_textcolor(lbl_guide, _GainLineColor)
    label.set_size(lbl_guide, size.normal)
    label.set_textalign(lbl_guide, text.align_right) 

