0% found this document useful (0 votes)
4 views

RSI

This document is a Pine Script code for a custom Relative Strength Index (RSI) indicator. It allows users to configure the RSI length, source, moving average type, and Bollinger Bands settings. The script plots the RSI, its moving average, and optional Bollinger Bands on a chart, providing visual indicators for overbought and oversold conditions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

RSI

This document is a Pine Script code for a custom Relative Strength Index (RSI) indicator. It allows users to configure the RSI length, source, moving average type, and Bollinger Bands settings. The script plots the RSI, its moving average, and optional Bollinger Bands on a chart, providing visual indicators for overbought and oversold conditions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

//@version=5

indicator(title="My Relative Strength Index", shorttitle="RSI",


format=format.price, precision=2, timeframe="", timeframe_gaps=true)

ma(source, length, type) =>


switch type
"SMA" => ta.sma(source, length)
"Bollinger Bands" => ta.sma(source, length)
"EMA" => ta.ema(source, length)
"SMMA (RMA)" => ta.rma(source, length)
"WMA" => ta.wma(source, length)
"VWMA" => ta.vwma(source, length)

rsiLengthInput = input.int(14, minval=1, title="RSI Length", group="RSI Settings")


rsiSourceInput = input.source(close, "Source", group="RSI Settings")
maTypeInput = input.string("SMA", title="MA Type", options=["SMA", "Bollinger
Bands", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="MA Settings")
maLengthInput = input.int(50, title="MA Length", group="MA Settings")
bbMultInput = input.float(1.5, minval=0.001, maxval=50, title="BB StdDev",
group="MA Settings")

up = ta.rma(math.max(ta.change(rsiSourceInput), 0), rsiLengthInput)


down = ta.rma(-math.min(ta.change(rsiSourceInput), 0), rsiLengthInput)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
rsiMA = ma(rsi, maLengthInput, maTypeInput)
isBB = maTypeInput == "Bollinger Bands"

plot(rsi, "RSI", color=#7E57C2)


plot(rsiMA, "RSI-based MA", color=color.orange)
rsiUpperBand = hline(70, "RSI Upper Band1", color=#787B86)
rsiUpperBand1 = hline(60, "RSI Upper Band", color=#4d3aae)
hline(50, "RSI Middle Band", color=color.new(#787B86, 50))
rsiLowerBand = hline(30, "RSI Lower Band1", color=#787B86)
rsiLowerBand1 = hline(40, "RSI Lower Band", color=#9c4a52)
fill(rsiUpperBand1, rsiLowerBand1, color=color.rgb(126, 87, 194, 90), title="RSI
Background Fill")
bbUpperBand = plot(isBB ? rsiMA + ta.stdev(rsi, maLengthInput) * bbMultInput : na,
title = "Upper Bollinger Band", color=color.green)
bbLowerBand = plot(isBB ? rsiMA - ta.stdev(rsi, maLengthInput) * bbMultInput : na,
title = "Lower Bollinger Band", color=color.green)
fill(bbUpperBand, bbLowerBand, color= isBB ? color.new(color.green, 90) : na,
title="Bollinger Bands Background Fill")

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy