Bar Color Long / Short Indicator With Advised SL

This script is a trading indicator named "Bar Color Long / Short Indicator With Advised SL" designed for the TradingView platform. The indicator's primary purpose is to provide entry signals for long and short positions, based on various technical analysis methods. Additionally, the indicator suggests stop-loss levels for both long and short positions.

User Inputs
The indicator has several user inputs, such as:

Show bar colors (ON/OFF)
When the bar colors are turned off, the alert signals for long and short positions will be displayed instead.

Custom Risk Calculation
The script calculates a custom risk level based on a modified version of the RSI (Relative Strength Index) formula. The custom risk level is divided into three categories: low, medium, and high.

Sentiment Score Calculation
The indicator calculates a sentiment score based on a combination of methods resembling EMA (Exponential Moving Average), MACD (Moving Average Convergence Divergence), and ROC (Rate of Change). The sentiment score is used to determine if the sentiment is positive or negative.

Bollinger Bands Percent and Combined Signal
The Bollinger Bands Percent is calculated, and the custom risk, sentiment score, and Bollinger Bands Percent are combined to generate a new signal. This signal is used in conjunction with EMA10 to determine the bar colors and provide entry signals.

Bar Colors
Based on the combined signal and EMA10, the script determines the bar colors as follows:

Orange: Positive sentiment
Blue: Negative sentiment
Gray: Neutral
Entry Signals and Alerts
When the bar colors are turned off, the indicator displays large green arrow signals for long (buy) positions and red arrow signals for short (sell) positions based on the sentiment and EMA10 conditions. The script also includes alert conditions for long and short signals, which can be used to set up notifications when these signals are triggered in the TradingView platform.

Advised Stop-Loss Levels
The indicator plots stop-loss lines for both long and short positions at the last candle, accompanied by labels showing the advised stop-loss levels in numeric values.

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.


The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?