// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © tjroberts314
//@version=5
// @description TODO: add library description here
library("Utils")
// @function TODO: add function description here
// @param x TODO: add parameter x description here
// @returns TODO: add what function returns
export print(string txt) =>
// Create label on the first bar.
var lbl = label.new(bar_index, na, txt, xloc.bar_index, yloc.price, color(color.white), label.style_none, color.white, size.large, text.align_left)
// On next bars, update the label's x and y position, and the text it displays.
label.set_xy(lbl, bar_index, ta.highest(10)[1])
label.set_text(lbl, txt)
export roundn(float x, int n) =>
mult = 1
if n != 0
for i = 1 to math.abs(n)
mult := mult * 10
n >= 0 ? math.round(x * mult) / mult : math.round(x / mult) * mult
export printTable() =>
var table tableDisplay = table.new(position.bottom_right, columns = 12, rows = 3, frame_color= color.gray, frame_width = 2, border_width = 2, border_color = color.gray)
if barstate.islast
table.cell(table_id = tableDisplay, column = 0, row = 0, text = "P/L", text_color = color.gray)
table.cell(table_id = tableDisplay, column = 1, row = 0, text = "Put Wins", text_color = color.gray)
table.cell(table_id = tableDisplay, column = 2, row = 0, text = "Put Losses", text_color = color.gray)
table.cell(table_id = tableDisplay, column = 3, row = 0, text = "Call Wins", text_color = color.gray)
table.cell(table_id = tableDisplay, column = 4, row = 0, text = "Call Losses", text_color = color.gray)
table.cell(table_id = tableDisplay, column = 5, row = 0, text = "Total Spreads", text_color = color.gray)
table.cell(table_id = tableDisplay, column = 6, row = 0, text = "Mon W", text_color = color.gray)
table.cell(table_id = tableDisplay, column = 7, row = 0, text = "Mon L", text_color = color.gray)
table.cell(table_id = tableDisplay, column = 8, row = 0, text = "Wed W", text_color = color.gray)
table.cell(table_id = tableDisplay, column = 9, row = 0, text = "Wed L", text_color = color.gray)
table.cell(table_id = tableDisplay, column = 10, row = 0, text = "Fri W", text_color = color.gray)
table.cell(table_id = tableDisplay, column = 11, row = 0, text = "Fri L", text_color = color.gray)
table.cell(table_id = tableDisplay, column = 0, row = 1, text = str.tostring(1), text_color = color.gray)
table.cell(table_id = tableDisplay, column = 1, row = 1, text = str.tostring(2), text_color = color.gray)
table.cell(table_id = tableDisplay, column = 2, row = 1, text = str.tostring(3), text_color = color.gray)
table.cell(table_id = tableDisplay, column = 3, row = 1, text = str.tostring(4), text_color = color.gray)
table.cell(table_id = tableDisplay, column = 4, row = 1, text = str.tostring(5), text_color = color.gray)
table.cell(table_id = tableDisplay, column = 5, row = 1, text = str.tostring(6), text_color = color.gray)
table.cell(table_id = tableDisplay, column = 6, row = 1, text = str.tostring(7), text_color = color.green)
table.cell(table_id = tableDisplay, column = 7, row = 1, text = str.tostring(8), text_color = color.red)
table.cell(table_id = tableDisplay, column = 8, row = 1, text = str.tostring(9), text_color = color.green)
table.cell(table_id = tableDisplay, column = 9, row = 1, text = str.tostring(10), text_color = color.red)
table.cell(table_id = tableDisplay, column = 10, row = 1, text = str.tostring(11), text_color = color.green)
table.cell(table_id = tableDisplay, column = 11, row = 1, text = str.tostring(12), text_color = color.red)