0% found this document useful (0 votes)
27 views9 pages

Pine Scripts

The document contains a Pine Script code for a trading indicator that analyzes the Relative Strength Index (RSI) for multiple banks listed on the NSE, including ICICI, HDFC, SBI, Axis, and Kotak. It calculates the RSI and its moving average, plotting background colors and shapes based on specific RSI conditions. The script aims to visually indicate when the RSI is above or below certain thresholds in relation to its moving average.
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)
27 views9 pages

Pine Scripts

The document contains a Pine Script code for a trading indicator that analyzes the Relative Strength Index (RSI) for multiple banks listed on the NSE, including ICICI, HDFC, SBI, Axis, and Kotak. It calculates the RSI and its moving average, plotting background colors and shapes based on specific RSI conditions. The script aims to visually indicate when the RSI is above or below certain thresholds in relation to its moving average.
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

//@version=5 OF SAME = - SCRIPT

indicator('TEST BOTH + & - TOGETHER', shorttitle='TEST BOTH + & - TOGETHER',


overlay=true)

// Fetch the ICICI Bank price data


icici_close = [Link]('NSE:ICICIBANK', '3', close)

// Calculate RSI
rsi_value1 = [Link](icici_close, 14)

// Calculate RSI-based moving average


rsi_ma1 = [Link](rsi_value1, 14)

// Determine if RSI is above 50 and RSI is above RSI MA


rsi_above_35 = rsi_value1 > 35
rsi_above_rsi_ma = rsi_value1 > rsi_ma1

// Plot background color when RSI is above 50 and RSI is above RSI MA
bgcolor(rsi_above_35 and rsi_above_rsi_ma ? [Link](76, 175, 79, 92) : na,
transp=85)

rsi_above_50 = rsi_value1 < 50


rsi_above_rsi_ma2 = rsi_value1 < rsi_ma1

// Plot background color when RSI is above 50 and RSI is above RSI MA
bgcolor(rsi_above_50 and rsi_above_rsi_ma2 ? [Link](252, 200, 197, 57) : na,
transp=85)

//----------

// Fetch the HDFC Bank price data


hdfc_close = [Link]('NSE:HDFCBANK', '3', close)

// Calculate RSI
rsi_value2 = [Link](hdfc_close, 14)

// Calculate RSI-based moving average


rsi_ma2 = [Link](rsi_value2, 14)

// Determine if RSI is above 50 and RSI is above RSI MA


rsi_above_35_1 = rsi_value2 > 35
rsi_above_rsi_ma_1 = rsi_value2 > rsi_ma2

// Plot a label when RSI is above 50 and RSI is above RSI MA


plotshape(series=rsi_above_35_1 and rsi_above_rsi_ma_1, style=[Link],
location=[Link], color=[Link](57, 22, 255), size=[Link])

rsi_above_50_1 = rsi_value2 < 50


rsi_above_rsi_ma_1_2 = rsi_value2 < rsi_ma2

// Plot a label when RSI is above 50 and RSI is above RSI MA


plotshape(series=rsi_above_50_1 and rsi_above_rsi_ma_1_2, style=[Link],
location=[Link], color=[Link](179, 231, 245), size=[Link])

//-------------
// Fetch the ICICI Bank price data
sbi_close = [Link]('NSE:SBIN', '3', close)

// Calculate RSI
rsi_value3 = [Link](sbi_close, 14)

// Calculate RSI-based moving average


rsi_ma3 = [Link](rsi_value3, 14)

// Determine if RSI is above 50 and RSI is above RSI MA


rsi_above_35_2 = rsi_value3 > 35
rsi_above_rsi_ma_2 = rsi_value3 > rsi_ma3

// Plot a label when RSI is above 50 and RSI is above RSI MA


plotshape(series=rsi_above_35_2 and rsi_above_rsi_ma_2, style=[Link],
location=[Link], color=[Link](255, 31, 31), size=[Link])

// Determine if RSI is above 50 and RSI is above RSI MA


rsi_above_50_2 = rsi_value3 < 50
rsi_above_rsi_ma_2_2 = rsi_value3 < rsi_ma3

