Adapting a built-in [PineCoders]
"Adapting a built-in [PineCoders]" by PineCoders, MPL-2.0. Ported to FloScript by FloSignals; modifications under MPL-2.0. Original: Adapting a built-in [PineCoders] (v3.0), read 2026-11-15T18:48:47.313Z; 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.
Adapting a built-in [PineCoders] by PineCoders, ported from Pine v5. Pane indicator with 2 plots, drawings and 9 inputs.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © PineCoders
// ------------------------------------------------------------------------------------------------
// Original author: PineCoders
// Original title: Adapting a built-in [PineCoders]
// Licence: MPL-2.0 (the header above is the original notice, kept verbatim)
// 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("Adapting a built-in [PineCoders]", "Vol", format=format.volume)
// Adapting a built-in [PineCoders]
// v3, 2022.10.01
// This code was written using the recommendations from the Pine Script™ User Manual's Style Guide:
// https://www.tradingview.com/pine-script-docs/en/v5/writing/Style_guide.html
// ———————————————————— Constants and Inputs {
// ————— Constants
color BULL = #00FF00
color BEAR = #FF0000
color MA = color.new(color.gray, 40)
color GRAY = #808080ff
color WHITE = #FFFFFFff
// ————— Inputs
bool showMaInput = input.bool(true, "Show MA, ", inline="ma")
int maLengthInput = input.int(20, "Length", inline="ma", minval=1)
bool usePrevClInput = input.bool(false, "Color columns based on previous close")
bool showInfoBoxInput = input.bool(true, "Show values")
string infoBoxSizeInput = input.string("normal", "Size ", inline="display", options=["tiny", "small", "normal", "large", "huge", "auto"])
string infoBoxYPosInput = input.string("top", "↕", inline="display", options=["top", "middle", "bottom"])
string infoBoxXPosInput = input.string("left", "↔", inline="display", options=["left", "center", "right"])
color infoBoxTxtColorInput = input.color(WHITE, "T", inline="display")
float leftMarginInput = input.float(2.0, "Left margin", minval=1, maxval=100, step=0.5, tooltip="1-100")
// }
// ———————————————————— Calculations {
// Color of the volume columns.
color columns = usePrevClInput ? (close[1] > close ? BEAR : BULL) : open > close ? BEAR : BULL
// MA of volume calculation. We use `nz()` so that value is zero when the symbol has no volume information.
float ma = ta.sma(nz(volume), maLengthInput)
// Detect when the MA is rising. Will be used to determine the color of the background of the MA value's table cell.
bool maRises = ta.rising(ma, 1)
// }
// ———————————————————— Visuals {
// ————— Display table
if showInfoBoxInput
// Create a 4-column, 1-row table.
var table infoBox = table.new(infoBoxYPosInput + "_" + infoBoxXPosInput, 4, 1)
// MA cell's bg is bull color when MA is rising.
color bgMa = maRises ? BULL : BEAR
// Volume cell's bg is bull color when volume is above its MA.
color bgVol = volume > ma ? BULL : BEAR
if barstate.isfirst
// Left margin.
table.cell(infoBox, 0, 0, " ", width=leftMarginInput)
table.cell(infoBox, 1, 0, "", text_color=infoBoxTxtColorInput, text_size=infoBoxSizeInput, bgcolor=bgMa)
// Small space between values (note that you can use a float width).
table.cell(infoBox, 2, 0, " ", width=0.5)
table.cell(infoBox, 3, 0, "", text_color=infoBoxTxtColorInput, text_size=infoBoxSizeInput, bgcolor=bgVol)
else if barstate.islast
table.cell_set_text(infoBox, 1, 0, str.format("SMA({0}): {1,number,###,####,###}", maLengthInput, ma))
table.cell_set_bgcolor(infoBox, 1, 0, bgMa)
table.cell_set_text(infoBox, 3, 0, str.format("Vol: {0,number,###,####,###}", nz(volume)))
table.cell_set_bgcolor(infoBox, 3, 0, bgVol)
// ————— Plots
plot(volume, "Volume", columns, 1, plot.style_columns)
plot(showMaInput ? ma : na, "Volume MA", MA, 1, plot.style_area)
// }
This file is under the Mozilla Public License 2.0; it is a port of the original by PineCoders, 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.