OPEN-SOURCE SCRIPT

Buy Sell Indicator PRO

3 118
It uses Average True Range (ATR) to dynamically calculate a trailing stop level that follows price action and adapts to market volatility.

The indicator:

Plots a dynamic trailing stop line on the chart.

Colors the trailing stop line:

Green when in an uptrend (long position),

Red when in a downtrend (short position),

Blue when neutral.

Plots Buy/Sell labels based on when the price crosses above or below the trailing stop line.

Colors candles green or red depending on whether the price is above or below the trailing stop.

It gives alerts for potential Buy and Sell opportunities automatically.

🧠 How It Works (Logic)
ATR Calculation:

It calculates the ATR (Average True Range) over a chosen period (default: 10 bars).

ATR measures market volatility — bigger ATR = bigger stop distance.

Trailing Stop Calculation:

When the price moves up, the trailing stop also moves up.

When the price moves down, the trailing stop moves down.

If price crosses the trailing stop, the trend is considered reversed.

Buy/Sell Signals:

Buy when the price crosses above the trailing stop line.

Sell when the price crosses below the trailing stop line.

EMA Crossover (Optional Flexibility):

By default, the EMA is set to 1 (basically just the close price).

But if you change the EMA period input, it can use a smoothed moving average to trigger Buy/Sell, making signals cleaner.

📈 How To Use It
Add the Indicator to your chart (make sure it's updated to the v5 version I posted earlier).

Adjust the Settings:

Key Value (Sensitivity):

A higher Key Value = wider trailing stop = fewer but more reliable signals.

A lower Key Value = tighter trailing stop = more frequent signals but possibly more noise.

ATR Period:

Higher period = slower reactions (good for higher timeframes).

Lower period = faster reactions (good for scalping or low timeframes).

EMA Period:

1 by default. Increasing it will smooth the entry signals.

Interpret the Chart:

Trailing Stop Line:

If price is above the line and the line is green → market is bullish.

If price is below the line and the line is red → market is bearish.

Buy/Sell Labels:

Entry signals are plotted with clear Buy and Sell tags.

Candle Colors:

Candles turn green when price > trailing stop.

Candles turn red when price < trailing stop.

Set Alerts:

Create a TradingView alert on the Buy and Sell conditions.

You will get automatic alerts when a new signal is detected.

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.