OPEN-SOURCE SCRIPT
ATR Stop Loss Calculator v2 Trade4Green

ATR Stop Loss Calculator
The ATR Stop Loss Calculator is a risk management tool that helps traders determine precise stop loss levels based on the Average True Range (ATR), a widely used volatility indicator developed by J. Welles Wilder. Rather than placing stop losses at arbitrary levels, this indicator anchors them to actual market volatility, ensuring your stop is proportional to how much the market is currently moving.
How it works
The indicator calculates the ATR over a configurable lookback period (default 14 candles) for each of the last 5 closed candles. Each candle is assigned an ID, where ID 1 represents the most recently closed candle and ID 5 the candle closed five bars ago. The ATR value of each candle is multiplied by a configurable multiplier (default 2.5) to produce the stop loss distance. This multiplier controls how much breathing room you give the trade relative to current volatility.
Stop loss calculation
Once you enter your entry price and select Buy or Sell, the indicator automatically calculates your stop loss price:
Buy trade: Entry price minus (ATR × multiplier)
Sell trade: Entry price plus (ATR × multiplier)
You select which candle ID to base your stop loss on, allowing you to reference the volatility at the exact candle where your setup occurred. An optional extra candle ID input lets you monitor any candle further back, such as candle 25, for additional reference.
How to use it
Add the indicator to your chart
Set your preferred ATR period and multiplier in the settings
Enter your intended entry price and select Buy or Sell
Choose which candle ID corresponds to your trade setup
Read your stop loss price directly from the table in the top right corner
All colors in the table are fully customizable to match your chart style.
The ATR Stop Loss Calculator is a risk management tool that helps traders determine precise stop loss levels based on the Average True Range (ATR), a widely used volatility indicator developed by J. Welles Wilder. Rather than placing stop losses at arbitrary levels, this indicator anchors them to actual market volatility, ensuring your stop is proportional to how much the market is currently moving.
How it works
The indicator calculates the ATR over a configurable lookback period (default 14 candles) for each of the last 5 closed candles. Each candle is assigned an ID, where ID 1 represents the most recently closed candle and ID 5 the candle closed five bars ago. The ATR value of each candle is multiplied by a configurable multiplier (default 2.5) to produce the stop loss distance. This multiplier controls how much breathing room you give the trade relative to current volatility.
Stop loss calculation
Once you enter your entry price and select Buy or Sell, the indicator automatically calculates your stop loss price:
Buy trade: Entry price minus (ATR × multiplier)
Sell trade: Entry price plus (ATR × multiplier)
You select which candle ID to base your stop loss on, allowing you to reference the volatility at the exact candle where your setup occurred. An optional extra candle ID input lets you monitor any candle further back, such as candle 25, for additional reference.
How to use it
Add the indicator to your chart
Set your preferred ATR period and multiplier in the settings
Enter your intended entry price and select Buy or Sell
Choose which candle ID corresponds to your trade setup
Read your stop loss price directly from the table in the top right corner
All colors in the table are fully customizable to match your chart style.
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน