OPEN-SOURCE SCRIPT

Candle Size Alerts (Manual size)

106
This TradingView Pine Script (v6) is an indicator that triggers alerts based on the size of the previous candle. Here's a breakdown of how it works:

1. Indicator Definition
//version=6
indicator('Candle Size Alerts (Manual size)', overlay = true)
The script is written in Pine Script v6.
indicator('Candle Size Alerts (Manual size)', overlay = true):
Defines the indicator name as "Candle Size Alerts (Manual size)".
overlay = true means it runs directly on the price chart (not as a separate panel).

2. Calculate the Previous Candle's Body Size
candleSize = math.abs(close[1] - open[1])
close[1] and open[1] refer to the previous candle’s closing and opening prices.
math.abs(...) ensures that the size is always a positive value, regardless of whether it's a green or red candle.

3. Define a User-Adjustable Candle Size Threshold
candleThreshold = input(500, title = 'Fixed Candle Size Threshold')
input(500, title = 'Fixed Candle Size Threshold'):
Allows users to set a custom threshold (default is 500 points).
If the previous candle's body size exceeds or equals this threshold, an alert is triggered.

4. Check if the Candle Size Meets the Condition
sizeCondition = candleSize >= candleThreshold
This evaluates whether the previous candle's size is greater than or equal to the threshold.
If true, an alert will be generated.

5. Determine Candle Color
isRedCandle = close[1] < open[1]
isGreenCandle = close[1] > open[1]
isRedCandle: The candle is red if the closing price is lower than the opening price.
isGreenCandle: The candle is green if the closing price is higher than the opening price.

6. Generate Alerts Based on Candle Color
if sizeCondition
if isRedCandle
alert('SHORT SIGNAL: Previous candle is RED, body size = ' + str.tostring(candleSize) + ' points (Threshold: ' + str.tostring(candleThreshold) + ')', alert.freq_once_per_bar)
else if isGreenCandle
alert('LONG SIGNAL: Previous candle is GREEN, body size = ' + str.tostring(candleSize) + ' points (Threshold: ' + str.tostring(candleThreshold) + ')', alert.freq_once_per_bar)

If the candle size meets the threshold (sizeCondition == true):
If red, a SHORT SIGNAL alert is triggered.
If green, a LONG SIGNAL alert is triggered.
alert.freq_once_per_bar ensures that alerts are sent only once per candle (avoiding repeated notifications).

How It Works in TradingView:
The script does not plot anything on the chart.
It monitors the previous candle’s body size.
If the size exceeds the threshold, an alert is generated.
Alerts can be used to notify the trader when big candles appear.

How to set Alerts in Trading View
1. Select Indicator – Ensure the indicator is added and properly configured.
2. Set Time Frame – Make sure it's appropriate for your trading strategy.
3. Open Alerts Panel – Click the "Alerts" tab or use the shortcut (Alt + A on Windows).
4. Create a New Alert – Click "+" or "Create Alert."
5. Select Condition – Pick the relevant indicator condition (e.g., "Candle Size Alerts(Manual size)").
6. Choose Alert Function – Default is "Any Alert() Function Call".
7. Set Expiration & Name – Define how long the alert remains active.
8. Configure Notifications – Choose between pop-up, email, webhook, or app notifications.
9. Create Alert – Click "Create" to finalize.

How to set the size manually:
Add the "Candle Size Alerts (Manual size)" Indicator to your chart.
Open Indicator Settings – Click on the indicator and go to the "Inputs" tab.
Set Fixed Size Threshold – Adjust the "Fixed Size Candle Threshold" to your desired value.
Click OK – This applies the changes.
Reset Alerts – Delete and recreate alerts to reflect the new threshold.

Happy Trading !!!!

Clause de non-responsabilité

Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.