Logging in PineScript
"Logging in Pine Script" by QuantNomad, MPL-2.0. Ported to FloScript by FloSignals; modifications under MPL-2.0. Original: Logging in Pine Script (v2.0), read 2026-11-15T18:51:37.468Z; source language v5.
Licence: Mozilla Public License 2.0 (MPL-2.0) — full text. The source is published with it, modifications included, under the same licence.
Logging in Pine Script by QuantNomad, ported from Pine v5. Overlay indicator with 2 plots, drawings and 5 inputs.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// (Notice added by FloSignals: the author's source carries none. It was published open-source on 2021-06-05; since 2019-07-26 the platform it was published on has released such a script under MPL-2.0 automatically.)
// ------------------------------------------------------------------------------------------------
// Original author: QuantNomad
// Original title: Logging in Pine Script
// Licence: MPL-2.0 (the notice above was added by FloSignals; the original carries none)
// Pine version: 5
// Fetched: 2026-11-15
// Ported to FloScript by FloSignals; modifications under MPL-2.0.
// Converter: @flosignals/floscript 0.1.0, strict mode, score 100/100
// ------------------------------------------------------------------------------------------------
//@floscript=1
//@version=5
indicator('Logging in PineScript', overlay=true)
////////////
// INPUTS //
// Pivot Points Input
leftBars = input.int(5, group='Pivot Points')
rightBars = input.int(5, group='Pivot Points')
log_show = input.bool(true, title='Show Log?', group='Log')
log_show_msg = input.int(10, title='# of message to show', group='Log')
log_offset = input.int(0, title='# of messages to offset', group='Log', step=1)
//////////////////////////
// 1. Logging Funtions ///
var bar_arr = array.new_int(0)
var time_arr = array.new_string(0)
var msg_arr = array.new_string(0)
var type_arr = array.new_string(0)
log_msg(message, type) =>
array.push(bar_arr, bar_index)
array.push(time_arr, str.tostring(year) + '-' + str.tostring(month) + '-' + str.tostring(dayofmonth) + ' ' + str.tostring(hour) + ':' + str.tostring(minute) + ':' + str.tostring(second))
array.push(msg_arr, message)
array.push(type_arr, type)
// PIVOT POINTS //
swh = ta.pivothigh(leftBars, rightBars)
swl = ta.pivotlow(leftBars, rightBars)
hprice = 0.0
hprice := not na(swh) ? swh : hprice[1]
lprice = 0.0
lprice := not na(swl) ? swl : lprice[1]
plot(hprice, color=color.new(color.green, 0), linewidth=2)
plot(lprice, color=color.new(color.red, 0), linewidth=2)
// Pivot Points Messages //
if not na(swh)
log_msg('New Pivot High: ' + str.tostring(hprice), 'message')
if not na(swh) and hprice > hprice[1]
log_msg('New Pivot Higher High: ' + str.tostring(hprice), 'warning')
if ta.crossover(close, hprice)
log_msg('Pivot High Cross !!', 'error')
if not na(swl)
log_msg('New Pivot Low: ' + str.tostring(lprice), 'message')
if not na(swl) and lprice < lprice[1]
log_msg('New Pivot Lower Low: ' + str.tostring(lprice), 'warning')
if ta.crossunder(close, lprice)
log_msg('Pivot Low Cross !!', 'error')
///////////////////////////////////
// 2. Create and fill log table //
var log_tbl = table.new(position.bottom_left, 3, log_show_msg + 1, border_width=1)
if barstate.islast and log_show
table.cell(log_tbl, 0, 0, 'Bar #', bgcolor=color.gray, text_size=size.small)
table.cell(log_tbl, 1, 0, 'Time', bgcolor=color.gray, text_size=size.small)
table.cell(log_tbl, 2, 0, 'Message', bgcolor=color.gray, text_size=size.small)
for i = 1 to log_show_msg by 1
arr_i = array.size(msg_arr) - log_show_msg + i - 1 - log_offset
if arr_i < 0
break
type = array.get(type_arr, arr_i)
msg_color = type == 'message' ? #cccccc : type == 'warning' ? #F5AC4E : type == 'error' ? #DD4224 : na
table.cell(log_tbl, 0, i, str.tostring(array.get(bar_arr, arr_i)), bgcolor=msg_color, text_size=size.small)
table.cell(log_tbl, 1, i, array.get(time_arr, arr_i), bgcolor=msg_color, text_size=size.small)
table.cell(log_tbl, 2, i, array.get(msg_arr, arr_i), bgcolor=msg_color, text_size=size.small)
This file is under the Mozilla Public License 2.0; it is a port of the original by QuantNomad, with the original licence header kept and the changes made for FloScript noted in the file.
- v1
Library refresh 2026-11-15
Disclaimer. Scripts are written and published by members, or ported by FloSignals from open-source originals, and are their authors' own work and opinion. FloSignals does not review them for correctness and nothing in a script is financial advice or a recommendation to buy or sell anything — read the Risk Disclaimer. Posting here is under the Community Rules; a script that is not the poster's to post can be reported as the Copyright & Takedowns page says.

Comments (0)
No comments yet. Members can leave one.