Sagar sir - N Continuous candle green with +ve % change
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © bhaving

//@version=4
study("N Continuous candle with % change", overlay=true)

//input
noOfCandles = input(title="Number Of Continuous Green Candles", defval=3)
percentageChange = input(title="Percentage Change", defval=20)
highest = highest(noOfCandles)
lowest = lowest(noOfCandles)

if percentageChange < 0 
    percentageChange := percentageChange * -1

if percentageChange == 0 
    percentageChange := 20

percent(n1, n2) =>
    ((n1 - n2) / n2) * 100

truncate(number, decimals) =>
    factor = pow(10, decimals)
    int(number * factor) / factor

// check for continuous green candle
checkForGreen() =>
    result = close > open
    for i=1 to noOfCandles - 1
        result := result and (close[i] > open[i])
    result

continousGreen = checkForGreen()

//calculate percentage and keep 2 decimal place
percentage = percent(highest, lowest)
percentage := truncate(percentage, 2)

if (continousGreen and percentage > percentageChange)
    var label maLabel = na
    percText = tostring(truncate(high, 2)) + "\n(" + tostring(percentage) + "%)"
    maLabel := label.new(x=bar_index, y=na, yloc=yloc.abovebar,
         style=label.style_labeldown, color=color.new(color.blue, 10),
         text=percText,
         textcolor=color.new(color.white, 10))
    
    maLabel := label.new(x=bar_index - 2, y=na, yloc=yloc.belowbar,
         style=label.style_label_up, color=color.new(color.blue, 10),
         text=tostring(truncate(low[noOfCandles - 1], 2)),
         textcolor=color.new(color.white, 10))

// resetting value except our condition match
percentage := continousGreen and percentage > percentageChange ?  percentage : 0
highest := continousGreen and percentage > percentageChange ?  highest : 0
lowest := continousGreen and percentage > percentageChange ?  lowest : 0

// display values along with the sript name in top right corner
plotchar(percentage, "", "", location.top, color.yellow)
plotchar(highest, "", "", location.top, color.green)
plotchar(lowest, "", "", location.top, color.red)