OPEN-SOURCE SCRIPT

Q-o-Q Sales, Profit, EPS

//version=5
indicator("Q-o-Q Sales, Profit, EPS", overlay=false)

// Inputs for sales, profit, and EPS for 4 quarters
sales_q1 = input.string("1000", title="Sales Q1 (in K)")
sales_q2 = input.string("1200", title="Sales Q2 (in K)")
sales_q3 = input.string("1100", title="Sales Q3 (in K)")
sales_q4 = input.string("1300", title="Sales Q4 (in K)")

profit_q1 = input.string("200", title="Profit Q1 (in K)")
profit_q2 = input.string("250", title="Profit Q2 (in K)")
profit_q3 = input.string("220", title="Profit Q3 (in K)")
profit_q4 = input.string("300", title="Profit Q4 (in K)")

eps_q1 = input.string("1.5", title="EPS Q1")
eps_q2 = input.string("1.8", title="EPS Q2")
eps_q3 = input.string("1.6", title="EPS Q3")
eps_q4 = input.string("2.0", title="EPS Q4")

// Table creation
var table table_id = table.new(position.top_center, 4, 5, bgcolor=color.new(color.gray, 90))

// Add table headers
table.cell(table_id, 0, 0, "Quarter", text_color=color.white, bgcolor=color.new(color.blue, 50))
table.cell(table_id, 0, 1, "Sales (K)", text_color=color.white, bgcolor=color.new(color.blue, 50))
table.cell(table_id, 0, 2, "Profit (K)", text_color=color.white, bgcolor=color.new(color.blue, 50))
table.cell(table_id, 0, 3, "EPS", text_color=color.white, bgcolor=color.new(color.blue, 50))

// Populate table with data
table.cell(table_id, 1, 0, "Q1", text_color=color.black, bgcolor=color.new(color.white, 0))
table.cell(table_id, 1, 1, sales_q1, text_color=color.black, bgcolor=color.new(color.white, 0))
table.cell(table_id, 1, 2, profit_q1, text_color=color.black, bgcolor=color.new(color.white, 0))
table.cell(table_id, 1, 3, eps_q1, text_color=color.black, bgcolor=color.new(color.white, 0))

table.cell(table_id, 2, 0, "Q2", text_color=color.black, bgcolor=color.new(color.white, 0))
table.cell(table_id, 2, 1, sales_q2, text_color=color.black, bgcolor=color.new(color.white, 0))
table.cell(table_id, 2, 2, profit_q2, text_color=color.black, bgcolor=color.new(color.white, 0))
table.cell(table_id, 2, 3, eps_q2, text_color=color.black, bgcolor=color.new(color.white, 0))

table.cell(table_id, 3, 0, "Q3", text_color=color.black, bgcolor=color.new(color.white, 0))
table.cell(table_id, 3, 1, sales_q3, text_color=color.black, bgcolor=color.new(color.white, 0))
table.cell(table_id, 3, 2, profit_q3, text_color=color.black, bgcolor=color.new(color.white, 0))
table.cell(table_id, 3, 3, eps_q3, text_color=color.black, bgcolor=color.new(color.white, 0))

table.cell(table_id, 4, 0, "Q4", text_color=color.black, bgcolor=color.new(color.white, 0))
table.cell(table_id, 4, 1, sales_q4, text_color=color.black, bgcolor=color.new(color.white, 0))
table.cell(table_id, 4, 2, profit_q4, text_color=color.black, bgcolor=color.new(color.white, 0))
table.cell(table_id, 4, 3, eps_q4, text_color=color.black, bgcolor=color.new(color.white, 0))

// Plot to make the script usable
plot(na)

Aviso legal