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

//@version=5

// @description TODO: add library description here
library("CSMlibrary", overlay = true)

// @function TODO: add function description here
// @param x TODO: add parameter x description here
// @returns TODO: add what function returns
//export fun(float x) =>
	//TODO : add function body and return value here
//	x

// ---------------------------
// @function CSMplot: This function plots a seris with its title at right end
//						The plot will be drawn for last 400 bars. 
// @param myseries: seris to be plotted
// @param mytitle: plot title for the seris
// @param mycolor: plot color for the seris
// @param mywidth: plot line width.
// @param myoffset: offset at right end for the plot label
// @param l_size: string describing the size of the plot label




// @returns TODO: add what function returns

export CSMplot(float myseries, string mytitle, color mycolor, int mywidth, int myoffset, string l_size) =>
	ll_offset = timenow + math.round(ta.change(time)*myoffset)
	// draw last 4000 bars
	var a = array.new_line()
	array.push(a, line.new(bar_index - 1, myseries[1], bar_index, myseries, color = mycolor, width = mywidth, style = line.style_solid))
	if array.size(a) > 4000
		ln = array.shift(a)
		line.delete(ln)


	myplot_line = line.new(x1=timenow, x2=ll_offset, y1=myseries, y2=myseries, xloc=xloc.bar_time, extend=extend.right, color=mycolor, width=mywidth, style=line.style_dotted)
	line.delete(myplot_line[1])
	myplot_label = label.new(x=ll_offset, y=myseries, xloc=xloc.bar_time, yloc=yloc.price, text=mytitle + " ║ " + str.tostring(myseries), style=label.style_none, textcolor=mycolor, size=l_size)
	label.delete(myplot_label[1])

//CSMplot(close, "CLOSE", color.lime,  1,  5,  size.normal)
//CSMplot(open, "OPEN", color.maroon,  1,  5,  size.normal)

// ---------------------------

/// ---------------------------


/// ---------------------------

// ---------------------------


// ---------------------------

// ---------------------------


// ---------------------------

// ---------------------------


// ---------------------------

// ---------------------------


// ---------------------------
//