0% found this document useful (0 votes)
284 views1 page

RSI Trading Strategy with MA Options

The document contains source code for a trading strategy that uses RSI and RSIT indicators. It defines functions to calculate moving averages and inputs for parameters like RSI length, source, and overbought/oversold levels. The strategy enters long positions when RSI crosses above the overbought level and short positions when it crosses below the oversold level.
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)
284 views1 page

RSI Trading Strategy with MA Options

The document contains source code for a trading strategy that uses RSI and RSIT indicators. It defines functions to calculate moving averages and inputs for parameters like RSI length, source, and overbought/oversold levels. The strategy enters long positions when RSI crosses above the overbought level and short positions when it crosses below the oversold level.
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

// This source code is subject to the terms of the Mozilla Public License 2.

0 at
[Link]
// © vishva989

//@version=5
strategy("My strategy", overlay=true, margin_long=100, margin_short=100)

ma(source, length, type) =>


switch type
"SMA" => [Link](source, length)
"Bollinger Bands" => [Link](source, length)
"EMA" => [Link](source, length)
"SMMA (RMA)" => [Link](source, length)
"WMA" => [Link](source, length)
"VWMA" => [Link](source, length)

rsiLengthInput = [Link](14, minval=1, title="RSI Length", group="RSI Settings")


rsitLengthInput = [Link](14, minval=1, title="RSIT Length", group="RSI
Settings")
rsiSourceInput = [Link](close, "Source", group="RSI Settings")
rsitSourceInput = [Link](close, "Source", group="RSI Settings")
oversold= [Link](30,minval=1, title="OverSold", group="RSI Settings")
overbought= [Link](70,minval=1, title="OverBought", group="RSI Settings")
maTypeInput = [Link]("SMA", title="MA Type", options=["SMA", "Bollinger
Bands", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="MA Settings")
maLengthInput = [Link](14, title="MA Length", group="MA Settings")

up = [Link]([Link]([Link](rsiSourceInput), 0), rsiLengthInput)


down = [Link](-[Link]([Link](rsiSourceInput), 0), rsiLengthInput)
upt = [Link]([Link]([Link](rsitSourceInput), 0), rsitLengthInput)
downt = [Link](-[Link]([Link](rsitSourceInput), 0), rsitLengthInput)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
rsit = downt == 0 ? 100 : upt == 0 ? 0 : 100 - (100 / (1 + upt / downt))
rsiMA = ma(rsi, maLengthInput, maTypeInput)

//plot(rsi,color=[Link])
//plot(rsit,color=[Link])

longCondition = [Link](rsi,overbought)
if (longCondition)
[Link]("My Long Entry Id", [Link],100)

shortCondition =[Link](rsi, overbought)


if (shortCondition)
[Link]("My Short Entry Id", [Link],100)

You might also like