Delta Percentage
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © kicknoob

//@version=5
indicator("Delta Percentage",overlay=false)

coin1 = input.string(title="Choose firstpair Coin ", defval="BTCUSDT")
coin2 = input.string(title="Choose second pair Coin ", defval="ETHUSDT")
coin3 = input.string(title="Choose third pair Coin ", defval="BNBUSDT")
coin4 = input.string(title="Choose fourth pair Coin ", defval="DOGEUSDT")
coin5 = input.string(title="Choose fifth pair Coin ", defval="LTCUSDT")
coin6 = input.string(title="Choose sixth pair Coin ", defval="FILUSDT")
coin7 = input.string(title="Choose seventh pair Coin ", defval="SOLUSDT")
coin8 = input.string(title="Choose eight pair Coin ", defval="DOTUSDT")
coin9 = input.string(title="Choose ninth pair Coin ", defval="LINKUSDT")
c1 = request.security(coin1,timeframe.period,close)
c2 = request.security(coin2,timeframe.period,close)
c3 = request.security(coin3,timeframe.period,close)
c4 = request.security(coin4,timeframe.period,close)
c5 = request.security(coin5,timeframe.period,close)
c6 = request.security(coin6,timeframe.period,close)
c7 = request.security(coin7,timeframe.period,close)
c8 = request.security(coin8,timeframe.period,close)
c9 = request.security(coin9,timeframe.period,close)
monthsBack = input.int(3, minval = 0)
yearsBack  = input.int(0, minval = 0)
fromCurrentDateTime = input(false, "Calculate from current Date/Time instead of first of the month")

targetDate = time >= timestamp(
  year(timenow) - yearsBack, 
  month(timenow) - monthsBack,
  fromCurrentDateTime ? dayofmonth(timenow) : 1,
  fromCurrentDateTime ? hour(timenow)       : 0,
  fromCurrentDateTime ? minute(timenow)     : 0,
  fromCurrentDateTime ? second(timenow)     : 0)

beginMonth = not targetDate[1] and targetDate

var float src1 = na
var float src2 = na
var float src3 = na
var float src4 = na
var float src5 = na
var float src6 = na
var float src7 = na
var float src8 = na
var float src9 = na
if beginMonth
    src1 := c1
    src2 := c2
    src3 := c3
    src4 := c4
    src5 := c5
    src6 := c6
    src7 := c7
    src8 := c8
    src9 := c9
total1 = (c1-src1)/src1*100
total2 = (c2-src2)/src2*100
total3 = (c3-src3)/src3*100
total4 = (c4-src4)/src4*100
total5 = (c5-src5)/src5*100
total6 = (c6-src6)/src6*100
total7 = (c7-src7)/src7*100
total8 = (c8-src8)/src8*100
total9 = (c9-src9)/src9*100

plot(total1,title="Coin 1",color=color.red)
plot(total2,title="Coin 2",color=color.blue)
plot(total3,title="Coin 3",color=color.green)
plot(total4,title="Coin 4",color=color.yellow)
plot(total5,title="Coin 5",color=color.orange)
plot(total6,title="Coin 6",color=color.gray)
plot(total7,title="Coin 7",color=color.purple)
plot(total8,title="Coin 8",color=color.maroon)
plot(total9,title="Coin 9",color=color.white)

