Green Line Breakout (GLB) - Public Use
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © GreatStockMarketer

//@version=4
study("Green Line Breakout", overlay = true)
int data_range = 470
    
float[] monthHighs = array.new_float(data_range, 0)
float[] GLValues = array.new_float(3, 0)
//float monthHigh = 0.0
float curentGLV = 0.00
float lastGLV = 0.00
int counter = 0
float val = na

//mnthHighValue(period) => security(syminfo.tickerid,"M",high[period],lookahead=true)

for _i = 0 to data_range-1
    array.set(id=monthHighs, index=_i, value=high[data_range-_i])
    //val := mnthHighValue(10)
    
for _j = 0 to data_range-1
    if array.get(id=GLValues, index=0) < array.get(id=monthHighs, index=_j)
        curentGLV := array.get(id=monthHighs, index=_j)
        array.set(id=GLValues, index=0,value=curentGLV) //Holds the current GLV
        counter := 0
    
    if array.get(id=GLValues, index=0) > array.get(id=monthHighs, index=_j)
        counter := counter + 1
        
        if counter == 3 //and ((month(time) != month(timenow)) or (year(time) != year(timenow)))
            lastGLV := array.get(id=GLValues, index=0)
            array.set(id=GLValues, index=1,value=lastGLV) //Holds the current GLV
            counter=0

if timeframe.ismonthly == false
    array.set(id=GLValues, index=1,value=na)
plot(array.get(GLValues,1), color=timeframe.ismonthly?color.green:color.white, trackprice=true, show_last=1, linewidth=3)