OPEN-SOURCE SCRIPT
Cập nhật Dynamic Testing

Input Parameters
---
Core Calculations
ATR (Average True Range)
ATR is computed using the specified period to gauge price volatility.
Volume SMA
The script calculates the simple moving average of volume over the same period as ATR. This is used as a threshold for validating high-volume scenarios.
---
Support and Resistance Levels
---
Entry Scenarios
Bullish Entry (`isBullishEntry`)
Bearish Entry (`isBearishEntry`)
---
Box Visualization
Bullish and Bearish Boxes
---
Stop Loss and Take Profit Calculations
Bullish Trades
Bearish Trades
---
Visualization for Key Levels
Bullish Scenario
Bearish Scenario
---
Dynamic Updates
---
Purpose
---
Technical Summary
---
- `lookbackPeriod`: Number of candles to check for determining the highest high (resistance) and lowest low (support) levels.
- `atrPeriod`: The period for calculating the Average True Range (ATR), a measure of market volatility.
- `atrMultiplierSL`: Multiplier to calculate the stop-loss distance relative to the ATR.
- `atrMultiplierTP1` and `atrMultiplierTP2`: Multipliers to calculate two take-profit levels relative to ATR.
- `rewardToRisk`: The ratio between reward (profit) and risk (stop loss) for trade management.
---
Core Calculations
ATR (Average True Range)
atr = ta.atr(atrPeriod)
ATR is computed using the specified period to gauge price volatility.
Volume SMA
volumeSMA = ta.sma(volume, atrPeriod)
The script calculates the simple moving average of volume over the same period as ATR. This is used as a threshold for validating high-volume scenarios.
---
Support and Resistance Levels
- `support`: Lowest price over the last `lookbackPeriod` candles.
- `resistance`: Highest price over the same period.
- `supportBuffer` and `resistanceBuffer`: These are "buffered" zones around support and resistance, calculated using half of the ATR to prevent false breakouts.
---
Entry Scenarios
Bullish Entry (`isBullishEntry`)
- The close is above the buffered support level.
- The low of the current candle touches or breaks below the support level.
- The trading volume is greater than the `volumeSMA`.
Bearish Entry (`isBearishEntry`)
- The close is below the buffered resistance level.
- The high of the current candle touches or exceeds the resistance level.
- The trading volume is greater than the `volumeSMA`.
---
Box Visualization
Bullish and Bearish Boxes
- Bullish Box (`bullishBox`):
- A green, semi-transparent rectangle around the support level to highlight the bullish entry zone.
- Dynamically updates based on recent price action. - Bearish Box (`bearishBox`):
- A red, semi-transparent rectangle around the resistance level to highlight the bearish entry zone.
- Adjusts similarly as price evolves.
---
Stop Loss and Take Profit Calculations
Bullish Trades
- Stop Loss (`bullishSL`): Calculated as [code]support - atrMultiplierSL * ATR[/code].
- Take Profit 1 (`bullishTP1`):[code]support + rewardToRisk * atrMultiplierTP1 * ATR[/code].
- Take Profit 2 (`bullishTP2`):[code]support + rewardToRisk * atrMultiplierTP2 * ATR[/code].
Bearish Trades
- Stop Loss (`bearishSL`):[code]resistance + atrMultiplierSL * ATR[/code].
- Take Profit 1 (`bearishTP1`):[code]resistance - rewardToRisk * atrMultiplierTP1 * ATR[/code].
- Take Profit 2 (`bearishTP2`):[code]resistance - rewardToRisk * atrMultiplierTP2 * ATR[/code].
---
Visualization for Key Levels
Bullish Scenario
- Green lines represent `bullishTP1` and `bullishTP2` for profit targets.
- A red line indicates the `bullishSL`.
- Labels like "TP1," "TP2," and "SL" dynamically appear at respective levels to make the targets and risk visually clear.
Bearish Scenario
- Red lines represent `bearishTP1` and `bearishTP2`.
- A green line marks the `bearishSL`.
- Similar dynamic labeling for `TP1`, `TP2`, and `SL` at corresponding bearish levels.
---
Dynamic Updates
- Both the entry boxes and key level visualizations (lines and labels) adjust dynamically based on real-time price and volume data.
---
Purpose
- Identify high-probability bullish and bearish trade setups.
- Define clear entry zones (using boxes) and exit levels (TP1, TP2, SL).
- Incorporate volatility (via ATR) and volume into decision-making.
---
Technical Summary
- Dynamically visualize support/resistance levels.
- Set risk-managed trades using ATR-based stop-loss and profit levels.
- Automate visual trade zones for enhanced chart clarity.
---
Phát hành các Ghi chú
UpdatedMã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội Quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội Quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.