Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
- // © sonnyparlin
- //@version=5
- indicator(shorttitle='RSI+Indicator', title='RSI Indicator', overlay=true)
- // Inputs and variables
- rsiLow = input.int(26, minval=1, title="RSI Low Limit")
- rsiHigh = input.int(75, minval=50, title="RSI High Limit")
- enterLong = ta.crossover(ta.rsi(close,14),rsiLow)
- // Enter long
- currentRSI = ta.rsi(close,14)
- var float entryPrice = na
- if enterLong
- entryPrice := close
- label.new(bar_index,
- low,
- "Go Long ▲ RSI: " + str.tostring(currentRSI, '#'),
- color=color.lime,
- size = size.normal,
- style=label.style_label_up)
- exitWithProfit = input.int(2, title='Signal with at least (x%) profit')/100
- exitCond1 = ta.crossunder(ta.rsi(close,14),rsiHigh)
- exitCond2 = (close - entryPrice) / close > exitWithProfit
- exitLong = exitCond1 and exitCond2
- if exitLong
- label.new(bar_index,
- high,
- "Exit Long ▼ RSI: " + str.tostring(currentRSI, '#'),
- color=color.red,
- size = size.normal,
- style=label.style_label_down)
Advertisement
Add Comment
Please, Sign In to add comment