// Plot a label when RSI is above 50 and RSI is above RSI MA


plotshape(series=rsi_above_50_2 and rsi_above_rsi_ma_2_2, style=[Link],
location=[Link], color=[Link](125, 28, 28), size=[Link])

//-------------------

//study("RSI Above 50 and MA", shorttitle="RSI Above 50 & MA AXISBANK",


overlay=true)

// Fetch the AXIS Bank price data


axis_close = [Link]('NSE:AXISBANK', '3', close)

// Calculate RSI
rsi_value4 = [Link](axis_close, 14)

// Calculate RSI-based moving average


rsi_ma4 = [Link](rsi_value4, 14)

// Determine if RSI is above 50 and RSI is above RSI MA


rsi_above_35_3 = rsi_value4 > 35
rsi_above_rsi_ma_3 = rsi_value4 > rsi_ma4

// Plot a label when RSI is above 50 and RSI is above RSI MA


plotshape(series=rsi_above_35_3 and rsi_above_rsi_ma_3, style=[Link],
location=[Link], color=[Link](236, 26, 180), size=[Link])

// Determine if RSI is above 50 and RSI is above RSI MA


rsi_above_50_3 = rsi_value4 < 50
rsi_above_rsi_ma_3_2 = rsi_value4 < rsi_ma4

// Plot a label when RSI is above 50 and RSI is above RSI MA


plotshape(series=rsi_above_50_3 and rsi_above_rsi_ma_3_2, style=[Link],
location=[Link], color=[Link](94, 25, 75), size=[Link])

//-------------------
//study("RSI Above 50 and MA", shorttitle="RSI Above 50 & MA KOTAKBANK",
overlay=true)

// Fetch the KOTAK Bank price data


kotak_close = [Link]('NSE:KOTAKBANK', '3', close)

// Calculate RSI
rsi_value5 = [Link](kotak_close, 14)

// Calculate RSI-based moving average


rsi_ma5 = [Link](rsi_value5, 14)

// Determine if RSI is above 50 and RSI is above RSI MA


rsi_above_35_4 = rsi_value5 > 35
rsi_above_rsi_ma_4 = rsi_value5 > rsi_ma5

// Plot a label when RSI is above 50 and RSI is above RSI MA


plotshape(series=rsi_above_35_4 and rsi_above_rsi_ma_4, style=[Link],
location=[Link], color=[Link](255, 182, 13), size=[Link])

// Determine if RSI is above 50 and RSI is above RSI MA


rsi_above_50_4 = rsi_value5 < 50
rsi_above_rsi_ma_4_2 = rsi_value5 < rsi_ma5

// Plot a label when RSI is above 50 and RSI is above RSI MA


plotshape(series=rsi_above_50_4 and rsi_above_rsi_ma_4_2, style=[Link],
location=[Link], color=[Link](201, 152, 77), size=[Link])

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++

complete script up and down in one script RSI above 35 and above MA and RSI below
50 and bellow MA in single indicator

//@version=4 ON + - SCRIPT
study("Test all", shorttitle="Test all", overlay=true)

// Fetch the ICICI Bank price data


icici_close = security("NSE:ICICIBANK", "3", close)

// Calculate RSI
rsi_value1 = rsi(icici_close, 14)

// Calculate RSI-based moving average


rsi_ma1 = sma(rsi_value1, 14)

// Determine if RSI is above 50 and RSI is above RSI MA


rsi_above_35 = rsi_value1 > 35
rsi_above_rsi_ma = rsi_value1 > rsi_ma1

// Plot background color when RSI is above 50 and RSI is above RSI MA
bgcolor(rsi_above_35 and rsi_above_rsi_ma ? [Link](76, 175, 79, 92) : na,
transp=85)
rsi_above_50 = rsi_value1 < 50
rsi_above_rsi_ma2 = rsi_value1 < rsi_ma1

// Plot background color when RSI is above 50 and RSI is above RSI MA
bgcolor(rsi_above_50 and rsi_above_rsi_ma2 ? [Link](252, 200, 197, 57) : na,
transp=85)

