OPEN-SOURCE SCRIPT
GFG S/R lines ES + SPY correlation by Agaam

## GFG S/R Lines + EMA by Agaam
**GFG S/R Lines + EMA** is a clean chart-overlay indicator designed to show important swing-based support and resistance levels together with a trend EMA.
The purpose of this indicator is to give traders a simple visual structure on the chart: where price has recently formed swing highs, where price has recently formed swing lows, and whether price is trading with or against the EMA trend.
## What The Indicator Shows
This script displays two main tools:
1. **Swing-based support and resistance lines**
2. **Trend EMA**
These two components work together to help traders understand market structure and trend direction without overcrowding the chart.
## Support and Resistance Logic
The indicator finds support and resistance using confirmed swing pivots.
A **resistance line** is created when price forms a confirmed swing high.
A **support line** is created when price forms a confirmed swing low.
The swing length can be adjusted in the settings. A smaller swing length will detect more levels, while a larger swing length will create fewer but stronger-looking levels.
The script also avoids placing duplicate levels too close together. If a new pivot forms near an existing level, the script filters it out so the chart stays cleaner.
## Support and Resistance Display
Support and resistance levels are drawn as horizontal lines directly on the chart.
Users can control:
* How many support and resistance levels are shown
* Line length
* Line width
* Whether lines extend right
* Whether lines extend left
* Support color
* Resistance color
* Timeframe tags
* Label size
* Label offset
This makes the indicator flexible for different chart styles and timeframes.
## Timeframe Tags
The indicator can display a small timeframe tag beside each support or resistance line.
This helps traders quickly see which chart timeframe created the level. For example, a level created on the 5-minute chart can be marked as 5m.
Timeframe tags can be turned on or off in the settings.
## EMA Logic
The indicator includes a trend EMA that helps show the current directional bias of price.
When the EMA is rising, it can suggest bullish trend pressure.
When the EMA is falling, it can suggest bearish trend pressure.
When the EMA is flat, it can suggest a more neutral or sideways condition.
The EMA length is adjustable, allowing traders to use a faster or slower trend guide depending on their trading style.
## EMA Colors
The EMA changes color based on its direction:
* Green when the EMA is rising
* Red when the EMA is falling
* Gray when the EMA is flat or neutral
This gives a fast visual read of trend direction without needing extra labels or panels.
## How Traders Can Use It
Traders can use this indicator to:
* Identify recent support areas
* Identify recent resistance areas
* Watch how price reacts near swing levels
* Use the EMA as a simple trend guide
* Compare price location to nearby support/resistance
* Keep the chart clean while still seeing structure and trend
For example, if price is above a rising EMA and pulling back toward a support line, traders may watch that area for a possible reaction. If price is below a falling EMA and approaching resistance, traders may watch for weakness or rejection.
## Important Notes
Support and resistance levels are based on confirmed pivots, so they appear after the swing is confirmed. They should be used as visual reference levels, not as guaranteed reversal points.
The EMA is a trend guide, not a standalone signal. Price can move above or below the EMA during choppy or volatile conditions.
This indicator is best used with market context, price action, and proper risk management.
## Disclaimer
This script is for educational and informational purposes only. It is not financial advice and does not guarantee trading results. Trading involves risk, and every trader is responsible for their own decisions.
**GFG S/R Lines + EMA** is a clean chart-overlay indicator designed to show important swing-based support and resistance levels together with a trend EMA.
The purpose of this indicator is to give traders a simple visual structure on the chart: where price has recently formed swing highs, where price has recently formed swing lows, and whether price is trading with or against the EMA trend.
## What The Indicator Shows
This script displays two main tools:
1. **Swing-based support and resistance lines**
2. **Trend EMA**
These two components work together to help traders understand market structure and trend direction without overcrowding the chart.
## Support and Resistance Logic
The indicator finds support and resistance using confirmed swing pivots.
A **resistance line** is created when price forms a confirmed swing high.
A **support line** is created when price forms a confirmed swing low.
The swing length can be adjusted in the settings. A smaller swing length will detect more levels, while a larger swing length will create fewer but stronger-looking levels.
The script also avoids placing duplicate levels too close together. If a new pivot forms near an existing level, the script filters it out so the chart stays cleaner.
## Support and Resistance Display
Support and resistance levels are drawn as horizontal lines directly on the chart.
Users can control:
* How many support and resistance levels are shown
* Line length
* Line width
* Whether lines extend right
* Whether lines extend left
* Support color
* Resistance color
* Timeframe tags
* Label size
* Label offset
This makes the indicator flexible for different chart styles and timeframes.
## Timeframe Tags
The indicator can display a small timeframe tag beside each support or resistance line.
This helps traders quickly see which chart timeframe created the level. For example, a level created on the 5-minute chart can be marked as 5m.
Timeframe tags can be turned on or off in the settings.
## EMA Logic
The indicator includes a trend EMA that helps show the current directional bias of price.
When the EMA is rising, it can suggest bullish trend pressure.
When the EMA is falling, it can suggest bearish trend pressure.
When the EMA is flat, it can suggest a more neutral or sideways condition.
The EMA length is adjustable, allowing traders to use a faster or slower trend guide depending on their trading style.
## EMA Colors
The EMA changes color based on its direction:
* Green when the EMA is rising
* Red when the EMA is falling
* Gray when the EMA is flat or neutral
This gives a fast visual read of trend direction without needing extra labels or panels.
## How Traders Can Use It
Traders can use this indicator to:
* Identify recent support areas
* Identify recent resistance areas
* Watch how price reacts near swing levels
* Use the EMA as a simple trend guide
* Compare price location to nearby support/resistance
* Keep the chart clean while still seeing structure and trend
For example, if price is above a rising EMA and pulling back toward a support line, traders may watch that area for a possible reaction. If price is below a falling EMA and approaching resistance, traders may watch for weakness or rejection.
## Important Notes
Support and resistance levels are based on confirmed pivots, so they appear after the swing is confirmed. They should be used as visual reference levels, not as guaranteed reversal points.
The EMA is a trend guide, not a standalone signal. Price can move above or below the EMA during choppy or volatile conditions.
This indicator is best used with market context, price action, and proper risk management.
## Disclaimer
This script is for educational and informational purposes only. It is not financial advice and does not guarantee trading results. Trading involves risk, and every trader is responsible for their own decisions.
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน