OPEN-SOURCE SCRIPT
Gold SCALP XAUUSD (SMA200/PSAR/ADX/ATR/Arrows)

This script is a custom scalping indicator designed for XAUUSD (gold) trading, suitable for low timeframes such as 1-minute or 5-minute charts.
It combines several proven technical analysis tools: the 200-period Simple Moving Average (SMA), Parabolic SAR (PSAR), Average Directional Index (ADX), and Average True Range (ATR).
The script first calculates the 200-period SMA to determine the overall market trend – above the SMA is bullish, below is bearish.
The PSAR indicator is included to pinpoint short-term reversal points and precise breakout moments.
ADX is calculated manually within the script to measure the strength of the prevailing trend; only strong trends trigger signals.
ATR is used to dynamically set take-profit and stop-loss levels, adapting to current volatility.
A buy signal is generated when the close price crosses above the PSAR, price is above the 200 SMA (bullish environment), and ADX indicates a strong trend above the threshold.
A sell signal appears when the close crosses below the PSAR, price is below SMA 200, and ADX confirms a strong bearish trend.
Arrows are plotted on the chart for every valid buy or sell signal, making trade entries visually clear.
Take-profit and stop-loss levels are plotted as crosses above or below the entry, calculated as multiples of ATR.
The background color subtly changes to green or red, indicating whether the market is bullish or bearish per trend filter.
Users can quickly evaluate trend conditions and momentum at a glance using these color cues.
Parameters for SMA, PSAR, ADX, ATR, and profit/stop levels can be manually adjusted to fit the user’s risk and trading style.
ADX and DI (Directional Indicators) are calculated from price action, not with a built-in, and the code follows the standard ADX mathematical formula.
Signals appear only when the trend is strong, avoiding sideways or choppy movements and helping filter out false positives.
The script does not open or close trades automatically; it is strictly an informational and visual trading tool.
All the plots, shapes, and backgrounds are intended to increase clarity and make decision-making quick during scalping.
The code is written in Pine Script v5, fully compatible with TradingView charts.
It is especially useful for traders looking to capture quick moves but needing strict technical filtering for their scalping approach.
Combining dynamic and static volatility, directional, and trend-following tools helps maximize probability and reduce whipsaw trades.
The modular design enables further customization, such as adding more timeframes or integrating with alerts, based on user preference.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
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.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
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.