//----------

// Fetch the HDFC Bank price data


hdfc_close = security("NSE:HDFCBANK", "3", close)

// Calculate RSI
rsi_value2 = rsi(hdfc_close, 14)

// Calculate RSI-based moving average


rsi_ma2 = sma(rsi_value2, 14)

// Determine if RSI is above 50 and RSI is above RSI MA


rsi_above_35_1 = rsi_value2 > 35
rsi_above_rsi_ma_1 = rsi_value2 > rsi_ma2

// Plot a label when RSI is above 50 and RSI is above RSI MA


plotshape(series=rsi_above_35_1 and rsi_above_rsi_ma_1, style=[Link],
location=[Link], color=[Link](57, 22, 255), size=[Link])

rsi_above_50_1 = rsi_value2 < 50


rsi_above_rsi_ma_1_2 = rsi_value2 < rsi_ma2

// Plot a label when RSI is above 50 and RSI is above RSI MA


plotshape(series=rsi_above_50_1 and rsi_above_rsi_ma_1_2, style=[Link],
location=[Link], color=[Link](179, 231, 245), size=[Link])

//-------------

// Fetch the ICICI Bank price data


sbi_close = security("NSE:SBIN", "3", close)

// Calculate RSI
rsi_value3 = rsi(sbi_close, 14)

// Calculate RSI-based moving average


rsi_ma3 = sma(rsi_value3, 14)

// Determine if RSI is above 50 and RSI is above RSI MA


rsi_above_35_2 = rsi_value3 > 35
rsi_above_rsi_ma_2 = rsi_value3 > rsi_ma3

// Plot a label when RSI is above 50 and RSI is above RSI MA


plotshape(series=rsi_above_35_2 and rsi_above_rsi_ma_2, style=[Link],
location=[Link], color=[Link](255, 31, 31), size=[Link])

// Determine if RSI is above 50 and RSI is above RSI MA


rsi_above_50_2 = rsi_value3 < 50
rsi_above_rsi_ma_2_2 = rsi_value3 < rsi_ma3
// Plot a label when RSI is above 50 and RSI is above RSI MA
plotshape(series=rsi_above_50_2 and rsi_above_rsi_ma_2_2, style=[Link],
location=[Link], color=[Link](125, 28, 28), size=[Link])

//-------------------

//@version=4
//study("RSI Above 50 and MA", shorttitle="RSI Above 50 & MA AXISBANK",
overlay=true)

// Fetch the AXIS Bank price data


axis_close = security("NSE:AXISBANK", "3", close)

// Calculate RSI
rsi_value4 = rsi(axis_close, 14)

// Calculate RSI-based moving average


rsi_ma4 = sma(rsi_value4, 14)

// Determine if RSI is above 50 and RSI is above RSI MA


rsi_above_35_3 = rsi_value4 > 35
rsi_above_rsi_ma_3 = rsi_value4 > rsi_ma4

// Plot a label when RSI is above 50 and RSI is above RSI MA


plotshape(series=rsi_above_35_3 and rsi_above_rsi_ma_3, style=[Link],
location=[Link], color=[Link](236, 26, 180), size=[Link])

// Determine if RSI is above 50 and RSI is above RSI MA


rsi_above_50_3 = rsi_value4 < 50
rsi_above_rsi_ma_3_2 = rsi_value4 < rsi_ma4

// Plot a label when RSI is above 50 and RSI is above RSI MA


plotshape(series=rsi_above_50_3 and rsi_above_rsi_ma_3_2, style=[Link],
location=[Link], color=[Link](94, 25, 75), size=[Link])

//-------------------

//@version=4
//study("RSI Above 50 and MA", shorttitle="RSI Above 50 & MA KOTAKBANK",
overlay=true)

// Fetch the KOTAK Bank price data


kotak_close = security("NSE:KOTAKBANK", "3", close)

// Calculate RSI
rsi_value5 = rsi(kotak_close, 14)

// Calculate RSI-based moving average


rsi_ma5 = sma(rsi_value5, 14)

