`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.
진정한 TradingView 정신에 따라, 이 스크립트의 저자는 트레이더들이 이해하고 검증할 수 있도록 오픈 소스로 공개했습니다. 저자에게 박수를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 출판물에서 이 코드를 재사용하는 것은 하우스 룰에 의해 관리됩니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.