Quantified Trader

How to Customize Pine Script Indicators

Customizing Pine Script indicators allows traders and analysts to create their own unique technical indicators or modify existing ones to suit their specific trading strategies and preferences. Pine Script, a domain-specific language used in the TradingView platform, provides a flexible framework for creating custom indicators. Here’s a guide on how to customize Pine Script indicators:

– Modifying RSI Indicator by Changing Colour for Entry and Exit signals

//@version=5
indicator(title="Custom RSI", shorttitle="CRSI")

// User input for RSI length
rsiLength = input.int(title="RSI Length", defval=14, minval=1)

// User input for the source of RSI calculation
rsiSrc = input.source(title="RSI Source", defval=close)

// Calculate RSI values based on user inputs
rsiValues = ta.rsi(rsiSrc, rsiLength)

// User input for the overbought level
overbought = input.int(title="Overbought Level", defval=70, minval=0, maxval=100)

// User input for the oversold level
oversold = input.int(title="Oversold Level", defval=30, minval=0, maxval=100)

// Determine the color of the plot line based on RSI values
lineColor = rsiValues > overbought ? color.red : rsiValues < oversold ? color.green : color.blue

// Plot horizontal dashed lines at overbought and oversold levels
hline(overbought, title='Overbought', color=color.red, linestyle=hline.style_dashed)
hline(oversold, title='Oversold', color=color.green, linestyle=hline.style_dashed)

// Plot the RSI values with the determined line color and style
plot(series=rsiValues, title="Custom RSI", color=lineColor, style=plot.style_line)

– Modify the CandleStick Colour Using Pine Script

We define a condition for bullish candles (bullish condition) and bearish candles (bearish condition) based on whether the closing price is greater than the opening price for bullish or less than the opening price for bearish.

We specify the colors for bullish (bullishColor) and bearish (bearishColor) candles using the color function.

Finally, we used the plotcandle function to plot the candles on the chart, and we set the candle color based on the conditions we defined.

This code will color the candles green for bullish candles and red for bearish candles. You can customize the colors by changing the bullishColor and bearishColor variables to your preferred colors.

//@version=5

indicator(title="Custom Candle Color", shorttitle="CCC", overlay=true)
// Define a condition to determine the candle color
bullishCondition = close > open
bearishCondition = close < open

// Set the color for bullish and bearish candles
bullishColor = color.white  //IMP -> Change color here 
bearishColor = color.yellow //IMP -> Change color here

// Plot the candles with the specified colors
plotcandle(open, high, low, close, color=bullishCondition ? bullishColor : bearishColor)

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top