// Determine if RSI is above 50 and RSI is above RSI MA


rsi_above_35_4 = rsi_value5 > 35
rsi_above_rsi_ma_4 = rsi_value5 > rsi_ma5

// Plot a label when RSI is above 50 and RSI is above RSI MA


plotshape(series=rsi_above_35_4 and rsi_above_rsi_ma_4, style=[Link],
location=[Link], color=[Link](255, 182, 13), size=[Link])

// Determine if RSI is above 50 and RSI is above RSI MA


rsi_above_50_4 = rsi_value5 < 50
rsi_above_rsi_ma_4_2 = rsi_value5 < rsi_ma5

// Plot a label when RSI is above 50 and RSI is above RSI MA


plotshape(series=rsi_above_50_4 and rsi_above_rsi_ma_4_2, style=[Link],
location=[Link], color=[Link](201, 152, 77), size=[Link])

++++++++++++++++++++++++++++++++++++++++++++++++++++++

++++++++++++++++++++++++++++++++++++++++++++++++++++++

++++++++++++++++++++++++++++++++++++++++++++++++++++++

[Link]
usp=drive_link
[Link]

//@version=4
study("RSI Above 50 and MA icici ", shorttitle="RSI Above 50 & MA icici",
overlay=true)

// Fetch the ICICI Bank price data


icici_close = security("NSE:ICICIBANK", "3", close)

// Calculate RSI
rsi_value1 = rsi(icici_close, 14)

// Calculate RSI-based moving average


rsi_ma1 = sma(rsi_value1, 14)

// Determine if RSI is above 50 and RSI is above RSI MA


rsi_above_50 = rsi_value1 > 35
rsi_above_rsi_ma = rsi_value1 > rsi_ma1
// Plot background color when RSI is above 50 and RSI is above RSI MA
bgcolor(rsi_above_50 and rsi_above_rsi_ma ? [Link](76, 175, 79, 92) : na,
transp=85)

// Plot a label when RSI is above 50 and RSI is above RSI MA


//plotshape(series=rsi_above_50 and rsi_above_rsi_ma, style=[Link],
location=[Link], color=[Link], size=[Link])

//----------

// Fetch the HDFC Bank price data


hdfc_close = security("NSE:HDFCBANK", "3", close)

// Calculate RSI
rsi_value2 = rsi(hdfc_close, 14)

// Calculate RSI-based moving average


rsi_ma2 = sma(rsi_value2, 14)

// Determine if RSI is above 50 and RSI is above RSI MA


rsi_above_50_1 = rsi_value2 > 35
rsi_above_rsi_ma_1 = rsi_value2 > rsi_ma2

// Plot background color when RSI is above 50 and RSI is above RSI MA
//bgcolor(rsi_above_50_1 and rsi_above_rsi_ma_1 ? [Link](179, 210, 230, 55) :
na, transp=85)

// Plot a label when RSI is above 50 and RSI is above RSI MA


plotshape(series=rsi_above_50_1 and rsi_above_rsi_ma_1, style=[Link],
location=[Link], color=[Link](31, 142, 253), size=[Link])

//------------

//@version=4
//study("RSI Above 50 and MA", shorttitle="RSI Above 50 & MA SBI", overlay=true)

// Fetch the ICICI Bank price data


sbi_close = security("NSE:SBIN", "3", close)

// Calculate RSI
rsi_value3 = rsi(sbi_close, 14)

// Calculate RSI-based moving average


rsi_ma3 = sma(rsi_value3, 14)

// Determine if RSI is above 50 and RSI is above RSI MA


rsi_above_50_2 = rsi_value3 > 35
rsi_above_rsi_ma_2 = rsi_value3 > rsi_ma3

// Plot background color when RSI is above 50 and RSI is above RSI MA
//bgcolor(rsi_above_50_2 and rsi_above_rsi_ma_2 ? [Link](238, 161, 103, 38) :
na, transp=85)

// Plot a label when RSI is above 50 and RSI is above RSI MA


plotshape(series=rsi_above_50_2 and rsi_above_rsi_ma_2, style=[Link],
location=[Link], color=[Link](255, 31, 31), size=[Link])
//--------------

//@version=4
//study("RSI Above 50 and MA", shorttitle="RSI Above 50 & MA AXISBANK",
overlay=true)

// Fetch the AXIS Bank price data


axis_close = security("NSE:AXISBANK", "3", close)

// Calculate RSI
rsi_value4 = rsi(axis_close, 14)

// Calculate RSI-based moving average


rsi_ma4 = sma(rsi_value4, 14)

// Determine if RSI is above 50 and RSI is above RSI MA


rsi_above_50_3 = rsi_value4 > 35
rsi_above_rsi_ma_3 = rsi_value4 > rsi_ma4

// Plot background color when RSI is above 50 and RSI is above RSI MA
//bgcolor(rsi_above_50_3 and rsi_above_rsi_ma_3 ? [Link](238, 161, 103, 38) :
na, transp=85)

// Plot a label when RSI is above 50 and RSI is above RSI MA


plotshape(series=rsi_above_50_3 and rsi_above_rsi_ma_3, style=[Link],
location=[Link], color=[Link](236, 26, 180), size=[Link])

//----------------

//@version=4
//study("RSI Above 50 and MA", shorttitle="RSI Above 50 & MA KOTAKBANK",
overlay=true)

// Fetch the KOTAK Bank price data


kotak_close = security("NSE:KOTAKBANK", "3", close)

// Calculate RSI
rsi_value5 = rsi(kotak_close, 14)

// Calculate RSI-based moving average


rsi_ma5 = sma(rsi_value5, 14)

// Determine if RSI is above 50 and RSI is above RSI MA


rsi_above_50_4 = rsi_value5 > 35
rsi_above_rsi_ma_4 = rsi_value5 > rsi_ma5

// Plot background color when RSI is above 50 and RSI is above RSI MA
//bgcolor(rsi_above_50_4 and rsi_above_rsi_ma_4 ? [Link](238, 161, 103, 38) :
na, transp=85)

// Plot a label when RSI is above 50 and RSI is above RSI MA


plotshape(series=rsi_above_50_4 and rsi_above_rsi_ma_4, style=[Link],
location=[Link], color=[Link](64, 232, 64), size=[Link])

kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
//general slope posotive
//@version=4
study(title="RSI Slope Positive Marking", shorttitle="RSI Slope+", overlay=false)

rsiLength = input(14, title="RSI Period")


slopePeriod = input(5, title="Slope Calculation Period")

rsiValue = rsi(close, rsiLength)

rsiSlope = (rsiValue - rsiValue[slopePeriod]) / slopePeriod

positiveSlope = rsiSlope > 0

plotshape(positiveSlope, style=[Link], location=[Link],


color=[Link], size=[Link])

kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
//hdfc slope positive
//@version=4
study(title="HDFC Bank RSI Slope Positive Marking", shorttitle="HDFC RSI Slope+",
overlay=false)

rsiLength = input(14, title="RSI Period")


slopePeriod = input(10, title="Slope Calculation Period")

hdfcRsiValue = security("NSE:HDFCBANK", "3", rsi(close, rsiLength))

rsiSlope = (hdfcRsiValue - hdfcRsiValue[slopePeriod]) / slopePeriod

positiveSlope = rsiSlope > 0

plotshape(positiveSlope, style=[Link], location=[Link],


color=[Link], size=[Link])

--------------

//icici slope positive


//@version=4
study(title="icici Bank RSI Slope Positive Marking", shorttitle="icici RSI Slope+",
overlay=false)

rsiLength1 = input(14, title="RSI Period")


slopePeriod1 = input(10, title="Slope Calculation Period")

iciciRsiValue1 = security("NSE:ICICIBANK", "3", rsi(close, rsiLength1))

rsiSlope1 = (iciciRsiValue1 - iciciRsiValue1[slopePeriod1]) / slopePeriod1

positiveSlope1 = rsiSlope1 > 0

plotshape(positiveSlope1, style=[Link], location=[Link],


color=[Link], size=[Link])

You might also like