Monthly Gain in percentage
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © k_vipz88

//@version=5
indicator(title = "Monthly Gain", shorttitle = "MonthlyGain[%]", overlay = false, timeframe = "D")
current = high
previous = low
days = 0

smallest_sample = input.int(22)

for i = smallest_sample to 200 by 1
    previous := low[i]
    days := i
    if high[i-smallest_sample] < low[i]
        break

percentage = (current - previous) * 22 * 100/(previous * days)
plot(percentage)