FX Profit Calculator
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © only_fibonacci

//@version=5

indicator("FX Profit Calculator",overlay=true)
standart= 1
tp = input.price(title = "TP",confirm=true,defval =standart)
buyOrder = input.price(title = "Order",confirm=true,defval =standart)
sl = input.price(title = "SL",defval=standart,confirm=true)
lot = input.float(defval=0.1,title="LOT",minval=0.001,step=0.002)
unit=100000*lot
gap = math.abs(tp-buyOrder)
variable_profit= gap*unit
buy = tp>buyOrder and buyOrder>sl
sell = tp<buyOrder and buyOrder<sl
percent=input.int(defval=3,step=1,minval=1,title="Percent")
float multiplier = (100+percent)/100 

leverage = input.int(defval=100,step=10,title="Leverage")


isParity(parity)=>
    parity==currency.USD ? 1 : request.security(parity+currency.USD,"D",close)


    


        
guarantee = unit*isParity(syminfo.basecurrency)/leverage
basePrice= isParity(syminfo.currency)
profit=variable_profit*basePrice
stop = buy ? (sl-buyOrder)*unit*basePrice : (buyOrder-sl)*unit*basePrice
openPosition = input.bool(false,title = "Is the position open?")
status = buy ? (close-buyOrder)*unit*basePrice : (buyOrder-close)*unit*basePrice
string orderType = buy ? "BUY" : sell ? "SELL" : ""


        

if barstate.islast
    if tp<close*multiplier and sl>close/multiplier and (buy or sell)
        tpline=line.new(x1=bar_index[10],y1=tp,x2=bar_index,y2=tp,color=color.green,extend=extend.right,width=2)
        slline=line.new(x1=bar_index[10],y1=sl,x2=bar_index,y2=sl,color=color.red,extend=extend.right,width=2)   
        boline=line.new(x1=bar_index[10],y1=buyOrder,x2=bar_index,y2=buyOrder,color=color.purple,extend=extend.right,width=2)   
        var label = label.new(bar_index+20, tp, text="Profit : "+str.tostring(profit), style=label.style_label_lower_left,color=color.black,textcolor=color.white)
        var label2 = label.new(bar_index+20, sl, text="Stop : "+str.tostring(stop), style=label.style_label_lower_left,color=color.black,textcolor=color.white)
        var label3 = label.new(bar_index+20, buyOrder, text="Order : "+str.tostring(buyOrder)+"\nGuarantee : "+str.tostring(guarantee)+"\nPosition SIDE : "+orderType, style=label.style_label_lower_left,color=color.black,textcolor=color.white)
        
        if openPosition and (buy or sell)
            poslabel = label.new(bar_index+50, buyOrder, text="Status : "+str.tostring(status), style=label.style_label_lower_left,color=color.black,textcolor=status<0 ? color.red : color.green)
    else if tp>close*multiplier or sl<close/multiplier or (buy==false and sell==false)
        var label1 = label.new(bar_index+20, low, text="Please Update Indicator Settings", style=label.style_label_lower_left,color=color.black,textcolor=color.white)

                

 
