jetgadget
Pine Script Rookie
Pine Script Rookie
Posts: 2
Joined: March 14th, 2022

change line width

I have been struggeling to make an extra addition to my code, tried to set linewidht with variable but it messed it up.
All I wanted to acomplish is to preset the line width to a really bold style. Any one know how this is done?

//@version=5
// vast op D tf gezet.
indicator(title="Moving Average", shorttitle="JBL", overlay=true, timeframe="1440", timeframe_gaps=true)
len = input.int(100, minval=1, title="Length")
src = input(close, title="Source")
offset = input.int(title="Offset", defval=0, minval=-500, maxval=500)
out = ta.sma(src, len)
plot(out,color=color.orange,title="MA", offset=offset)

processingclouds
Pine Script Master
Pine Script Master
Posts: 115
Joined: January 30th, 2022

Re: change line width

Ok so as i understand you want to add linewidth selection as an input.
I have added an input as width and passed it to the plot function. Also i removed the timeframe="1440" and timeframe_gaps from the indicator line. As this required us to select the timeframe from settings when we add the script and i was not really fond of it

Code: Select all

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

//@version=5
// vast op D tf gezet.
indicator(title="Moving Average", shorttitle="JBL", overlay=true)
len = input.int(100, minval=1, title="Length")
src = input.source(close, title="Source")
offset = input.int(title="Offset", defval=0, minval=-500, maxval=500)
out = ta.sma(src, len)

width = input.int(defval=4, title="LineWidth")
plot(out, title="MA", color=color.orange,  linewidth=width, offset=offset)

jetgadget
Pine Script Rookie
Pine Script Rookie
Posts: 2
Joined: March 14th, 2022

Re: change line width

Many Thanks for letting me know how its done, appreciate it, I added the linewidth selection.
Its working perfectly.

Return to “Pine Script Q&A”