Indicator · Pine Script v4 · On the chart

PSMC - Splitting Alerts

by Web3Degenerate· code credited to ZenAndTheArtOfTrading

This indicator demonstrates how to configure and separate multiple alert triggers using input toggles.

View on GitHub

GitHub stars2on the repository
Pine versionv4older, still runs
Lines of code58
Settings4inputs
LicenceNone statedfile: MPL-2.0
Last update2 years ago13 Sep 2024

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

58 lines of Pine Script v4 from advanced-pine-script/16.Bonus-V4-Content/8.Separating-Alerts.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

8.Separating-Alerts.pine
//demonstrates how to split multiple alerts using your settings menu. 

// There are two methods - one is to use the alertcondition() function multiple times in your script for each alert. 

// The advantage of this approach is that you can title your alerts in the alert dialog interface, but the drawback is you need to set each alert individually and you need to use the {{plot}} placeholder to pass script data to a 3rd party API.

// The second (better) method is to use the new alert() function which was introduced recently. This function triggers based on an "if" statement, so it can be more customized than the alertcondition() function.

// And the process of separating multiple alert triggers is made a bit simpler by the fact that you can easily add alert checkboxes to your script's settings menu so that you can isolate and enable whichever alerts you need more fluidly.

// The main advantage of this approach is that you can also use this alert() function to easily add dynamic text messages to your alerts without using the {{plot}} placeholder, which is fantastic for third-party API automation purposes!

// Simply use the "tostring()" function in your alert() message to convert any number data to text.

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ZenAndTheArtOfTrading
// @version=4
study(title="PSMC - Splitting Alerts", overlay=true)

// Get user input
rsiOB_Alert = input(title="RSI OB Alert?", type=input.bool, defval=false)
rsiOS_Alert = input(title="RSI OS Alert?", type=input.bool, defval=false)
rsiOB_Bear_Alert = input(title="RSI OB Bear Alert?", type=input.bool, defval=false)
rsiOS_Bull_Alert = input(title="RSI OS Bull Alert?", type=input.bool, defval=false)

// Get RSI
rsi = rsi(close, 7)

// Detect signals
rsiOB = rsi >= 70
rsiOS = rsi <= 30
rsiOB_Bear = rsiOB[1] and close <= open
rsiOS_Bull = rsiOS[1] and close >= open

// Draw signals
plotshape(rsiOB, style=shape.triangledown, color=color.red, location=location.abovebar, title="RSI OB")
plotshape(rsiOS, style=shape.triangleup, color=color.green, location=location.belowbar, title="RSI OS")
plotshape(rsiOB_Bear, style=shape.arrowdown, color=color.purple, location=location.abovebar, title="RSI OB Bull")
plotshape(rsiOS_Bull, style=shape.arrowup, color=color.purple, location=location.belowbar, title="RSI OS Bear")

// Generate alert triggers
if rsiOB_Alert and rsiOB
    alert("RSI Overbought at: " + tostring(rsi), alert.freq_once_per_bar)

if rsiOS_Alert and rsiOS
    alert("RSI Oversold at: " + tostring(rsi), alert.freq_once_per_bar)

if rsiOB_Bear_Alert and rsiOB_Bear
    alert("RSI Overbought at: " + tostring(rsi) + " and bearish candle closed at: " + tostring(close), alert.freq_once_per_bar_close)
    
if rsiOS_Bull_Alert and rsiOS_Bull
    alert("RSI Oversold at: " + tostring(rsi) + " and bullish candle closed at: " + tostring(close), alert.freq_once_per_bar_close)
    
// Generate alert conditions
alertcondition(rsiOB_Alert and rsiOB, title="RSI Overbought", message="RSI is overbought!")
alertcondition(rsiOS_Alert and rsiOS, title="RSI Oversold", message="RSI is overbought!")
alertcondition(rsiOB_Bear_Alert and rsiOB_Bear, title="RSI Overbought + Bear", message="RSI is overbought and printed a bearish bar!")
alertcondition(rsiOS_Bull_Alert and rsiOS_Bull, title="RSI Oversold + Bull", message="RSI is oversold and printed a bullish bar!")

Overview

PSMC - Splitting Alerts calculates a 7-period RSI to identify overbought and oversold conditions, alongside candlestick confirmations when price closes against the extreme. Signals are plotted directly on the main chart with colored shapes and arrows. The settings menu allows traders to selectively enable alerts for each condition. Both dynamic alert calls with live price and indicator values and standard alertcondition definitions are supported. The RSI length and threshold levels are hardcoded.

Details

Published by

Web3Degenerate on GitHub

Code credit

ZenAndTheArtOfTrading, as written in the script's header

Type

Indicator, Pine Script v4

Draws

On the price chart

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
RSI OB Alert?boolfalsersiOB_Alert
RSI OS Alert?boolfalsersiOS_Alert
RSI OB Bear Alert?boolfalsersiOB_Bear_Alert
RSI OS Bull Alert?boolfalsersiOS_Bull_Alert
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

285 stars

Mean Reversion Study is an indicator that identifies trade setups combining exponential moving averages, RSI extremes, and engulfing candlestick patterns. It highlights bullish setups when a bullish engulfing candle forms below the EMA while RSI is oversold, a

Indicator v4 Mean reversionCandlestick patterns
Updated 3 years ago · None stated GitHub repository of Mean Reversion Study

Raschke Patterns

by TradersPost
228 stars

This overlay indicator marks Linda Raschke short-term bar setups on the price chart. It flags Turtle Soup and Turtle Soup plus one false breakouts of a prior extreme, 80-20 bars, inside bars, failed inside-bar breakouts, outside up and down bars, NR4 and NR7 c

Indicator v6 Candlestick patternsBreakout Repaints
Updated 3 months ago · None stated GitHub repository of Raschke Patterns
55 stars

This indicator overlays on the price chart and provides trend and momentum analysis. It calculates and plots three exponential moving averages with fixed periods of 20, 50, and 200 using yellow, orange, and blue colors respectively. The script also computes th

Indicator v6 TrendOscillators & momentum
Updated 6 months ago · Apache-2.0 GitHub repository of Trend & Momentum Analysis

EmaRainbowCandleMark

by fox-buddy
4 stars

EmaRainbowCandleMark is a price-chart overlay that calculates a stack of exponential moving averages with Fibonacci-style lengths and tests candles for hammers, shooting stars, and bullish or bearish engulfing patterns. Body-to-wick tolerances set how strict t

Indicator v4 Moving averagesCandlestick patterns
Updated 2 years ago · None stated GitHub repository of EmaRainbowCandleMark

GainzAlgo V2 [Alpha]

by IAMATOMIC001
3 stars

This indicator detects buy and sell signals on the price chart by combining engulfing candlestick patterns, body-to-range stability ratios, RSI boundaries, and price momentum over ten bars. Confirmed signals trigger visual buy and sell labels directly on candl

Indicator v5 Candlestick patternsOscillators & momentum
Updated 12 months ago · None stated GitHub repository of GainzAlgo V2 [Alpha]

More Oscillators & momentum scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers