Pine Script v4 · Strategy
7-RSI strategy
A Pine Script v4 strategy built on RSI (close, 14). It has 42 order rules and no entry of its own. Exits wait for a signal; there is no stop loss. Each trade commits 5% of equity and pays no commission. 36 settings; defaults include Source RSI close, Bot period 1 and Source Bot ohlc4.
Generated from the script's code by a template: every clause is a fact read from the source. Not written by a person or a model, and not taken from the author's description.
- Does 7-RSI strategy repaint?
- No
- No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
- How did 7-RSI strategy do on BTCUSDT 1D with default settings?
- Not measured
- It closed no trades there from 26 Jan 2024 to 21 Oct 2026 with the default settings, so there is no result to report. Its entry conditions never all held on this data. It closed no trades on the other markets either. A backtest, not investment advice.
- Can 7-RSI strategy be converted to Pine Script v5?
- Not tested
- The steps are shown below, but neither version placed a trade on any market tested, so there was nothing to compare and no download is offered.
- Does 7-RSI strategy use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does 7-RSI strategy run in Zeal Terminal?
- Yes
- It compiles in 54 ms and runs 1,000 bars in 152 ms, in the browser.
BTCUSDT · 1D · default settings
- Winning trade
- Losing trade
- Equity
- Buy and hold
Needs BINANCE:BTCUSDT 1 data, not available: a lower timeframe than the chart; the engine does not evaluate intrabar data Needs BINANCE:BTCUSDT 5 data, not available: a lower timeframe than the chart; the engine does not evaluate intrabar data Needs BINANCE:BTCUSDT 15 data, not available: a lower timeframe than the chart; the engine does not evaluate intrabar data Needs BINANCE:BTCUSDT 30 data, not available: a lower timeframe than the chart; the engine does not evaluate intrabar data Needs BINANCE:BTCUSDT 60 data, not available: a lower timeframe than the chart; the engine does not evaluate intrabar data Needs BINANCE:BTCUSDT 120 data, not available: a lower timeframe than the chart; the engine does not evaluate intrabar data Values that depend on it are empty on this chart.
- Net profit
- 0.00%
- $0.00
- Buy and hold
- +102.5%
- same period
- Closed trades
- 0
- 0 won · 0 lost
- Profitable
- 0.0%
- of closed trades
- Profit factor
- —
- gross profit ÷ gross loss
- Max drawdown
- 0.00%
- $0.00
One run with the author's default settings, $100,000 starting capital, commission as the script sets it. A single backtest says little about future results and is not a recommendation. Backtests are simulations on historical data and are not investment advice.
Review
What a careful reader of this script would point out, found by checking the source and the backtest.
-
Check
No stop loss
Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.
-
Check
No commission
The backtest assumes free trading. Results on any real exchange will be lower.
-
Note
No slippage
Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.
-
Note
Uses an argument v6 removed
when = on line 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175. The upgraded version below moves each call inside an if block.
-
Note
Uses long =, which v5 renamed line 135
long = on line 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 178, 180. v5 writes it as direction = strategy.long or strategy.short.
Upgrade and export
Written in Pine Script v4. The upgrade to v5 takes 1 step, one per version, each applied to the result of the one before. A last clean-v5 pass then types the settings and moves when = into if blocks, which v6 requires. Every step runs before and after on the same candles in Zeal Terminal's engine; a step whose results differ is shown but not offered as a download. Upgrades preserve behaviour: bugs are fixed in the Review, never silently here.
- Upgrading to v5 renames security → request.security, rsi → ta.rsi, abs → math.abs.
- 40 strategy calls use the when = argument (line 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
v4 → v5
Not verifiedNeither version placed a trade on any of the 8 markets, so there was nothing to compare.
- Line 3: //@version=4 → //@version=5
- Line 6: input(type = input.source) → input.source()
- Line 7: input(type = input.resolution) → input.timeframe()
- Line 8: input(type = input.source) → input.source()
- Line 9: security → request.security
- Line 10: input(type = input.string) → input.string()
68 more edits
- Line 12: input(type = input.resolution) → input.timeframe()
- Line 14: input(type = input.resolution) → input.timeframe()
- Line 16: input(type = input.resolution) → input.timeframe()
- Line 18: input(type = input.resolution) → input.timeframe()
- Line 20: input(type = input.resolution) → input.timeframe()
- Line 22: input(type = input.resolution) → input.timeframe()
- Line 24: input(type = input.resolution) → input.timeframe()
- Line 26: input(type = input.float) → input.float()
- Line 28: input(type = input.float) → input.float()
- Line 37: input(type = input.float) → input.float()
- Line 39: input(type = input.float) → input.float()
- Line 49: rsi → ta.rsi
- Line 50: security → request.security
- Line 51: rsi → ta.rsi
- Line 52: security → request.security
- Line 53: rsi → ta.rsi
- Line 54: security → request.security
- Line 55: rsi → ta.rsi
- Line 56: security → request.security
- Line 57: rsi → ta.rsi
- Line 58: security → request.security
- Line 59: rsi → ta.rsi
- Line 60: security → request.security
- Line 61: rsi → ta.rsi
- Line 62: security → request.security
- Line 135: long = true → direction = strategy.long
- Line 136: long = true → direction = strategy.long
- Line 137: long = true → direction = strategy.long
- Line 138: long = true → direction = strategy.long
- Line 139: long = true → direction = strategy.long
- Line 140: long = true → direction = strategy.long
- Line 141: long = true → direction = strategy.long
- Line 142: long = true → direction = strategy.long
- Line 143: long = true → direction = strategy.long
- Line 144: long = true → direction = strategy.long
- Line 145: long = true → direction = strategy.long
- Line 146: long = true → direction = strategy.long
- Line 147: long = true → direction = strategy.long
- Line 148: long = true → direction = strategy.long
- Line 149: long = true → direction = strategy.long
- Line 150: long = true → direction = strategy.long
- Line 151: long = true → direction = strategy.long
- Line 152: long = true → direction = strategy.long
- Line 153: long = true → direction = strategy.long
- Line 154: long = true → direction = strategy.long
- Line 156: long = false → direction = strategy.short
- Line 157: long = false → direction = strategy.short
- Line 158: long = false → direction = strategy.short
- Line 159: long = false → direction = strategy.short
- Line 160: long = false → direction = strategy.short
- Line 161: long = false → direction = strategy.short
- Line 162: long = false → direction = strategy.short
- Line 163: long = false → direction = strategy.short
- Line 164: long = false → direction = strategy.short
- Line 165: long = false → direction = strategy.short
- Line 166: long = false → direction = strategy.short
- Line 167: long = false → direction = strategy.short
- Line 168: long = false → direction = strategy.short
- Line 169: long = false → direction = strategy.short
- Line 170: long = false → direction = strategy.short
- Line 171: long = false → direction = strategy.short
- Line 172: long = false → direction = strategy.short
- Line 173: long = false → direction = strategy.short
- Line 174: long = false → direction = strategy.short
- Line 175: long = false → direction = strategy.short
- Line 178: long = false → direction = strategy.short
- Line 180: long = true → direction = strategy.long
- Line 180: abs → math.abs
⋯// © rrolik66-//@version=4+//@version=5strategy(title="7-RSI strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=5, currency=currency.USD)// inputs-src = input(close, "Source RSI", type = input.source)+src = input.source(close, "Source RSI")-bot_res = input(title="Bot period", type=input.resolution, defval="1")+bot_res = input.timeframe(title="Bot period", defval="1")-srcin_bot = input(ohlc4, "Source Bot", type = input.source)+srcin_bot = input.source(ohlc4, "Source Bot")-src_bot = security(syminfo.tickerid, bot_res, srcin_bot)+src_bot = request.security(syminfo.tickerid, bot_res, srcin_bot)-tradeDirection = input(title="Trade Direction", type=input.string,+tradeDirection = input.string(title="Trade Direction", options=["Long Bot", "Short Bot"], defval="Long Bot")-rsi1_res = input(title="RSI-1 period", type=input.resolution, defval="1", group="indicators")+rsi1_res = input.timeframe(title="RSI-1 period", defval="1", group="indicators")rsi1_Len = input(14, minval=1, title="RSI-1 Length", group="indicators")-rsi2_res = input(title="RSI-2 period", type=input.resolution, defval="5", group="indicators")+rsi2_res = input.timeframe(title="RSI-2 period", defval="5", group="indicators")rsi2_Len = input(14, minval=1, title="RSI-2 Length", group="indicators")-rsi3_res = input(title="RSI-3 period", type=input.resolution, defval="15", group="indicators")+rsi3_res = input.timeframe(title="RSI-3 period", defval="15", group="indicators")rsi3_Len = input(14, minval=1, title="RSI-3 Length", group="indicators")-rsi4_res = input(title="RSI-4 period", type=input.resolution, defval="30", group="indicators")+rsi4_res = input.timeframe(title="RSI-4 period", defval="30", group="indicators")rsi4_Len = input(14, minval=1, title="RSI-4 Length", group="indicators")-rsi5_res = input(title="RSI-5 period", type=input.resolution, defval="60", group="indicators")+rsi5_res = input.timeframe(title="RSI-5 period", defval="60", group="indicators")rsi5_Len = input(14, minval=1, title="RSI-5 Length", group="indicators")-rsi6_res = input(title="RSI-6 period", type=input.resolution, defval="120", group="indicators")+rsi6_res = input.timeframe(title="RSI-6 period", defval="120", group="indicators")rsi6_Len = input(14, minval=1, title="RSI-6 Length", group="indicators")-rsi7_res = input(title="RSI-7 period", type=input.resolution, defval="1D", group="indicators")+rsi7_res = input.timeframe(title="RSI-7 period", defval="1D", group="indicators")rsi7_Len = input(14, minval=1, title="RSI-7 Length", group="indicators")-longProfitPerc = input(title="Long Bot Take Profit (%)",- type=input.float, minval=0.0, step=0.05, defval=0.5, group="Long Bot") * 0.01+longProfitPerc = input.float(title="Long Bot Take Profit (%)", minval=0.0, step=0.05, defval=0.5, group="Long Bot") * 0.01-st_long_orders = input(title="Long Bot Step orders (%)",- type=input.float, minval=0.0, step=0.1, defval=2.0, group="Long Bot") * 0.01+st_long_orders = input.float(title="Long Bot Step orders (%)", minval=0.0, step=0.1, defval=2.0, group="Long Bot") * 0.01rsi1_low = input(100, title="RSI-1 <", group="Long Bot")⋯rsi7_low = input(100, title="RSI-7 <", group="Long Bot")-shortProfitPerc = input(title="Short Bot Take Profit (%)",- type=input.float, minval=0.0, step=0.05, defval=0.5, group="Short Bot") * 0.01+shortProfitPerc = input.float(title="Short Bot Take Profit (%)", minval=0.0, step=0.05, defval=0.5, group="Short Bot") * 0.01-st_short_orders = input(title="Short Bot Step orders (%)",- type=input.float, minval=0.0, step=0.1, defval=2.0, group="Short Bot") * 0.01+st_short_orders = input.float(title="Short Bot Step orders (%)", minval=0.0, step=0.1, defval=2.0, group="Short Bot") * 0.01rsi1_up = input(0, title="RSI-1 >", group="Short Bot")⋯//indicators-rsi1 = rsi(src, rsi1_Len)+rsi1 = ta.rsi(src, rsi1_Len)-rsi1_sec = security(syminfo.tickerid, rsi1_res, rsi1)+rsi1_sec = request.security(syminfo.tickerid, rsi1_res, rsi1)-rsi2 = rsi(src, rsi2_Len)+rsi2 = ta.rsi(src, rsi2_Len)-rsi2_sec = security(syminfo.tickerid, rsi2_res, rsi2)+rsi2_sec = request.security(syminfo.tickerid, rsi2_res, rsi2)-rsi3 = rsi(src, rsi3_Len)+rsi3 = ta.rsi(src, rsi3_Len)-rsi3_sec = security(syminfo.tickerid, rsi3_res, rsi3)+rsi3_sec = request.security(syminfo.tickerid, rsi3_res, rsi3)-rsi4 = rsi(src, rsi4_Len)+rsi4 = ta.rsi(src, rsi4_Len)-rsi4_sec = security(syminfo.tickerid, rsi4_res, rsi4)+rsi4_sec = request.security(syminfo.tickerid, rsi4_res, rsi4)-rsi5 = rsi(src, rsi5_Len)+rsi5 = ta.rsi(src, rsi5_Len)-rsi5_sec = security(syminfo.tickerid, rsi5_res, rsi5)+rsi5_sec = request.security(syminfo.tickerid, rsi5_res, rsi5)-rsi6 = rsi(src, rsi6_Len)+rsi6 = ta.rsi(src, rsi6_Len)-rsi6_sec = security(syminfo.tickerid, rsi6_res, rsi6)+rsi6_sec = request.security(syminfo.tickerid, rsi6_res, rsi6)-rsi7 = rsi(src, rsi7_Len)+rsi7 = ta.rsi(src, rsi7_Len)-rsi7_sec = security(syminfo.tickerid, rsi7_res, rsi7)+rsi7_sec = request.security(syminfo.tickerid, rsi7_res, rsi7)//RSI⋯if (strategy.position_size == 0)- strategy.order(id="Long0", long=true, limit=src_bot, when=longOK and Buy)+ strategy.order(id="Long0", direction = strategy.long, limit=src_bot, when=longOK and Buy)- strategy.order(id="Long1", long=true, limit=longEntryPrice1, when=longOK and Buy)+ strategy.order(id="Long1", direction = strategy.long, limit=longEntryPrice1, when=longOK and Buy)- strategy.order(id="Long2", long=true, limit=longEntryPrice2, when=longOK and Buy)+ strategy.order(id="Long2", direction = strategy.long, limit=longEntryPrice2, when=longOK and Buy)- strategy.order(id="Long3", long=true, limit=longEntryPrice3, when=longOK and Buy)+ strategy.order(id="Long3", direction = strategy.long, limit=longEntryPrice3, when=longOK and Buy)- strategy.order(id="Long4", long=true, limit=longEntryPrice4, when=longOK and Buy)+ strategy.order(id="Long4", direction = strategy.long, limit=longEntryPrice4, when=longOK and Buy)- strategy.order(id="Long5", long=true, limit=longEntryPrice5, when=longOK and Buy)+ strategy.order(id="Long5", direction = strategy.long, limit=longEntryPrice5, when=longOK and Buy)- strategy.order(id="Long6", long=true, limit=longEntryPrice6, when=longOK and Buy)+ strategy.order(id="Long6", direction = strategy.long, limit=longEntryPrice6, when=longOK and Buy)- strategy.order(id="Long7", long=true, limit=longEntryPrice7, when=longOK and Buy)+ strategy.order(id="Long7", direction = strategy.long, limit=longEntryPrice7, when=longOK and Buy)- strategy.order(id="Long8", long=true, limit=longEntryPrice8, when=longOK and Buy)+ strategy.order(id="Long8", direction = strategy.long, limit=longEntryPrice8, when=longOK and Buy)- strategy.order(id="Long9", long=true, limit=longEntryPrice9, when=longOK and Buy)+ strategy.order(id="Long9", direction = strategy.long, limit=longEntryPrice9, when=longOK and Buy)- strategy.order(id="Long10", long=true, limit=longEntryPrice10, when=longOK and Buy)+ strategy.order(id="Long10", direction = strategy.long, limit=longEntryPrice10, when=longOK and Buy)- strategy.order(id="Long11", long=true, limit=longEntryPrice11, when=longOK and Buy)+ strategy.order(id="Long11", direction = strategy.long, limit=longEntryPrice11, when=longOK and Buy)- strategy.order(id="Long12", long=true, limit=longEntryPrice12, when=longOK and Buy)+ strategy.order(id="Long12", direction = strategy.long, limit=longEntryPrice12, when=longOK and Buy)- strategy.order(id="Long13", long=true, limit=longEntryPrice13, when=longOK and Buy)+ strategy.order(id="Long13", direction = strategy.long, limit=longEntryPrice13, when=longOK and Buy)- strategy.order(id="Long14", long=true, limit=longEntryPrice14, when=longOK and Buy)+ strategy.order(id="Long14", direction = strategy.long, limit=longEntryPrice14, when=longOK and Buy)- strategy.order(id="Long15", long=true, limit=longEntryPrice15, when=longOK and Buy)+ strategy.order(id="Long15", direction = strategy.long, limit=longEntryPrice15, when=longOK and Buy)- strategy.order(id="Long16", long=true, limit=longEntryPrice16, when=longOK and Buy)+ strategy.order(id="Long16", direction = strategy.long, limit=longEntryPrice16, when=longOK and Buy)- strategy.order(id="Long17", long=true, limit=longEntryPrice17, when=longOK and Buy)+ strategy.order(id="Long17", direction = strategy.long, limit=longEntryPrice17, when=longOK and Buy)- strategy.order(id="Long18", long=true, limit=longEntryPrice18, when=longOK and Buy)+ strategy.order(id="Long18", direction = strategy.long, limit=longEntryPrice18, when=longOK and Buy)- strategy.order(id="Long19", long=true, limit=longEntryPrice19, when=longOK and Buy)+ strategy.order(id="Long19", direction = strategy.long, limit=longEntryPrice19, when=longOK and Buy)if (strategy.position_size == 0)- strategy.order(id="Short0", long=false, limit=src_bot, when=shortOK and Sell)+ strategy.order(id="Short0", direction = strategy.short, limit=src_bot, when=shortOK and Sell)- strategy.order(id="Short1", long=false, limit=shortEntryPrice1, when=shortOK and Sell)+ strategy.order(id="Short1", direction = strategy.short, limit=shortEntryPrice1, when=shortOK and Sell)- strategy.order(id="Short2", long=false, limit=shortEntryPrice2, when=shortOK and Sell)+ strategy.order(id="Short2", direction = strategy.short, limit=shortEntryPrice2, when=shortOK and Sell)- strategy.order(id="Short3", long=false, limit=shortEntryPrice3, when=shortOK and Sell)+ strategy.order(id="Short3", direction = strategy.short, limit=shortEntryPrice3, when=shortOK and Sell)- strategy.order(id="Short4", long=false, limit=shortEntryPrice4, when=shortOK and Sell)+ strategy.order(id="Short4", direction = strategy.short, limit=shortEntryPrice4, when=shortOK and Sell)- strategy.order(id="Short5", long=false, limit=shortEntryPrice5, when=shortOK and Sell)+ strategy.order(id="Short5", direction = strategy.short, limit=shortEntryPrice5, when=shortOK and Sell)- strategy.order(id="Short6", long=false, limit=shortEntryPrice6, when=shortOK and Sell)+ strategy.order(id="Short6", direction = strategy.short, limit=shortEntryPrice6, when=shortOK and Sell)- strategy.order(id="Short7", long=false, limit=shortEntryPrice7, when=shortOK and Sell)+ strategy.order(id="Short7", direction = strategy.short, limit=shortEntryPrice7, when=shortOK and Sell)- strategy.order(id="Short8", long=false, limit=shortEntryPrice8, when=shortOK and Sell)+ strategy.order(id="Short8", direction = strategy.short, limit=shortEntryPrice8, when=shortOK and Sell)- strategy.order(id="Short9", long=false, limit=shortEntryPrice9, when=shortOK and Sell)+ strategy.order(id="Short9", direction = strategy.short, limit=shortEntryPrice9, when=shortOK and Sell)- strategy.order(id="Short10", long=false, limit=shortEntryPrice10, when=shortOK and Sell)+ strategy.order(id="Short10", direction = strategy.short, limit=shortEntryPrice10, when=shortOK and Sell)- strategy.order(id="Short11", long=false, limit=shortEntryPrice11, when=shortOK and Sell)+ strategy.order(id="Short11", direction = strategy.short, limit=shortEntryPrice11, when=shortOK and Sell)- strategy.order(id="Short12", long=false, limit=shortEntryPrice12, when=shortOK and Sell)+ strategy.order(id="Short12", direction = strategy.short, limit=shortEntryPrice12, when=shortOK and Sell)- strategy.order(id="Short13", long=false, limit=shortEntryPrice13, when=shortOK and Sell)+ strategy.order(id="Short13", direction = strategy.short, limit=shortEntryPrice13, when=shortOK and Sell)- strategy.order(id="Short14", long=false, limit=shortEntryPrice14, when=shortOK and Sell)+ strategy.order(id="Short14", direction = strategy.short, limit=shortEntryPrice14, when=shortOK and Sell)- strategy.order(id="Short15", long=false, limit=shortEntryPrice15, when=shortOK and Sell)+ strategy.order(id="Short15", direction = strategy.short, limit=shortEntryPrice15, when=shortOK and Sell)- strategy.order(id="Short16", long=false, limit=shortEntryPrice16, when=shortOK and Sell)+ strategy.order(id="Short16", direction = strategy.short, limit=shortEntryPrice16, when=shortOK and Sell)- strategy.order(id="Short17", long=false, limit=shortEntryPrice17, when=shortOK and Sell)+ strategy.order(id="Short17", direction = strategy.short, limit=shortEntryPrice17, when=shortOK and Sell)- strategy.order(id="Short18", long=false, limit=shortEntryPrice18, when=shortOK and Sell)+ strategy.order(id="Short18", direction = strategy.short, limit=shortEntryPrice18, when=shortOK and Sell)- strategy.order(id="Short19", long=false, limit=shortEntryPrice19, when=shortOK and Sell)+ strategy.order(id="Short19", direction = strategy.short, limit=shortEntryPrice19, when=shortOK and Sell)// exit position based on take profit priceif (strategy.position_size > 0)- strategy.order(id="exit_Long", long=false, limit=longExitPrice, qty=strategy.position_size)+ strategy.order(id="exit_Long", direction = strategy.short, limit=longExitPrice, qty=strategy.position_size)if (strategy.position_size < 0)- strategy.order(id="exit_Short", long=true, limit=shortExitPrice, qty=abs(strategy.position_size))+ strategy.order(id="exit_Short", direction = strategy.long, limit=shortExitPrice, qty=math.abs(strategy.position_size))Clean v5
Not verifiedNeither version placed a trade on any of the 8 markets, so there was nothing to compare.
- Line 13: input() → input.int()
- Line 15: input() → input.int()
- Line 17: input() → input.int()
- Line 19: input() → input.int()
- Line 21: input() → input.int()
- Line 23: input() → input.int()
55 more edits
- Line 25: input() → input.int()
- Line 28: input() → input.int()
- Line 29: input() → input.int()
- Line 30: input() → input.int()
- Line 31: input() → input.int()
- Line 32: input() → input.int()
- Line 33: input() → input.int()
- Line 34: input() → input.int()
- Line 37: input() → input.int()
- Line 38: input() → input.int()
- Line 39: input() → input.int()
- Line 40: input() → input.int()
- Line 41: input() → input.int()
- Line 42: input() → input.int()
- Line 43: input() → input.int()
- Line 131: when = longOK and Buy → if block
- Line 132: when = longOK and Buy → if block
- Line 133: when = longOK and Buy → if block
- Line 134: when = longOK and Buy → if block
- Line 135: when = longOK and Buy → if block
- Line 136: when = longOK and Buy → if block
- Line 137: when = longOK and Buy → if block
- Line 138: when = longOK and Buy → if block
- Line 139: when = longOK and Buy → if block
- Line 140: when = longOK and Buy → if block
- Line 141: when = longOK and Buy → if block
- Line 142: when = longOK and Buy → if block
- Line 143: when = longOK and Buy → if block
- Line 144: when = longOK and Buy → if block
- Line 145: when = longOK and Buy → if block
- Line 146: when = longOK and Buy → if block
- Line 147: when = longOK and Buy → if block
- Line 148: when = longOK and Buy → if block
- Line 149: when = longOK and Buy → if block
- Line 150: when = longOK and Buy → if block
- Line 152: when = shortOK and Sell → if block
- Line 153: when = shortOK and Sell → if block
- Line 154: when = shortOK and Sell → if block
- Line 155: when = shortOK and Sell → if block
- Line 156: when = shortOK and Sell → if block
- Line 157: when = shortOK and Sell → if block
- Line 158: when = shortOK and Sell → if block
- Line 159: when = shortOK and Sell → if block
- Line 160: when = shortOK and Sell → if block
- Line 161: when = shortOK and Sell → if block
- Line 162: when = shortOK and Sell → if block
- Line 163: when = shortOK and Sell → if block
- Line 164: when = shortOK and Sell → if block
- Line 165: when = shortOK and Sell → if block
- Line 166: when = shortOK and Sell → if block
- Line 167: when = shortOK and Sell → if block
- Line 168: when = shortOK and Sell → if block
- Line 169: when = shortOK and Sell → if block
- Line 170: when = shortOK and Sell → if block
- Line 171: when = shortOK and Sell → if block
⋯rsi1_res = input.timeframe(title="RSI-1 period", defval="1", group="indicators")-rsi1_Len = input(14, minval=1, title="RSI-1 Length", group="indicators")+rsi1_Len = input.int(14, minval=1, title="RSI-1 Length", group="indicators")rsi2_res = input.timeframe(title="RSI-2 period", defval="5", group="indicators")-rsi2_Len = input(14, minval=1, title="RSI-2 Length", group="indicators")+rsi2_Len = input.int(14, minval=1, title="RSI-2 Length", group="indicators")rsi3_res = input.timeframe(title="RSI-3 period", defval="15", group="indicators")-rsi3_Len = input(14, minval=1, title="RSI-3 Length", group="indicators")+rsi3_Len = input.int(14, minval=1, title="RSI-3 Length", group="indicators")rsi4_res = input.timeframe(title="RSI-4 period", defval="30", group="indicators")-rsi4_Len = input(14, minval=1, title="RSI-4 Length", group="indicators")+rsi4_Len = input.int(14, minval=1, title="RSI-4 Length", group="indicators")rsi5_res = input.timeframe(title="RSI-5 period", defval="60", group="indicators")-rsi5_Len = input(14, minval=1, title="RSI-5 Length", group="indicators")+rsi5_Len = input.int(14, minval=1, title="RSI-5 Length", group="indicators")rsi6_res = input.timeframe(title="RSI-6 period", defval="120", group="indicators")-rsi6_Len = input(14, minval=1, title="RSI-6 Length", group="indicators")+rsi6_Len = input.int(14, minval=1, title="RSI-6 Length", group="indicators")rsi7_res = input.timeframe(title="RSI-7 period", defval="1D", group="indicators")-rsi7_Len = input(14, minval=1, title="RSI-7 Length", group="indicators")+rsi7_Len = input.int(14, minval=1, title="RSI-7 Length", group="indicators")longProfitPerc = input.float(title="Long Bot Take Profit (%)", minval=0.0, step=0.05, defval=0.5, group="Long Bot") * 0.01st_long_orders = input.float(title="Long Bot Step orders (%)", minval=0.0, step=0.1, defval=2.0, group="Long Bot") * 0.01-rsi1_low = input(100, title="RSI-1 <", group="Long Bot")+rsi1_low = input.int(100, title="RSI-1 <", group="Long Bot")-rsi2_low = input(100, title="RSI-2 <", group="Long Bot")+rsi2_low = input.int(100, title="RSI-2 <", group="Long Bot")-rsi3_low = input(100, title="RSI-3 <", group="Long Bot")+rsi3_low = input.int(100, title="RSI-3 <", group="Long Bot")-rsi4_low = input(100, title="RSI-4 <", group="Long Bot")+rsi4_low = input.int(100, title="RSI-4 <", group="Long Bot")-rsi5_low = input(100, title="RSI-5 <", group="Long Bot")+rsi5_low = input.int(100, title="RSI-5 <", group="Long Bot")-rsi6_low = input(100, title="RSI-6 <", group="Long Bot")+rsi6_low = input.int(100, title="RSI-6 <", group="Long Bot")-rsi7_low = input(100, title="RSI-7 <", group="Long Bot")+rsi7_low = input.int(100, title="RSI-7 <", group="Long Bot")shortProfitPerc = input.float(title="Short Bot Take Profit (%)", minval=0.0, step=0.05, defval=0.5, group="Short Bot") * 0.01st_short_orders = input.float(title="Short Bot Step orders (%)", minval=0.0, step=0.1, defval=2.0, group="Short Bot") * 0.01-rsi1_up = input(0, title="RSI-1 >", group="Short Bot")+rsi1_up = input.int(0, title="RSI-1 >", group="Short Bot")-rsi2_up = input(0, title="RSI-2 >", group="Short Bot")+rsi2_up = input.int(0, title="RSI-2 >", group="Short Bot")-rsi3_up = input(0, title="RSI-3 >", group="Short Bot")+rsi3_up = input.int(0, title="RSI-3 >", group="Short Bot")-rsi4_up = input(0, title="RSI-4 >", group="Short Bot")+rsi4_up = input.int(0, title="RSI-4 >", group="Short Bot")-rsi5_up = input(0, title="RSI-5 >", group="Short Bot")+rsi5_up = input.int(0, title="RSI-5 >", group="Short Bot")-rsi6_up = input(0, title="RSI-6 >", group="Short Bot")+rsi6_up = input.int(0, title="RSI-6 >", group="Short Bot")-rsi7_up = input(0, title="RSI-7 >", group="Short Bot")+rsi7_up = input.int(0, title="RSI-7 >", group="Short Bot")//indicators⋯if (strategy.position_size == 0)- strategy.order(id="Long0", direction = strategy.long, limit=src_bot, when=longOK and Buy)+ if longOK and Buy+ strategy.order(id="Long0", direction = strategy.long, limit=src_bot)- strategy.order(id="Long1", direction = strategy.long, limit=longEntryPrice1, when=longOK and Buy)+ if longOK and Buy+ strategy.order(id="Long1", direction = strategy.long, limit=longEntryPrice1)- strategy.order(id="Long2", direction = strategy.long, limit=longEntryPrice2, when=longOK and Buy)+ if longOK and Buy+ strategy.order(id="Long2", direction = strategy.long, limit=longEntryPrice2)- strategy.order(id="Long3", direction = strategy.long, limit=longEntryPrice3, when=longOK and Buy)+ if longOK and Buy+ strategy.order(id="Long3", direction = strategy.long, limit=longEntryPrice3)- strategy.order(id="Long4", direction = strategy.long, limit=longEntryPrice4, when=longOK and Buy)+ if longOK and Buy+ strategy.order(id="Long4", direction = strategy.long, limit=longEntryPrice4)- strategy.order(id="Long5", direction = strategy.long, limit=longEntryPrice5, when=longOK and Buy)+ if longOK and Buy+ strategy.order(id="Long5", direction = strategy.long, limit=longEntryPrice5)- strategy.order(id="Long6", direction = strategy.long, limit=longEntryPrice6, when=longOK and Buy)+ if longOK and Buy+ strategy.order(id="Long6", direction = strategy.long, limit=longEntryPrice6)- strategy.order(id="Long7", direction = strategy.long, limit=longEntryPrice7, when=longOK and Buy)+ if longOK and Buy+ strategy.order(id="Long7", direction = strategy.long, limit=longEntryPrice7)- strategy.order(id="Long8", direction = strategy.long, limit=longEntryPrice8, when=longOK and Buy)+ if longOK and Buy+ strategy.order(id="Long8", direction = strategy.long, limit=longEntryPrice8)- strategy.order(id="Long9", direction = strategy.long, limit=longEntryPrice9, when=longOK and Buy)+ if longOK and Buy+ strategy.order(id="Long9", direction = strategy.long, limit=longEntryPrice9)- strategy.order(id="Long10", direction = strategy.long, limit=longEntryPrice10, when=longOK and Buy)+ if longOK and Buy+ strategy.order(id="Long10", direction = strategy.long, limit=longEntryPrice10)- strategy.order(id="Long11", direction = strategy.long, limit=longEntryPrice11, when=longOK and Buy)+ if longOK and Buy+ strategy.order(id="Long11", direction = strategy.long, limit=longEntryPrice11)- strategy.order(id="Long12", direction = strategy.long, limit=longEntryPrice12, when=longOK and Buy)+ if longOK and Buy+ strategy.order(id="Long12", direction = strategy.long, limit=longEntryPrice12)- strategy.order(id="Long13", direction = strategy.long, limit=longEntryPrice13, when=longOK and Buy)+ if longOK and Buy+ strategy.order(id="Long13", direction = strategy.long, limit=longEntryPrice13)- strategy.order(id="Long14", direction = strategy.long, limit=longEntryPrice14, when=longOK and Buy)+ if longOK and Buy+ strategy.order(id="Long14", direction = strategy.long, limit=longEntryPrice14)- strategy.order(id="Long15", direction = strategy.long, limit=longEntryPrice15, when=longOK and Buy)+ if longOK and Buy+ strategy.order(id="Long15", direction = strategy.long, limit=longEntryPrice15)- strategy.order(id="Long16", direction = strategy.long, limit=longEntryPrice16, when=longOK and Buy)+ if longOK and Buy+ strategy.order(id="Long16", direction = strategy.long, limit=longEntryPrice16)- strategy.order(id="Long17", direction = strategy.long, limit=longEntryPrice17, when=longOK and Buy)+ if longOK and Buy+ strategy.order(id="Long17", direction = strategy.long, limit=longEntryPrice17)- strategy.order(id="Long18", direction = strategy.long, limit=longEntryPrice18, when=longOK and Buy)+ if longOK and Buy+ strategy.order(id="Long18", direction = strategy.long, limit=longEntryPrice18)- strategy.order(id="Long19", direction = strategy.long, limit=longEntryPrice19, when=longOK and Buy)+ if longOK and Buy+ strategy.order(id="Long19", direction = strategy.long, limit=longEntryPrice19)if (strategy.position_size == 0)- strategy.order(id="Short0", direction = strategy.short, limit=src_bot, when=shortOK and Sell)+ if shortOK and Sell+ strategy.order(id="Short0", direction = strategy.short, limit=src_bot)- strategy.order(id="Short1", direction = strategy.short, limit=shortEntryPrice1, when=shortOK and Sell)+ if shortOK and Sell+ strategy.order(id="Short1", direction = strategy.short, limit=shortEntryPrice1)- strategy.order(id="Short2", direction = strategy.short, limit=shortEntryPrice2, when=shortOK and Sell)+ if shortOK and Sell+ strategy.order(id="Short2", direction = strategy.short, limit=shortEntryPrice2)- strategy.order(id="Short3", direction = strategy.short, limit=shortEntryPrice3, when=shortOK and Sell)+ if shortOK and Sell+ strategy.order(id="Short3", direction = strategy.short, limit=shortEntryPrice3)- strategy.order(id="Short4", direction = strategy.short, limit=shortEntryPrice4, when=shortOK and Sell)+ if shortOK and Sell+ strategy.order(id="Short4", direction = strategy.short, limit=shortEntryPrice4)- strategy.order(id="Short5", direction = strategy.short, limit=shortEntryPrice5, when=shortOK and Sell)+ if shortOK and Sell+ strategy.order(id="Short5", direction = strategy.short, limit=shortEntryPrice5)- strategy.order(id="Short6", direction = strategy.short, limit=shortEntryPrice6, when=shortOK and Sell)+ if shortOK and Sell+ strategy.order(id="Short6", direction = strategy.short, limit=shortEntryPrice6)- strategy.order(id="Short7", direction = strategy.short, limit=shortEntryPrice7, when=shortOK and Sell)+ if shortOK and Sell+ strategy.order(id="Short7", direction = strategy.short, limit=shortEntryPrice7)- strategy.order(id="Short8", direction = strategy.short, limit=shortEntryPrice8, when=shortOK and Sell)+ if shortOK and Sell+ strategy.order(id="Short8", direction = strategy.short, limit=shortEntryPrice8)- strategy.order(id="Short9", direction = strategy.short, limit=shortEntryPrice9, when=shortOK and Sell)+ if shortOK and Sell+ strategy.order(id="Short9", direction = strategy.short, limit=shortEntryPrice9)- strategy.order(id="Short10", direction = strategy.short, limit=shortEntryPrice10, when=shortOK and Sell)+ if shortOK and Sell+ strategy.order(id="Short10", direction = strategy.short, limit=shortEntryPrice10)- strategy.order(id="Short11", direction = strategy.short, limit=shortEntryPrice11, when=shortOK and Sell)+ if shortOK and Sell+ strategy.order(id="Short11", direction = strategy.short, limit=shortEntryPrice11)- strategy.order(id="Short12", direction = strategy.short, limit=shortEntryPrice12, when=shortOK and Sell)+ if shortOK and Sell+ strategy.order(id="Short12", direction = strategy.short, limit=shortEntryPrice12)- strategy.order(id="Short13", direction = strategy.short, limit=shortEntryPrice13, when=shortOK and Sell)+ if shortOK and Sell+ strategy.order(id="Short13", direction = strategy.short, limit=shortEntryPrice13)- strategy.order(id="Short14", direction = strategy.short, limit=shortEntryPrice14, when=shortOK and Sell)+ if shortOK and Sell+ strategy.order(id="Short14", direction = strategy.short, limit=shortEntryPrice14)- strategy.order(id="Short15", direction = strategy.short, limit=shortEntryPrice15, when=shortOK and Sell)+ if shortOK and Sell+ strategy.order(id="Short15", direction = strategy.short, limit=shortEntryPrice15)- strategy.order(id="Short16", direction = strategy.short, limit=shortEntryPrice16, when=shortOK and Sell)+ if shortOK and Sell+ strategy.order(id="Short16", direction = strategy.short, limit=shortEntryPrice16)- strategy.order(id="Short17", direction = strategy.short, limit=shortEntryPrice17, when=shortOK and Sell)+ if shortOK and Sell+ strategy.order(id="Short17", direction = strategy.short, limit=shortEntryPrice17)- strategy.order(id="Short18", direction = strategy.short, limit=shortEntryPrice18, when=shortOK and Sell)+ if shortOK and Sell+ strategy.order(id="Short18", direction = strategy.short, limit=shortEntryPrice18)- strategy.order(id="Short19", direction = strategy.short, limit=shortEntryPrice19, when=shortOK and Sell)+ if shortOK and Sell+ strategy.order(id="Short19", direction = strategy.short, limit=shortEntryPrice19)// exit position based on take profit price⋯Does it run in Pine Script v6?
Not tested
Neither version placed a trade on any of the 8 markets, so there was nothing to compare. The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.
⋯// © rrolik66-//@version=5+//@version=6strategy(title="7-RSI strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=5, currency=currency.USD)⋯Settings
Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| Source RSI | close | source | rsi1 rsi2 rsi3 rsi4 rsi5 rsi6 rsi7 |
| Bot period | 1 | timeframe (written input.resolution) | src_bot |
| Source Bot | ohlc4 | source | src_bot |
| Trade Direction | Long Bot | string · options ["Long Bot", "Short Bot"] | longOK shortOK |
| indicators | |||
| RSI-1 period | 1 | timeframe (written input.resolution) | rsi1_sec |
| RSI-1 Length | 14 | int · min 1 | rsi1 |
| RSI-2 period | 5 | timeframe (written input.resolution) | rsi2_sec |
| RSI-2 Length | 14 | int · min 1 | rsi2 |
| RSI-3 period | 15 | timeframe (written input.resolution) | rsi3_sec |
| RSI-3 Length | 14 | int · min 1 | rsi3 |
| RSI-4 period | 30 | timeframe (written input.resolution) | rsi4_sec |
| RSI-4 Length | 14 | int · min 1 | rsi4 |
| RSI-5 period | 60 | timeframe (written input.resolution) | rsi5_sec |
| RSI-5 Length | 14 | int · min 1 | rsi5 |
| RSI-6 period | 120 | timeframe (written input.resolution) | rsi6_sec |
| RSI-6 Length | 14 | int · min 1 | rsi6 |
| RSI-7 period | 1D | timeframe (written input.resolution) | rsi7_sec |
| RSI-7 Length | 14 | int · min 1 | rsi7 |
| Long Bot | |||
| Long Bot Take Profit (%) | 0.5 | float · min 0.0 · step 0.05 | longExitPrice |
| Long Bot Step orders (%) | 2.0 | float · min 0.0 · step 0.1 | longEntryPrice1 longEntryPrice2 longEntryPrice3 longEntryPrice4 longEntryPrice5 longEntryPrice6 longEntryPrice7 longEntryPrice8 longEntryPrice9 longEntryPrice10 longEntryPrice11 longEntryPrice12 longEntryPrice13 longEntryPrice14 longEntryPrice15 longEntryPrice16 longEntryPrice17 longEntryPrice18 longEntryPrice19 |
| RSI-1 < | 100 | int | rsi1_low_signal |
| RSI-2 < | 100 | int | rsi2_low_signal |
| RSI-3 < | 100 | int | rsi3_low_signal |
| RSI-4 < | 100 | int | rsi4_low_signal |
| RSI-5 < | 100 | int | rsi5_low_signal |
| RSI-6 < | 100 | int | rsi6_low_signal |
| RSI-7 < | 100 | int | rsi7_low_signal |
| Short Bot | |||
| Short Bot Take Profit (%) | 0.5 | float · min 0.0 · step 0.05 | shortExitPrice |
| Short Bot Step orders (%) | 2.0 | float · min 0.0 · step 0.1 | shortEntryPrice1 shortEntryPrice2 shortEntryPrice3 shortEntryPrice4 shortEntryPrice5 shortEntryPrice6 shortEntryPrice7 shortEntryPrice8 shortEntryPrice9 shortEntryPrice10 shortEntryPrice11 shortEntryPrice12 shortEntryPrice13 shortEntryPrice14 shortEntryPrice15 shortEntryPrice16 shortEntryPrice17 shortEntryPrice18 shortEntryPrice19 |
| RSI-1 > | 0 | int | rsi1_up_signal |
| RSI-2 > | 0 | int | rsi2_up_signal |
| RSI-3 > | 0 | int | rsi3_up_signal |
| RSI-4 > | 0 | int | rsi4_up_signal |
| RSI-5 > | 0 | int | rsi5_up_signal |
| RSI-6 > | 0 | int | rsi6_up_signal |
| RSI-7 > | 0 | int | rsi7_up_signal |
What it calculates
- RSI (
rsi,ta.rsiin v5)Source RSI (close), RSI-1 Length (14)rsi1 · line 49 - RSI (
rsi,ta.rsiin v5)Source RSI (close), RSI-2 Length (14)rsi2 · line 51 - RSI (
rsi,ta.rsiin v5)Source RSI (close), RSI-3 Length (14)rsi3 · line 53 - RSI (
rsi,ta.rsiin v5)Source RSI (close), RSI-4 Length (14)rsi4 · line 55 - RSI (
rsi,ta.rsiin v5)Source RSI (close), RSI-5 Length (14)rsi5 · line 57 - RSI (
rsi,ta.rsiin v5)Source RSI (close), RSI-6 Length (14)rsi6 · line 59 - RSI (
rsi,ta.rsiin v5)Source RSI (close), RSI-7 Length (14)rsi7 · line 61
Signal flow
How price data and settings reach the orders. Each box is a name in the script, or several computed the same way; each arrow is a value one of them reads. Hover a box for its members.
The script has 116 named inputs, calculations, conditions and outputs, too many to draw legibly here; the tables above list them.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| order Long0 long | longOK and Buy | On | 135 |
| order Long1 long | longOK and Buy | On | 136 |
| order Long2 long | longOK and Buy | On | 137 |
| order Long3 long | longOK and Buy | On | 138 |
| order Long4 long | longOK and Buy | On | 139 |
| order Long5 long | longOK and Buy | On | 140 |
| order Long6 long | longOK and Buy | On | 141 |
| order Long7 long | longOK and Buy | On | 142 |
| order Long8 long | longOK and Buy | On | 143 |
| order Long9 long | longOK and Buy | On | 144 |
| order Long10 long | longOK and Buy | On | 145 |
| order Long11 long | longOK and Buy | On | 146 |
| order Long12 long | longOK and Buy | On | 147 |
| order Long13 long | longOK and Buy | On | 148 |
| order Long14 long | longOK and Buy | On | 149 |
| order Long15 long | longOK and Buy | On | 150 |
| order Long16 long | longOK and Buy | On | 151 |
| order Long17 long | longOK and Buy | On | 152 |
| order Long18 long | longOK and Buy | On | 153 |
| order Long19 long | longOK and Buy | On | 154 |
| order Short0 short | shortOK and Sell | On | 156 |
| order Short1 short | shortOK and Sell | On | 157 |
| order Short2 short | shortOK and Sell | On | 158 |
| order Short3 short | shortOK and Sell | On | 159 |
| order Short4 short | shortOK and Sell | On | 160 |
| order Short5 short | shortOK and Sell | On | 161 |
| order Short6 short | shortOK and Sell | On | 162 |
| order Short7 short | shortOK and Sell | On | 163 |
| order Short8 short | shortOK and Sell | On | 164 |
| order Short9 short | shortOK and Sell | On | 165 |
| order Short10 short | shortOK and Sell | On | 166 |
| order Short11 short | shortOK and Sell | On | 167 |
| order Short12 short | shortOK and Sell | On | 168 |
| order Short13 short | shortOK and Sell | On | 169 |
| order Short14 short | shortOK and Sell | On | 170 |
| order Short15 short | shortOK and Sell | On | 171 |
| order Short16 short | shortOK and Sell | On | 172 |
| order Short17 short | shortOK and Sell | On | 173 |
| order Short18 short | shortOK and Sell | On | 174 |
| order Short19 short | shortOK and Sell | On | 175 |
| order exit_Long short | (strategy.position_size > 0) | On | 178 |
| order exit_Short long | (strategy.position_size < 0) | On | 180 |
Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.
Does it repaint?
No
No repainting patterns in the source.
- ClearHigher-timeframe data8 security call(s), none with lookahead on.
- ClearFuture-bar referencesNo negative history offsets such as close[-1].
- ClearIntrabar recalculationNo varip, calc_on_every_tick or realtime-only state. Orders are decided once per closed bar.
- ClearOrder timingOrders fill at the next bar's open, after the signal bar has closed.
The checks read the source; the replay runs it. Together they catch the common causes, not every possible one.
Other markets
Not run on other markets: the script requests BINANCE:BTCUSDT 1, BINANCE:BTCUSDT 5, BINANCE:BTCUSDT 15, BINANCE:BTCUSDT 30, BINANCE:BTCUSDT 60, BINANCE:BTCUSDT 120, and that data is not available here (a lower timeframe than the chart; the engine does not evaluate intrabar data; a lower timeframe than the chart; the engine does not evaluate intrabar data; a lower timeframe than the chart; the engine does not evaluate intrabar data; a lower timeframe than the chart; the engine does not evaluate intrabar data; a lower timeframe than the chart; the engine does not evaluate intrabar data; a lower timeframe than the chart; the engine does not evaluate intrabar data). Its results would rest on empty values.
Similar scripts
Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| 7-RSI strategy this page | — | v4 strategy | 0.0% | 0 | 0.0% |
| Triple RSI strategy by Trade_by_DB | rsi | v5 strategy | +3.2% | 2 | 3.3% |
| Hobbiecode - RSI + Close previous day by hobbiecode | rsi | v5 strategy | +1.2% | 63 | 4.2% |
| dirt cheap yet elegant RSI Strategy by SparkyFlary | rsi | v4 strategy | −11.4% | 8 | 20.5% |
| RSI Classic Strategy (by Coinrule) by Coinrule | rsi | v4 strategy | +7.5% | 6 | 7.2% |
| RSITrendStrategy by email_analysts | rsi | v4 strategy | +69.2% | 22 | 38.6% |
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 54 ms | With a workaround 1,000 bars in 152 ms | Not measured |
| PineTS | No v5 and v6 only | — | Not measured |
Zeal Terminal's engine currently reads an order side written as long = true, long = false as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 135, 136, 137, 138, 139, 140 and more) so the engine trades the way the script says. The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market.
“Matches TradingView” needs this script's own output exported from TradingView and compared bar by bar, which has not been done for this script. The engine is built on OpenPineScript, whose conformance results are in its conformance report. PineTS runs Pine Script v5 and v6 only.
Source
Copied verbatim from the author's published script, with its licence header intact. The author may have updated the original since this snapshot.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © rrolik66//@version=4strategy(title="7-RSI strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=5, currency=currency.USD)// inputssrc = input(close, "Source RSI", type = input.source)bot_res = input(title="Bot period", type=input.resolution, defval="1")srcin_bot = input(ohlc4, "Source Bot", type = input.source)src_bot = security(syminfo.tickerid, bot_res, srcin_bot)tradeDirection = input(title="Trade Direction", type=input.string, options=["Long Bot", "Short Bot"], defval="Long Bot")rsi1_res = input(title="RSI-1 period", type=input.resolution, defval="1", group="indicators")rsi1_Len = input(14, minval=1, title="RSI-1 Length", group="indicators")rsi2_res = input(title="RSI-2 period", type=input.resolution, defval="5", group="indicators")rsi2_Len = input(14, minval=1, title="RSI-2 Length", group="indicators")rsi3_res = input(title="RSI-3 period", type=input.resolution, defval="15", group="indicators")rsi3_Len = input(14, minval=1, title="RSI-3 Length", group="indicators")rsi4_res = input(title="RSI-4 period", type=input.resolution, defval="30", group="indicators")rsi4_Len = input(14, minval=1, title="RSI-4 Length", group="indicators")rsi5_res = input(title="RSI-5 period", type=input.resolution, defval="60", group="indicators")rsi5_Len = input(14, minval=1, title="RSI-5 Length", group="indicators")rsi6_res = input(title="RSI-6 period", type=input.resolution, defval="120", group="indicators")rsi6_Len = input(14, minval=1, title="RSI-6 Length", group="indicators")rsi7_res = input(title="RSI-7 period", type=input.resolution, defval="1D", group="indicators")rsi7_Len = input(14, minval=1, title="RSI-7 Length", group="indicators")longProfitPerc = input(title="Long Bot Take Profit (%)", type=input.float, minval=0.0, step=0.05, defval=0.5, group="Long Bot") * 0.01st_long_orders = input(title="Long Bot Step orders (%)", type=input.float, minval=0.0, step=0.1, defval=2.0, group="Long Bot") * 0.01rsi1_low = input(100, title="RSI-1 <", group="Long Bot")rsi2_low = input(100, title="RSI-2 <", group="Long Bot")rsi3_low = input(100, title="RSI-3 <", group="Long Bot")rsi4_low = input(100, title="RSI-4 <", group="Long Bot")rsi5_low = input(100, title="RSI-5 <", group="Long Bot")rsi6_low = input(100, title="RSI-6 <", group="Long Bot")rsi7_low = input(100, title="RSI-7 <", group="Long Bot")shortProfitPerc = input(title="Short Bot Take Profit (%)", type=input.float, minval=0.0, step=0.05, defval=0.5, group="Short Bot") * 0.01st_short_orders = input(title="Short Bot Step orders (%)", type=input.float, minval=0.0, step=0.1, defval=2.0, group="Short Bot") * 0.01rsi1_up = input(0, title="RSI-1 >", group="Short Bot")rsi2_up = input(0, title="RSI-2 >", group="Short Bot")rsi3_up = input(0, title="RSI-3 >", group="Short Bot")rsi4_up = input(0, title="RSI-4 >", group="Short Bot")rsi5_up = input(0, title="RSI-5 >", group="Short Bot")rsi6_up = input(0, title="RSI-6 >", group="Short Bot")rsi7_up = input(0, title="RSI-7 >", group="Short Bot")//indicatorsrsi1 = rsi(src, rsi1_Len)rsi1_sec = security(syminfo.tickerid, rsi1_res, rsi1)rsi2 = rsi(src, rsi2_Len)rsi2_sec = security(syminfo.tickerid, rsi2_res, rsi2)rsi3 = rsi(src, rsi3_Len)rsi3_sec = security(syminfo.tickerid, rsi3_res, rsi3)rsi4 = rsi(src, rsi4_Len)rsi4_sec = security(syminfo.tickerid, rsi4_res, rsi4)rsi5 = rsi(src, rsi5_Len)rsi5_sec = security(syminfo.tickerid, rsi5_res, rsi5)rsi6 = rsi(src, rsi6_Len)rsi6_sec = security(syminfo.tickerid, rsi6_res, rsi6)rsi7 = rsi(src, rsi7_Len)rsi7_sec = security(syminfo.tickerid, rsi7_res, rsi7)//RSIrsi1_up_signal = rsi1_sec > rsi1_uprsi1_low_signal = rsi1_sec < rsi1_lowrsi2_up_signal = rsi2_sec > rsi2_uprsi2_low_signal = rsi2_sec < rsi2_lowrsi3_up_signal = rsi3_sec > rsi3_uprsi3_low_signal = rsi3_sec < rsi3_lowrsi4_up_signal = rsi4_sec > rsi4_uprsi4_low_signal = rsi4_sec < rsi4_lowrsi5_up_signal = rsi5_sec > rsi5_uprsi5_low_signal = rsi5_sec < rsi5_lowrsi6_up_signal = rsi6_sec > rsi6_uprsi6_low_signal = rsi6_sec < rsi6_lowrsi7_up_signal = rsi7_sec > rsi7_uprsi7_low_signal = rsi7_sec < rsi7_low//Buy & SellBuy = rsi1_low_signal and rsi2_low_signal and rsi3_low_signal and rsi4_low_signal and rsi5_low_signal and rsi6_low_signal and rsi7_low_signalSell = rsi1_up_signal and rsi2_up_signal and rsi3_up_signal and rsi4_up_signal and rsi5_up_signal and rsi6_up_signal and rsi7_up_signal// input into trading conditionslongOK = (tradeDirection == "Long Bot")shortOK = (tradeDirection == "Short Bot")// in entry orders pricelongEntryPrice1 = src_bot * (1 - (st_long_orders))longEntryPrice2 = src_bot * (1 - (st_long_orders*2))longEntryPrice3 = src_bot * (1 - (st_long_orders*3))longEntryPrice4 = src_bot * (1 - (st_long_orders*4))longEntryPrice5 = src_bot * (1 - (st_long_orders*5))longEntryPrice6 = src_bot * (1 - (st_long_orders*6))longEntryPrice7 = src_bot * (1 - (st_long_orders*7))longEntryPrice8 = src_bot * (1 - (st_long_orders*8))longEntryPrice9 = src_bot * (1 - (st_long_orders*9))longEntryPrice10 = src_bot * (1 - (st_long_orders*10))longEntryPrice11 = src_bot * (1 - (st_long_orders*11))longEntryPrice12 = src_bot * (1 - (st_long_orders*12))longEntryPrice13 = src_bot * (1 - (st_long_orders*13))longEntryPrice14 = src_bot * (1 - (st_long_orders*14))longEntryPrice15 = src_bot * (1 - (st_long_orders*15))longEntryPrice16 = src_bot * (1 - (st_long_orders*16))longEntryPrice17 = src_bot * (1 - (st_long_orders*17))longEntryPrice18 = src_bot * (1 - (st_long_orders*18))longEntryPrice19 = src_bot * (1 - (st_long_orders*19))shortEntryPrice1 = src_bot * (1 + st_short_orders)shortEntryPrice2 = src_bot * (1 + (st_short_orders*2))shortEntryPrice3 = src_bot * (1 + (st_short_orders*3))shortEntryPrice4 = src_bot * (1 + (st_short_orders*4))shortEntryPrice5 = src_bot * (1 + (st_short_orders*5))shortEntryPrice6 = src_bot * (1 + (st_short_orders*6))shortEntryPrice7 = src_bot * (1 + (st_short_orders*7))shortEntryPrice8 = src_bot * (1 + (st_short_orders*8))shortEntryPrice9 = src_bot * (1 + (st_short_orders*9))shortEntryPrice10 = src_bot * (1 + (st_short_orders*10))shortEntryPrice11 = src_bot * (1 + (st_short_orders*11))shortEntryPrice12 = src_bot * (1 + (st_short_orders*12))shortEntryPrice13 = src_bot * (1 + (st_short_orders*13))shortEntryPrice14 = src_bot * (1 + (st_short_orders*14))shortEntryPrice15 = src_bot * (1 + (st_short_orders*15))shortEntryPrice16 = src_bot * (1 + (st_short_orders*16))shortEntryPrice17 = src_bot * (1 + (st_short_orders*17))shortEntryPrice18 = src_bot * (1 + (st_short_orders*18))shortEntryPrice19 = src_bot * (1 + (st_short_orders*19))// take profit pricelongExitPrice = strategy.position_avg_price * (1 + longProfitPerc)shortExitPrice = strategy.position_avg_price * (1 - shortProfitPerc)// take profit values for confirmationplot(series=(strategy.position_size > 0) ? longExitPrice : na, color=color.green, style=plot.style_circles, linewidth=3, title="Long Take Profit")plot(series=(strategy.position_size < 0) ? shortExitPrice : na, color=color.red, style=plot.style_circles, linewidth=3, title="Short Take Profit")// entry ordersif (strategy.position_size == 0) strategy.order(id="Long0", long=true, limit=src_bot, when=longOK and Buy) strategy.order(id="Long1", long=true, limit=longEntryPrice1, when=longOK and Buy) strategy.order(id="Long2", long=true, limit=longEntryPrice2, when=longOK and Buy) strategy.order(id="Long3", long=true, limit=longEntryPrice3, when=longOK and Buy) strategy.order(id="Long4", long=true, limit=longEntryPrice4, when=longOK and Buy) strategy.order(id="Long5", long=true, limit=longEntryPrice5, when=longOK and Buy) strategy.order(id="Long6", long=true, limit=longEntryPrice6, when=longOK and Buy) strategy.order(id="Long7", long=true, limit=longEntryPrice7, when=longOK and Buy) strategy.order(id="Long8", long=true, limit=longEntryPrice8, when=longOK and Buy) strategy.order(id="Long9", long=true, limit=longEntryPrice9, when=longOK and Buy) strategy.order(id="Long10", long=true, limit=longEntryPrice10, when=longOK and Buy) strategy.order(id="Long11", long=true, limit=longEntryPrice11, when=longOK and Buy) strategy.order(id="Long12", long=true, limit=longEntryPrice12, when=longOK and Buy) strategy.order(id="Long13", long=true, limit=longEntryPrice13, when=longOK and Buy) strategy.order(id="Long14", long=true, limit=longEntryPrice14, when=longOK and Buy) strategy.order(id="Long15", long=true, limit=longEntryPrice15, when=longOK and Buy) strategy.order(id="Long16", long=true, limit=longEntryPrice16, when=longOK and Buy) strategy.order(id="Long17", long=true, limit=longEntryPrice17, when=longOK and Buy) strategy.order(id="Long18", long=true, limit=longEntryPrice18, when=longOK and Buy) strategy.order(id="Long19", long=true, limit=longEntryPrice19, when=longOK and Buy)if (strategy.position_size == 0) strategy.order(id="Short0", long=false, limit=src_bot, when=shortOK and Sell) strategy.order(id="Short1", long=false, limit=shortEntryPrice1, when=shortOK and Sell) strategy.order(id="Short2", long=false, limit=shortEntryPrice2, when=shortOK and Sell) strategy.order(id="Short3", long=false, limit=shortEntryPrice3, when=shortOK and Sell) strategy.order(id="Short4", long=false, limit=shortEntryPrice4, when=shortOK and Sell) strategy.order(id="Short5", long=false, limit=shortEntryPrice5, when=shortOK and Sell) strategy.order(id="Short6", long=false, limit=shortEntryPrice6, when=shortOK and Sell) strategy.order(id="Short7", long=false, limit=shortEntryPrice7, when=shortOK and Sell) strategy.order(id="Short8", long=false, limit=shortEntryPrice8, when=shortOK and Sell) strategy.order(id="Short9", long=false, limit=shortEntryPrice9, when=shortOK and Sell) strategy.order(id="Short10", long=false, limit=shortEntryPrice10, when=shortOK and Sell) strategy.order(id="Short11", long=false, limit=shortEntryPrice11, when=shortOK and Sell) strategy.order(id="Short12", long=false, limit=shortEntryPrice12, when=shortOK and Sell) strategy.order(id="Short13", long=false, limit=shortEntryPrice13, when=shortOK and Sell) strategy.order(id="Short14", long=false, limit=shortEntryPrice14, when=shortOK and Sell) strategy.order(id="Short15", long=false, limit=shortEntryPrice15, when=shortOK and Sell) strategy.order(id="Short16", long=false, limit=shortEntryPrice16, when=shortOK and Sell) strategy.order(id="Short17", long=false, limit=shortEntryPrice17, when=shortOK and Sell) strategy.order(id="Short18", long=false, limit=shortEntryPrice18, when=shortOK and Sell) strategy.order(id="Short19", long=false, limit=shortEntryPrice19, when=shortOK and Sell)// exit position based on take profit priceif (strategy.position_size > 0) strategy.order(id="exit_Long", long=false, limit=longExitPrice, qty=strategy.position_size)if (strategy.position_size < 0) strategy.order(id="exit_Short", long=true, limit=shortExitPrice, qty=abs(strategy.position_size))