c1 s6 Plotting
c1 s6 Plotting
// ____ _ _ _ _
// | _ \ | | ___ | |_ | |_ (_) _ __ __ _
// | |_) | | | / _ \ | __| | __| | | | '_ \ / _` |
// | __/ | | | (_) | | |_ | |_ | | | | | | | (_| |
// |_| |_| \___/ \__| \__| |_| |_| |_| \__, |
// |___/
// **************************
study("Pinescript - Plotting overlay=false", overlay=false)
// Plots display separated from chart
// Good for separating plots from chart data
// No scaling issues
// **************************
// **************************
// study("Pinescript - Plotting overlay=true", overlay=true)
// Plots display on chart
// Good for visualizing plots with chart data
// Should be same scale as chart data
// **************************
// Note: If you wish to switch overlay, you will need to click “add to chart”
again.
// Simply changing the boolean and saving will not produce the result you desire.
// **************************
plot(close) // Basic plot function
// **************************
// Every study requires at least one plot annotation* (Unless you use some other
output like bgcolor or barcolor)
// Plot annotations have 13 parameters, but only one is required -- the series type
to plot!
// If it’s not a series type, Pine Script will automatically cast the type into a
series (in most cases, booleans won’t work)
// Up to 64 plot annotations can be on one script (This is a cumulation of all
output series)
// Don’t worry about counting your plots though, Pine Script will let you know if
you go over.
// **************************
// input_bool = input(defval=false, title="On/Off", type=input.bool,
confirm=true)
// input_integer = input(defval=1, title="Pick a number 1-1000?",
type=input.integer, minval=1, maxval=1000, confirm=true, step=10)
// input_float = input(defval=1.0, title="", type=input.float)
// input_string = input(defval='247', title="input string", type=input.string)
// input_symbol = input(title="Symbol", type=input.symbol, defval="BTCUSD")
// input_resolution = input(title="Resolution", type=input.resolution, defval="60")
// input_session = input(title="Session", defval="24x7",type=input.session,
options=["24x7", "0900-1300", "1300-1700", "1700-2100"])
// input_source = input(defval=close, title="OHLChl2", type=input.source)
// **************************
// **************************
// hline(6000) // Draws a horizontal line across the chart on the 6000 y-axis.
// hline(6000, title='6000 hline', color=color.gray, linestyle=hline.style_solid,
linewidth=3, editable=true)
// **************************
// We can also assign hline functions to identifiers to be used in fill.
// **************************
// hline_10k = hline(10000)
// hline_5k = hline(5000)
// **************************
// Using fill() we can *fill* the background between two plots or two hlines.
// **************************
// fill(hline_10k, hline_5k)
// **************************
// barcolor(color=color.red)
// barcolor(color=color.yellow, offset=0, editable=true, show_last=100, title="last
100 candles are blue")
// **************************
// **************************
// plotarrow(close-open)
// plotarrow(close-open, offset=-2, title='offset', colorup=color.green,
colordown=color.white, minheight=1, maxheight=200)
// **************************
// **************************
// study("Pinescript - Plotting overlay=false", overlay=true)
// series_bool = close > open
// plotshape(series_bool) // The simplest way only requires only a series
// plot()
// offset_input = input(defval=-1, type=input.integer)
// plotshape(close, title="shapes", style=shape.diamond,
location=location.absolute, color=color.blue, transp=20, offset=offset_input,
text='diamond!', textcolor=color.red, size=size.small)
// **************************
// **************************
// 😁
// study("Pinescript - Plotting overlay=false", overlay=true)
// series_bool = close > open
// plotchar(series_bool) // Just a series is the only required argument.
// plotchar(close) // series[float] will be cast into series[bool], unless
location=location.absolute.
// plotchar(close, location=location.absolute) // Plots a star on everycandle
close price. instead of default above bar.
// plotchar(close < open, title='finger down', char='333', color=color.green,
location=location.abovebar)
// plotchar(close > open, char='🙌', location=location.belowbar)
// plotchar(barstate.islast ? close[1] + close*.10: na, char='🧠',
location=location.absolute, offset=10, size=size.large, text='use your')
// **************************
// Note: plotshape() and plotchar() are practically identical in function and form.
Choose whichever one you would like based on your needs.
// **************************
// plotcandle(open=open, high=high, low=low, close=close) // This is the simplest
method. Will just plot the same candles, but in the default blue color.
// **************************
// A more complex example that plots candles from the weekly chart. Use on a lower
timeframe.
// **************************
// ohlc() => [open, high, low, close]
// [o,h,l,c] = security(syminfo.tickerid, resolution='1W', expression=ohlc()) //
Special function that gets the weekly candle
// plotcandle(open=o, high=h, low=l, close=c, color=color.yellow) // Show last
weeks candle and this weeks
// **************************
// Another example for those who wish to view different charts on the same screen
without upgrading.
// **************************
// study("Pinescript - Adding a chart without Pro plan 🤫", overlay=false) // Be
sure to comment out any other study() before trying to use this one.
// ticker_id = input(defval="xrpusd", type=input.symbol, confirm=true)
// ohlc() => [open, high, low, close]
// [o,h,l,c] = security(ticker_id, resolution=timeframe.period, expression=ohlc())
// Special function that gets the weekly candle
// candle_color = c >= o ? color.green : color.red
// plotcandle(o,h,l,c, color=candle_color, wickcolor=color.gray)
// **************************
// Plot bar does the same thing as plotcandle. The only difference being it is a
bar chart, without wicks and body.
// **************************
// plotbar(open,low, high, close) // minimum required arguments.
// **************************
//Lets do the same thing, but change the location argument. Also, I will remove the
text.
// **************************
// plotshape(rsi_is_above, style=shape.arrowdown, location=location.top,
color=color.red)
// plotshape(rsi_is_below, style=shape.arrowup, location=location.bottom,
color=color.green)
// **************************
// The text would be nice, just in case someone using this indicator is colorblind
or maybe they don't understand arrows becuause they are an alien.
// **************************
// input_sell_sym = input(defval='🐻', confirm=true, title="Select Bearish Symbol",
type=input.string, options=['⚠','', '🐻', '📉', '❎'])
// input_buy_sym = input(defval="🐮", confirm=true, title="Select Bullish Symbol",
type=input.string, options=['⚠','', "🐮", '📈', '✅'])
// plotchar(rsi_is_above, location=location.top, char=input_sell_sym)
// plotchar(rsi_is_below, location=location.bottom, char=input_buy_sym)
// **************************