Pine Script v4 · Strategy
All in One Strategy no RSI Label - For higher dollar crypto
A Pine Script v4 strategy built on RSI (close, 14), EMA (rsi_ema, 14) and Highest (high, 5). It has 6 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss and a profit target. Each trade commits 100% of equity and pays 0.18% commission. 40 settings; defaults include Trade Types Long/Short, Stop Loss % 10.0 and Target Profit % 20.0.
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 All in One Strategy no RSI Label - For higher dollar crypto repaint?
- Yes
- At least one pattern in the source can repaint: intrabar recalculation.
- How did All in One Strategy no RSI Label - For higher dollar crypto 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 code limits trading to a date window, which can leave this period out. It closed no trades on the other markets either. A backtest, not investment advice.
- Can All in One Strategy no RSI Label - For higher dollar crypto 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.
- What alerts does All in One Strategy no RSI Label - For higher dollar crypto have?
- 12
- True Dip; True Peak; EMA Buy; EMA Sell; and more.
- Does All in One Strategy no RSI Label - For higher dollar crypto use a stop loss?
- Yes
- strategy.exit sets a stop on line 258, 261.
BTCUSDT · 1D · default settings
- K
- D
- Oversold
- Overbought
- RSI
- Winning trade
- Losing trade
- Equity
- Buy and hold
- 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, $1,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
8 settings do nothing
“Long/Short for Mixed Market, Long for Bull, Short for Bear”, “These are the RSI Strategy Inputs, RSI Length applies to MACD, set OB and OS to 45 for using Stoch and EMA strategies.”, “Use EMA Only, select only one strategy (EMA uses Stochastic inputs too)”, “These are the MACD strategy variables”, “Price Change Percentage Cross Check Inputs for all Strategies, added logic to avoid early sell”, “Stochastic Strategy Inputs”, “Curernt or Higher time frame only”, “Show RSI Buy Sell Zones” are declared but never read.
-
Check
Every trade uses all the equity
default_qty_value is 100% of equity.
-
Note
No slippage
Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.
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 rsi → ta.rsi, round → math.round, ema → ta.ema, crossunder → ta.crossunder, crossover → ta.crossover, highest → ta.highest, lowest → ta.lowest, stoch → ta.stoch, wma → ta.wma, sma → ta.sma, change → ta.change, vwma → ta.vwma, macd → ta.macd.
v4 → v5
Not verifiedNeither version placed a trade on any of the 8 markets, so there was nothing to compare.
- Line 2: //@version=4 → //@version=5
- Line 21: input(type = input.time) → input.time()
- Line 22: input(type = input.time) → input.time()
- Line 52: input(type = input.source) → input.source()
- Line 53: rsi → ta.rsi
- Line 65: input(type = input.resolution) → input.timeframe()
30 more edits
- Line 80: round → math.round
- Line 90: round → math.round
- Line 126: rsi → ta.rsi
- Line 127: ema → ta.ema
- Line 128: ema → ta.ema
- Line 129: ema → ta.ema
- Line 130: ema → ta.ema
- Line 131: ema → ta.ema
- Line 132: ema → ta.ema
- Line 138: crossunder → ta.crossunder
- Line 139: crossover → ta.crossover
- Line 154: highest → ta.highest
- Line 155: lowest → ta.lowest
- Line 156: stoch → ta.stoch
- Line 158: ema → ta.ema
- Line 159: wma → ta.wma
- Line 160: sma → ta.sma
- Line 161: sma → ta.sma
- Line 162: change → ta.change
- Line 163: change → ta.change
- Line 177: crossover → ta.crossover
- Line 178: crossunder → ta.crossunder
- Line 183: vwma → ta.vwma
- Line 184: vwma → ta.vwma
- Line 210: sma → ta.sma
- Line 211: sma → ta.sma
- Line 212: sma → ta.sma
- Line 223: macd → ta.macd
- Line 234: crossunder → ta.crossunder
- Line 236: crossover → ta.crossover
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/-//@version=4+//@version=5// ██████╗██████╗ ███████╗ █████╗ ████████╗███████╗██████╗ ██████╗ ██╗ ██╗ ⋯//Backtest dates with auto finish date of today-start = input(defval = timestamp("01 April 2021 00:00 -0500"), title = "Start Time", type = input.time)+start = input.time(defval = timestamp("01 April 2021 00:00 -0500"), title = "Start Time")-finish = input(defval = timestamp("31 December 2021 00:00 -0600"), title = "End Time", type = input.time)+finish = input.time(defval = timestamp("31 December 2021 00:00 -0600"), title = "End Time")window() => time >= start and time <= finish ? true : false // create function "within window of time"⋯os_lb = input(35, "Oversold Lookback Bars", minval=0, maxval=100)-source = input(title="Source", type=input.source, defval=close)+source = input.source(title="Source", defval=close)-RSI = rsi(source, length)+RSI = ta.rsi(source, length)// Price Movement Inputs⋯low_source= input(low,"Low Source")-HTF = input("","Curernt or Higher time frame only", type=input.resolution)+HTF = input.timeframe("","Curernt or Higher time frame only")// Selections to show or hide the overlays⋯ total := total + src[i]- round(total / count)+ math.round(total / count) ⋯ total := total + src[i]- round(total / count)+ math.round(total / count)RSI_low = AvgLow(RSI, os_lb, os_min)⋯haClose(gap) => (open[gap] + high[gap] + low[gap] + close[gap]) / 4-rsi_ema = rsi(haClose(0), length)+rsi_ema = ta.rsi(haClose(0), length)-v2 = ema(rsi_ema, length) +v2 = ta.ema(rsi_ema, length) -v3 = 2 * v2 - ema(v2, length) +v3 = 2 * v2 - ta.ema(v2, length) -emaA = ema(rsi_ema, fastLength) +emaA = ta.ema(rsi_ema, fastLength) -emaFast = 2 * emaA - ema(emaA, fastLength)+emaFast = 2 * emaA - ta.ema(emaA, fastLength)-emaB = ema(rsi_ema, slowLength) +emaB = ta.ema(rsi_ema, slowLength) -emaSlow = 2 * emaB - ema(emaB, slowLength) +emaSlow = 2 * emaB - ta.ema(emaB, slowLength) //plot(rsi_ema, color=color.white, title='RSI EMA', linewidth=3)⋯//plot(emaSlow, color=color.maroon, title="EMA Slow", linewidth=2)-EMABuy = crossunder(emaFast, v2) and window()+EMABuy = ta.crossunder(emaFast, v2) and window()-EMASell = crossover(emaFast, emaSlow) and window()+EMASell = ta.crossover(emaFast, emaSlow) and window()alertcondition(EMABuy, title='EMA Buy', message='EMA Buy Condition')⋯// Use highest highs and lowest lows-h_high = highest(high_source ,lkbk)+h_high = ta.highest(high_source ,lkbk)-l_low = lowest(low_source ,lkbk)+l_low = ta.lowest(low_source ,lkbk)-stoch = stoch(RSI, RSI_high, RSI_low, length)+stoch = ta.stoch(RSI, RSI_high, RSI_low, length)k =- k_mode=="EMA" ? ema(stoch, smoothK) :+ k_mode=="EMA" ? ta.ema(stoch, smoothK) :- k_mode=="WMA" ? wma(stoch, smoothK) :+ k_mode=="WMA" ? ta.wma(stoch, smoothK) :- sma(stoch, smoothK)+ ta.sma(stoch, smoothK)-d = sma(k, smoothD)+d = ta.sma(k, smoothD)-k_c = change(k)+k_c = ta.change(k)-d_c = change(d)+d_c = ta.change(d)kd = k - d⋯//StochSell = crossunder(k,d) and kd<0 and to_high>0 and window()-StochBuy = crossover(k, d) and window()+StochBuy = ta.crossover(k, d) and window()-StochSell = crossunder(k, d) and window()+StochSell = ta.crossunder(k, d) and window()alertcondition(StochBuy, title='Stoch Buy', message='K Crossing D')⋯// Calculations-h1 = vwma(high, length)+h1 = ta.vwma(high, length)-l1 = vwma(low, length)+l1 = ta.vwma(low, length)hp = h_high[1]⋯connor_os = oversold-ma1 = sma(close,cl1)+ma1 = ta.sma(close,cl1)-ma2 = sma(close, cl2)+ma2 = ta.sma(close, cl2)-ma3 = sma(close, cl3)+ma3 = ta.sma(close, cl3)// Buy Sell Zones using tweaked Connors RSI (RSI values of 80 and 20 for Crypto as well as ma3, ma20, and ma50 are the tweaks)⋯//------------------- MACD Strategy --------------------------------------------------[macdLine, signalLine, _] = macd(close, fastLength, slowLength, length)+[macdLine, signalLine, _] = ta.macd(close, fastLength, slowLength, length)bartrendcolor = macdLine > signalLine and k > 50 and RSI > 50 ? color.teal : macdLine < signalLine and k < 50 and RSI < 50 ? color.maroon : macdLine < signalLine ? color.yellow : color.gray⋯// Entry Logic-XRSI_OB = crossunder(RSI, overbought) and overall<0 and window()+XRSI_OB = ta.crossunder(RSI, overbought) and overall<0 and window()RSI_OB = RSI>overbought and true_peak and window()-XRSI_OS = crossover(RSI, oversold) and overall>0 and window()+XRSI_OS = ta.crossover(RSI, oversold) and overall>0 and window()RSI_OS = RSI<oversold and true_dip and window()⋯Clean v5
Not verifiedNeither version placed a trade on any of the 8 markets, so there was nothing to compare.
- Line 25: input() → input.bool()
- Line 26: input() → input.string()
- Line 29: input() → input.float()
- Line 31: input() → input.float()
- Line 33: input() → input.bool()
- Line 34: input() → input.bool()
30 more edits
- Line 35: input() → input.bool()
- Line 36: 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 43: input() → input.bool()
- Line 44: input() → input.bool()
- Line 45: input() → input.bool()
- Line 46: input() → input.int()
- Line 47: input() → input.int()
- Line 48: input() → input.int()
- Line 49: input() → input.int()
- Line 50: input() → input.int()
- Line 51: input() → input.int()
- Line 55: input() → input.bool()
- Line 56: input() → input.int()
- Line 58: input() → input.bool()
- Line 59: input() → input.bool()
- Line 60: input() → input.int()
- Line 61: input() → input.int()
- Line 62: input() → input.string()
- Line 63: input() → input.source()
- Line 64: input() → input.source()
- Line 67: input() → input.bool()
- Line 68: input() → input.bool()
- Line 69: input() → input.bool()
- Line 70: input() → input.bool()
- Line 71: input() → input.bool()
⋯// Strategy Selection - Long, Short, or Both-stratinfo = input(true, "Long/Short for Mixed Market, Long for Bull, Short for Bear")+stratinfo = input.bool(true, "Long/Short for Mixed Market, Long for Bull, Short for Bear")-strat = input(title="Trade Types", defval="Long/Short", options=["Long Only", "Long/Short", "Short Only"])+strat = input.string(title="Trade Types", defval="Long/Short", options=["Long Only", "Long/Short", "Short Only"])strat_val = strat == "Long Only" ? 1 : strat == "Long/Short" ? 0 : -1// Risk Management Inputs-sl= input(10.0, "Stop Loss %", minval = 0, maxval = 100, step = 0.01)+sl= input.float(10.0, "Stop Loss %", minval = 0, maxval = 100, step = 0.01)stoploss = sl/100-tp = input(20.0, "Target Profit %", minval = 0, maxval = 100, step = 0.01)+tp = input.float(20.0, "Target Profit %", minval = 0, maxval = 100, step = 0.01)TargetProfit = tp/100-useXRSI = input(false, "Use RSI crossing back, select only one strategy")+useXRSI = input.bool(false, "Use RSI crossing back, select only one strategy")-useCRSI = input(false, "Use Tweaked Connors RSI, select only one")+useCRSI = input.bool(false, "Use Tweaked Connors RSI, select only one")-RSIInfo = input(true, "These are the RSI Strategy Inputs, RSI Length applies to MACD, set OB and OS to 45 for using Stoch and EMA strategies.")+RSIInfo = input.bool(true, "These are the RSI Strategy Inputs, RSI Length applies to MACD, set OB and OS to 45 for using Stoch and EMA strategies.")-length = input(14, "RSI Length", minval=1)+length = input.int(14, "RSI Length", minval=1)-overbought= input(62, "Overbought")+overbought= input.int(62, "Overbought")-oversold= input(35, "Oversold")+oversold= input.int(35, "Oversold")-cl1 = input(3, "Connor's MA Length 1", minval=1, step=1)+cl1 = input.int(3, "Connor's MA Length 1", minval=1, step=1)-cl2 = input(20, "Connor's MA Lenght 2", minval=1, step=1)+cl2 = input.int(20, "Connor's MA Lenght 2", minval=1, step=1)-cl3 = input(50, "Connor's MA Lenght 3", minval=1, step=1)+cl3 = input.int(50, "Connor's MA Lenght 3", minval=1, step=1)// MACD and EMA Inputs-useMACD = input(false, "Use MACD Only, select only one strategy")+useMACD = input.bool(false, "Use MACD Only, select only one strategy")-useEMA = input(false, "Use EMA Only, select only one strategy (EMA uses Stochastic inputs too)")+useEMA = input.bool(false, "Use EMA Only, select only one strategy (EMA uses Stochastic inputs too)")-MACDInfo=input(true, "These are the MACD strategy variables")+MACDInfo=input.bool(true, "These are the MACD strategy variables")-fastLength = input(5, minval=1, title="EMA Fast Length")+fastLength = input.int(5, minval=1, title="EMA Fast Length")-slowLength = input(10, minval=1, title="EMA Slow Length")+slowLength = input.int(10, minval=1, title="EMA Slow Length")-ob_min = input(52, "Overbought Lookback Minimum Value", minval=0, maxval=200)+ob_min = input.int(52, "Overbought Lookback Minimum Value", minval=0, maxval=200)-ob_lb = input(25, "Overbought Lookback Bars", minval=0, maxval=100)+ob_lb = input.int(25, "Overbought Lookback Bars", minval=0, maxval=100)-os_min = input(50, "Oversold Lookback Minimum Value", minval=0, maxval=200)+os_min = input.int(50, "Oversold Lookback Minimum Value", minval=0, maxval=200)-os_lb = input(35, "Oversold Lookback Bars", minval=0, maxval=100)+os_lb = input.int(35, "Oversold Lookback Bars", minval=0, maxval=100)source = input.source(title="Source", defval=close)⋯// Price Movement Inputs-PriceInfo = input(true, "Price Change Percentage Cross Check Inputs for all Strategies, added logic to avoid early sell")+PriceInfo = input.bool(true, "Price Change Percentage Cross Check Inputs for all Strategies, added logic to avoid early sell")-lkbk = input(5,"Max Lookback Period")+lkbk = input.int(5,"Max Lookback Period")// EMA and SMA Background Inputs-useStoch = input(false, "Use Stochastic Strategy, choose only one")+useStoch = input.bool(false, "Use Stochastic Strategy, choose only one")-StochInfo = input(true, "Stochastic Strategy Inputs")+StochInfo = input.bool(true, "Stochastic Strategy Inputs")-smoothK = input(3, "K", minval=1)+smoothK = input.int(3, "K", minval=1)-smoothD = input(3, "D", minval=1)+smoothD = input.int(3, "D", minval=1)-k_mode = input("SMA", "K Mode", options=["SMA", "EMA", "WMA"])+k_mode = input.string("SMA", "K Mode", options=["SMA", "EMA", "WMA"])-high_source = input(high,"High Source")+high_source = input.source(high,"High Source")-low_source= input(low,"Low Source")+low_source= input.source(low,"Low Source")HTF = input.timeframe("","Curernt or Higher time frame only")// Selections to show or hide the overlays-showZones = input(true, title="Show Bullish/Bearish Zones")+showZones = input.bool(true, title="Show Bullish/Bearish Zones")-showStoch = input(true, title="Show Stochastic Overlays")+showStoch = input.bool(true, title="Show Stochastic Overlays")-showRSIBS = input(true, title="Show RSI Buy Sell Zones")+showRSIBS = input.bool(true, title="Show RSI Buy Sell Zones")-showMACD = input(true, title="Show MACD")+showMACD = input.bool(true, title="Show MACD")-color_bars=input(true, "Color Bars")+color_bars=input.bool(true, "Color Bars")// ------------------ Dynamic RSI Calculation ----------------------------------------⋯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.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/-//@version=5+//@version=6// ██████╗██████╗ ███████╗ █████╗ ████████╗███████╗██████╗ ██████╗ ██╗ ██╗ ⋯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 |
|---|---|---|---|
| Start Time | timestamp("01 April 2021 00:00 -0500") | time | line 23 |
| End Time | timestamp("31 December 2021 00:00 -0600") | time | line 23 |
| Long/Short for Mixed Market, Long for Bull, Short for Bear | true | bool | unused |
| Trade Types | Long/Short | string · options ["Long Only", "Long/Short", "Short Only"] | strat_val |
| Stop Loss % | 10.0 | float · min 0 · max 100 · step 0.01 | stoploss |
| Target Profit % | 20.0 | float · min 0 · max 100 · step 0.01 | TargetProfit |
| Use RSI crossing back, select only one strategy | false | bool | GoLong GoShort CloseLong CloseShort |
| Use Tweaked Connors RSI, select only one | false | bool | col GoLong GoShort CloseLong CloseShort |
| These are the RSI Strategy Inputs, RSI Length applies to MACD, set OB and OS to 45 for using Stoch and EMA strategies. | true | bool | unused |
| RSI Length | 14 | int · min 1 | RSI rsi_ema v2 v3 stoch h1 l1 macdLine signalLine |
| Overbought | 62 | int | signalColor Overbought connor_ob XRSI_OB RSI_OB |
| Oversold | 35 | int | signalColor Oversold connor_os XRSI_OS RSI_OS |
| Connor's MA Length 1 | 3 | int · min 1 · step 1 | ma1 |
| Connor's MA Lenght 2 | 20 | int · min 1 · step 1 | ma2 |
| Connor's MA Lenght 3 | 50 | int · min 1 · step 1 | ma3 |
| Use MACD Only, select only one strategy | false | bool | GoLong GoShort CloseLong CloseShort |
| Use EMA Only, select only one strategy (EMA uses Stochastic inputs too) | false | bool | unused |
| These are the MACD strategy variables | true | bool | unused |
| EMA Fast Length | 5 | int · min 1 | emaA emaFast macdLine signalLine |
| EMA Slow Length | 10 | int · min 1 | emaB emaSlow macdLine signalLine |
| Overbought Lookback Minimum Value | 52 | int · min 0 · max 200 | RSI_high |
| Overbought Lookback Bars | 25 | int · min 0 · max 100 | RSI_high |
| Oversold Lookback Minimum Value | 50 | int · min 0 · max 200 | RSI_low |
| Oversold Lookback Bars | 35 | int · min 0 · max 100 | RSI_low |
| Source | close | source | RSI |
| Price Change Percentage Cross Check Inputs for all Strategies, added logic to avoid early sell | true | bool | unused |
| Max Lookback Period | 5 | int | i overall_change highest_high lowest_low start_to_high start_to_low overall to_high to_low last_high last_low last_bar h_high l_low |
| Use Stochastic Strategy, choose only one | false | bool | GoLong GoShort |
| Stochastic Strategy Inputs | true | bool | unused |
| K | 3 | int · min 1 | k |
| D | 3 | int · min 1 | d |
| K Mode | SMA | string · options ["SMA", "EMA", "WMA"] | k |
| High Source | high | source | h_high |
| Low Source | low | source | l_low |
| Curernt or Higher time frame only | | timeframe (written input.resolution) | unused |
| Show Bullish/Bearish Zones | true | bool | Bullish/Bearish Zones |
| Show Stochastic Overlays | true | bool | K D signalUp signalDown |
| Show RSI Buy Sell Zones | true | bool | unused |
| Show MACD | true | bool | MACD Signals |
| Color Bars | true | bool | barcolor |
What it calculates
- RSI (
rsi,ta.rsiin v5)Source (close), RSI Length (14)RSI · line 53 - RSI (
rsi,ta.rsiin v5)haClose(0), RSI Length (14)rsi_ema · line 126 - EMA (
ema,ta.emain v5)rsi_ema, RSI Length (14)v2 · line 127 - EMA (
ema,ta.emain v5)v2, RSI Length (14)v3 · line 128 - EMA (
ema,ta.emain v5)rsi_ema, EMA Fast Length (5)emaA · line 129 - EMA (
ema,ta.emain v5)emaA, EMA Fast Length (5)emaFast · line 130 - EMA (
ema,ta.emain v5)rsi_ema, EMA Slow Length (10)emaB · line 131 - EMA (
ema,ta.emain v5)emaB, EMA Slow Length (10)emaSlow · line 132 - Highest (
highest,ta.highestin v5)High Source (high), Max Lookback Period (5)h_high · line 154 - Lowest (
lowest,ta.lowestin v5)Low Source (low), Max Lookback Period (5)l_low · line 155 - Stoch (
stoch,ta.stochin v5)RSI, RSI_high, RSI_low, RSI Length (14)stoch · line 156 - EMA / WMA / SMA (
ema,ta.emain v5)stoch, K (3) · chosen by K Modek · line 157 - SMA (
sma,ta.smain v5)k, D (3)d · line 161 - Change (
change,ta.changein v5)kk_c · line 162 - Change (
change,ta.changein v5)dd_c · line 163 - VWMA (
vwma,ta.vwmain v5)high, RSI Length (14)h1 · line 183 - VWMA (
vwma,ta.vwmain v5)low, RSI Length (14)l1 · line 184 - SMA (
sma,ta.smain v5)close, Connor's MA Length 1 (3)ma1 · line 210 - SMA (
sma,ta.smain v5)close, Connor's MA Lenght 2 (20)ma2 · line 211 - SMA (
sma,ta.smain v5)close, Connor's MA Lenght 3 (50)ma3 · line 212 - MACD (
macd,ta.macdin v5)close, EMA Fast Length (5), EMA Slow Length (10), RSI Length (14)macdLine · line 223 - MACD (
macd,ta.macdin v5)close, EMA Fast Length (5), EMA Slow Length (10), RSI Length (14)signalLine · line 223
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 |
|---|---|---|---|
| Open LONG long | (GoLong) | On | 246 |
| Open SHORT short | (GoShort) | On | 248 |
| Exit Exit Long stop and limit | (strategy.position_size > 0) | On | 258 |
| Exit Exit Short stop and limit | (strategy.position_size < 0) | On | 261 |
| Close LONG | (CloseLong) | On | 264 |
| Close SHORT | (CloseShort) | On | 268 |
Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.
Alerts
| Alert | Call | Message | Line |
|---|---|---|---|
| True Dip | alertcondition | Dip | 121 |
| True Peak | alertcondition | Peak | 122 |
| EMA Buy | alertcondition | EMA Buy Condition | 140 |
| EMA Sell | alertcondition | EMA Sell Condition | 141 |
| Stoch Buy | alertcondition | K Crossing D | 179 |
| Stoch Sell | alertcondition | D Crossing K | 180 |
| Connors Buy | alertcondition | Connors RSI Buy | 216 |
| Connors Sell | alertcondition | Connors RSI Sell | 217 |
| Reverse RSI Sell | alertcondition | RSI Crossing back under OB | 238 |
| Reverse RSI Buy | alertcondition | RSI Crossing back over OS | 239 |
| RSI Buy | alertcondition | RSI Crossover OS | 240 |
| RSI Sell | alertcondition | RSI Crossunder OB | 241 |
Does it repaint?
Yes
At least one pattern in the source can repaint; it is marked Check below.
- ClearHigher-timeframe dataThe script requests no other symbol or timeframe.
- ClearFuture-bar referencesNo negative history offsets such as close[-1].
- CheckIntrabar recalculationcalc_on_every_tick = true. Live values can differ from history.
- ClearOrder timingprocess_orders_on_close = true: orders fill at the signal bar's close.
The checks read the source; the replay runs it. Together they catch the common causes, not every possible one.
Other markets
The same script with default settings on 8 Binance markets. Each row is a separate backtest over the most recent 1,000 bars.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | 0.0% | +102.5% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | 0.0% | +5.5% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | 0.0% | +9.8% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | 0.0% | +8.4% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | 0.0% | +16.7% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | 0.0% | +21.5% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | 0.0% | +148.3% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | 0.0% | +17.1% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
Backtests are simulations on historical data and are not investment advice.
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 |
|---|---|---|---|---|---|
| All in One Strategy no RSI Label - For higher dollar crypto this page | — | v4 strategy | 0.0% | 0 | 0.0% |
| All in One Strategy by Solutions1978 | rsi ema highest lowest stoch sma vwma macd | v4 strategy | No trades on this market | ||
| Bear & Bull Zone Signal Strategy by Solutions1978 | rsi ema highest lowest stoch sma vwma | v4 strategy | No trades on this market | ||
| sma RSI & sudden buy and sell Strategy v1 by samwillington | ema rsi highest lowest sma | v5 strategy | +7.6% | 15 | 3.7% |
| Swing Multi Moving Averages Crypto and Stocks Strategy by exlux99 | ema wma highest lowest sma | v5 strategy | +60.2% | 22 | 13.1% |
| VCP pivot buy by perrycc007 | sma ema vwma wma lowest highest | v4 strategy | does not run in Zeal Terminal | ||
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 56 ms | Yes 1,000 bars in 290 ms | Not measured |
| PineTS | No v5 and v6 only | — | Not measured |
“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///@version=4// ██████╗██████╗ ███████╗ █████╗ ████████╗███████╗██████╗ ██████╗ ██╗ ██╗ //██╔════╝██╔══██╗██╔════╝██╔══██╗╚══██╔══╝██╔════╝██╔══██╗ ██╔══██╗╚██╗ ██╔╝ //██║ ██████╔╝█████╗ ███████║ ██║ █████╗ ██║ ██║ ██████╔╝ ╚████╔╝ //██║ ██╔══██╗██╔══╝ ██╔══██║ ██║ ██╔══╝ ██║ ██║ ██╔══██╗ ╚██╔╝ //╚██████╗██║ ██║███████╗██║ ██║ ██║ ███████╗██████╔╝ ██████╔╝ ██║ // ╚═════╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═╝ ╚══════╝╚═════╝ ╚═════╝ ╚═╝ //███████╗ ██████╗ ██╗ ██╗ ██╗████████╗██╗ ██████╗ ███╗ ██╗███████╗ ██╗ █████╗ ███████╗ █████╗ //██╔════╝██╔═══██╗██║ ██║ ██║╚══██╔══╝██║██╔═══██╗████╗ ██║██╔════╝███║██╔══██╗╚════██║██╔══██╗//███████╗██║ ██║██║ ██║ ██║ ██║ ██║██║ ██║██╔██╗ ██║███████╗╚██║╚██████║ ██╔╝╚█████╔╝//╚════██║██║ ██║██║ ██║ ██║ ██║ ██║██║ ██║██║╚██╗██║╚════██║ ██║ ╚═══██║ ██╔╝ ██╔══██╗//███████║╚██████╔╝███████╗╚██████╔╝ ██║ ██║╚██████╔╝██║ ╚████║███████║ ██║ █████╔╝ ██║ ╚█████╔╝//╚══════╝ ╚═════╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝ ╚═╝ ╚════╝ ╚═╝ ╚════╝ strategy(shorttitle='Ain1 No Label',title='All in One Strategy no RSI Label', overlay=true, scale=scale.left, initial_capital = 1000, process_orders_on_close=true, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, commission_type=strategy.commission.percent, commission_value=0.18, calc_on_every_tick=true)kcolor = color.new(#0094FF, 60)dcolor = color.new(#FF6A00, 60)// ----------------- Strategy Inputs -------------------------------------------------------------//Backtest dates with auto finish date of todaystart = input(defval = timestamp("01 April 2021 00:00 -0500"), title = "Start Time", type = input.time)finish = input(defval = timestamp("31 December 2021 00:00 -0600"), title = "End Time", type = input.time)window() => time >= start and time <= finish ? true : false // create function "within window of time"// Strategy Selection - Long, Short, or Bothstratinfo = input(true, "Long/Short for Mixed Market, Long for Bull, Short for Bear")strat = input(title="Trade Types", defval="Long/Short", options=["Long Only", "Long/Short", "Short Only"])strat_val = strat == "Long Only" ? 1 : strat == "Long/Short" ? 0 : -1// Risk Management Inputssl= input(10.0, "Stop Loss %", minval = 0, maxval = 100, step = 0.01)stoploss = sl/100tp = input(20.0, "Target Profit %", minval = 0, maxval = 100, step = 0.01)TargetProfit = tp/100useXRSI = input(false, "Use RSI crossing back, select only one strategy")useCRSI = input(false, "Use Tweaked Connors RSI, select only one")RSIInfo = input(true, "These are the RSI Strategy Inputs, RSI Length applies to MACD, set OB and OS to 45 for using Stoch and EMA strategies.")length = input(14, "RSI Length", minval=1)overbought= input(62, "Overbought")oversold= input(35, "Oversold")cl1 = input(3, "Connor's MA Length 1", minval=1, step=1)cl2 = input(20, "Connor's MA Lenght 2", minval=1, step=1)cl3 = input(50, "Connor's MA Lenght 3", minval=1, step=1)// MACD and EMA InputsuseMACD = input(false, "Use MACD Only, select only one strategy")useEMA = input(false, "Use EMA Only, select only one strategy (EMA uses Stochastic inputs too)")MACDInfo=input(true, "These are the MACD strategy variables")fastLength = input(5, minval=1, title="EMA Fast Length")slowLength = input(10, minval=1, title="EMA Slow Length")ob_min = input(52, "Overbought Lookback Minimum Value", minval=0, maxval=200)ob_lb = input(25, "Overbought Lookback Bars", minval=0, maxval=100)os_min = input(50, "Oversold Lookback Minimum Value", minval=0, maxval=200)os_lb = input(35, "Oversold Lookback Bars", minval=0, maxval=100)source = input(title="Source", type=input.source, defval=close)RSI = rsi(source, length)// Price Movement InputsPriceInfo = input(true, "Price Change Percentage Cross Check Inputs for all Strategies, added logic to avoid early sell")lkbk = input(5,"Max Lookback Period")// EMA and SMA Background InputsuseStoch = input(false, "Use Stochastic Strategy, choose only one")StochInfo = input(true, "Stochastic Strategy Inputs")smoothK = input(3, "K", minval=1)smoothD = input(3, "D", minval=1)k_mode = input("SMA", "K Mode", options=["SMA", "EMA", "WMA"])high_source = input(high,"High Source")low_source= input(low,"Low Source")HTF = input("","Curernt or Higher time frame only", type=input.resolution)// Selections to show or hide the overlaysshowZones = input(true, title="Show Bullish/Bearish Zones")showStoch = input(true, title="Show Stochastic Overlays")showRSIBS = input(true, title="Show RSI Buy Sell Zones")showMACD = input(true, title="Show MACD")color_bars=input(true, "Color Bars")// ------------------ Dynamic RSI Calculation ----------------------------------------AvgHigh(src,cnt,val) => total = 0.0 count = 0 for i = 0 to cnt if src[i] > val count := count + 1 total := total + src[i] round(total / count) RSI_high = AvgHigh(RSI, ob_lb, ob_min)AvgLow(src,cnt,val) => total = 0.0 count = 0 for i = 0 to cnt if src[i] < val count := count + 1 total := total + src[i] round(total / count)RSI_low = AvgLow(RSI, os_lb, os_min)// ------------------ Price Percentage Change Calculation -----------------------------------------perc_change(lkbk) => overall_change = ((close[0] - open[lkbk]) / open[lkbk]) * 100 highest_high = 0.0 lowest_low = 0.0 for i = lkbk to 0 highest_high := i == lkbk ? high : high[i] > high[(i + 1)] ? high[i] : highest_high[1] lowest_low := i == lkbk ? low : low[i] < low[(i + 1)] ? low[i] : lowest_low[1] start_to_high = ((highest_high - open[lkbk]) / open[lkbk]) * 100 start_to_low = ((lowest_low - open[lkbk]) / open[lkbk]) * 100 previous_to_high = ((highest_high - open[1])/open[1])*100 previous_to_low = ((lowest_low-open[1])/open[1])*100 previous_bar = ((close[1]-open[1])/open[1])*100 [overall_change, start_to_high, start_to_low, previous_to_high, previous_to_low, previous_bar] // Call the function [overall, to_high, to_low, last_high, last_low, last_bar] = perc_change(lkbk)// Plot the function//plot(overall*50, color=color.white, title='Overall Percentage Change', linewidth=3)//plot(to_high*50, color=color.green,title='Percentage Change from Start to High', linewidth=2)//plot(to_low*50, color=color.red, title='Percentage Change from Start to Low', linewidth=2)//plot(last_high*100, color=color.teal, title="Previous to High", linewidth=2)//plot(last_low*100, color=color.maroon, title="Previous to Close", linewidth=2)//plot(last_bar*100, color=color.orange, title="Previous Bar", linewidth=2)//hline(0, title='Center Line', color=color.orange, linewidth=2)true_dip = overall < 0 and to_high > 0 and to_low < 0 and last_high > 0 and last_low < 0 and last_bar < 0true_peak = overall > 0 and to_high > 0 and to_low > 0 and last_high > 0 and last_low < 0 and last_bar > 0alertcondition(true_dip, title='True Dip', message='Dip')alertcondition(true_peak, title='True Peak', message='Peak')// ------------------ Background Colors based on EMA Indicators -----------------------------------// Uses standard lengths of 9 and 21, if you want control delete the constant definition and uncomment the inputshaClose(gap) => (open[gap] + high[gap] + low[gap] + close[gap]) / 4rsi_ema = rsi(haClose(0), length)v2 = ema(rsi_ema, length) v3 = 2 * v2 - ema(v2, length) emaA = ema(rsi_ema, fastLength) emaFast = 2 * emaA - ema(emaA, fastLength)emaB = ema(rsi_ema, slowLength) emaSlow = 2 * emaB - ema(emaB, slowLength) //plot(rsi_ema, color=color.white, title='RSI EMA', linewidth=3)//plot(v2, color=color.green,title='v2', linewidth=2)//plot(v3, color=color.red, title='v3', linewidth=2)//plot(emaFast, color=color.teal, title="EMA Fast", linewidth=2)//plot(emaSlow, color=color.maroon, title="EMA Slow", linewidth=2)EMABuy = crossunder(emaFast, v2) and window()EMASell = crossover(emaFast, emaSlow) and window()alertcondition(EMABuy, title='EMA Buy', message='EMA Buy Condition')alertcondition(EMASell, title='EMA Sell', message='EMA Sell Condition')// bullish signal rule: bullishRule =emaFast > emaSlow// bearish signal rule: bearishRule =emaFast < emaSlow// current trading StateruleState = 0ruleState := bullishRule ? 1 : bearishRule ? -1 : nz(ruleState[1])ruleColor = ruleState==1 ? color.new(color.blue, 90) : ruleState == -1 ? color.new(color.red, 90) : ruleState == 0 ? color.new(color.gray, 90) : nabgcolor(showZones ? ruleColor : na, title="Bullish/Bearish Zones")// ------------------ Stochastic Indicator Overlay -----------------------------------------------// Calculation// Use highest highs and lowest lowsh_high = highest(high_source ,lkbk)l_low = lowest(low_source ,lkbk)stoch = stoch(RSI, RSI_high, RSI_low, length)k = k_mode=="EMA" ? ema(stoch, smoothK) : k_mode=="WMA" ? wma(stoch, smoothK) : sma(stoch, smoothK)d = sma(k, smoothD)k_c = change(k)d_c = change(d)kd = k - d// PlotsignalColor = k>oversold and d<overbought and k>d and k_c>0 and d_c>0 ? kcolor : k<overbought and d>oversold and k<d and k_c<0 and d_c<0 ? dcolor : nakp = plot(showStoch ? k : na, "K", color=kcolor)dp = plot(showStoch ? d : na, "D", color=dcolor)fill(kp, dp, color = signalColor, title="K-D")signalUp = showStoch ? not na(signalColor) and kd>0 : nasignalDown = showStoch ? not na(signalColor) and kd<0 : na//plot(signalUp ? kd : na, "Signal Up", color=kcolor, transp=90, style=plot.style_columns)//plot(signalDown ? (kd+100) : na , "Signal Down", color=dcolor, transp=90, style=plot.style_columns, histbase=100)//StochBuy = crossover(k, d) and kd>0 and to_low<0 and window()//StochSell = crossunder(k,d) and kd<0 and to_high>0 and window()StochBuy = crossover(k, d) and window()StochSell = crossunder(k, d) and window()alertcondition(StochBuy, title='Stoch Buy', message='K Crossing D')alertcondition(StochSell, title='Stoch Sell', message='D Crossing K')// -------------- Add Price Movement -------------------------// Calculationsh1 = vwma(high, length)l1 = vwma(low, length)hp = h_high[1]lp = l_low[1]// Plotvar plot_color=#353535var sig = 0if (h1 >hp) sig:=1 plot_color:=color.limeelse if (l1 <lp) sig:=-1 plot_color:=color.maroon//plot(1,title = "Price Movement Bars", style=plot.style_columns,color=plot_color)//plot(sig,title="Signal 1 or -1",display=display.none)// --------------------------------------- RSI Plot ----------------------------------------------// Plot Oversold and Overbought Linesover = hline(oversold, title="Oversold", color=color.green)under = hline(overbought, title="Overbought", color=color.red)fillcolor = color.new(#9915FF, 90)fill(over, under, fillcolor, title="Band Background")// Show RSI and EMA crosses with arrows and RSI Color (tweaked Connors RSI)// Improves strategy setting ease by showing where EMA 5 crosses EMA 10 from above to confirm overbought conditions or trend reversals// This shows where you should enter shorts or exit longs// Tweaked Connors RSI Calculationconnor_ob = overboughtconnor_os = oversoldma1 = sma(close,cl1)ma2 = sma(close, cl2)ma3 = sma(close, cl3)// Buy Sell Zones using tweaked Connors RSI (RSI values of 80 and 20 for Crypto as well as ma3, ma20, and ma50 are the tweaks)RSI_SELL = ma1 > ma2 and open > ma3 and RSI >= connor_ob and true_peak and window()RSI_BUY = ma2 < ma3 and ma3 > close and RSI <= connor_os and true_dip and window()alertcondition(RSI_BUY, title='Connors Buy', message='Connors RSI Buy')alertcondition(RSI_SELL, title='Connors Sell', message='Connors RSI Sell')// Color Definitioncol = useCRSI ? (close > ma2 and close < ma3 and RSI <= connor_os ? color.lime : close < ma2 and close > ma3 and RSI <= connor_ob ? color.red : color.yellow ) : color.yellow// Plot colored RSI Lineplot(RSI, title="RSI", linewidth=3, color=col)//------------------- MACD Strategy -------------------------------------------------[macdLine, signalLine, _] = macd(close, fastLength, slowLength, length)bartrendcolor = macdLine > signalLine and k > 50 and RSI > 50 ? color.teal : macdLine < signalLine and k < 50 and RSI < 50 ? color.maroon : macdLine < signalLine ? color.yellow : color.graybarcolor(color = color_bars ? bartrendcolor : na)MACDBuy = macdLine>signalLine and RSI<RSI_low and overall<0 and window()MACDSell = macdLine<signalLine and RSI>RSI_high and overall>0 and window()//plotshape(showMACD ? MACDBuy: na, title = "MACD Buy", style = shape.arrowup, text = "MACD Buy", color=color.green, textcolor=color.green, size=size.small)//plotshape(showMACD ? MACDSell: na, title = "MACD Sell", style = shape.arrowdown, text = "MACD Sell", color=color.red, textcolor=color.red, size=size.small)MACColor = MACDBuy ? color.new(color.teal, 50) : MACDSell ? color.new(color.maroon, 50) : nabgcolor(showMACD ? MACColor : na, title ="MACD Signals")// -------------------------------- Entry and Exit Logic ------------------------------------// Entry LogicXRSI_OB = crossunder(RSI, overbought) and overall<0 and window()RSI_OB = RSI>overbought and true_peak and window()XRSI_OS = crossover(RSI, oversold) and overall>0 and window()RSI_OS = RSI<oversold and true_dip and window()alertcondition(XRSI_OB, title='Reverse RSI Sell', message='RSI Crossing back under OB')alertcondition(XRSI_OS, title='Reverse RSI Buy', message='RSI Crossing back over OS')alertcondition(RSI_OS, title='RSI Buy', message='RSI Crossover OS')alertcondition(RSI_SELL, title='RSI Sell', message='RSI Crossunder OB')// Strategy Entry and Exit with built in Risk ManagementGoLong = strategy.position_size==0 and strat_val > -1 and rsi_ema > RSI and k < d ? (useXRSI ? XRSI_OS : useMACD ? MACDBuy : useCRSI ? RSI_BUY : useStoch ? StochBuy : RSI_OS) : falseGoShort = strategy.position_size==0 and strat_val < 1 and rsi_ema < RSI and d < k ? (useXRSI ? XRSI_OB : useMACD ? MACDSell : useCRSI ? RSI_SELL : useStoch ? StochSell : RSI_OB) : falseif (GoLong) strategy.entry("LONG", strategy.long)if (GoShort) strategy.entry("SHORT", strategy.short)longStopPrice = strategy.position_avg_price * (1 - stoploss)longTakePrice = strategy.position_avg_price * (1 + TargetProfit)shortStopPrice = strategy.position_avg_price * (1 + stoploss)shortTakePrice = strategy.position_avg_price * (1 - TargetProfit)//plot(series=(strategy.position_size > 0) ? longTakePrice : na, color=color.green, style=plot.style_circles, linewidth=3, title="Long Take Profit")//plot(series=(strategy.position_size < 0) ? shortTakePrice : na, color=color.green, style=plot.style_circles, linewidth=3, title="Short Take Profit")//plot(series=(strategy.position_size > 0) ? longStopPrice : na, color=color.red, style=plot.style_cross, linewidth=2, title="Long Stop Loss")//plot(series=(strategy.position_size < 0) ? shortStopPrice : na, color=color.red, style=plot.style_cross, linewidth=2, title="Short Stop Loss")if (strategy.position_size > 0) strategy.exit(id="Exit Long", from_entry = "LONG", stop = longStopPrice, limit = longTakePrice) if (strategy.position_size < 0) strategy.exit(id="Exit Short", from_entry = "SHORT", stop = shortStopPrice, limit = shortTakePrice)CloseLong = strat_val > -1 and strategy.position_size > 0 and rsi_ema > RSI and d > k ? (useXRSI ? XRSI_OB : useMACD ? MACDSell : useCRSI ? RSI_SELL : RSI_OB) : falseif(CloseLong) strategy.close("LONG") CloseShort = strat_val < 1 and strategy.position_size < 0 and rsi_ema < RSI and k > d ? (useXRSI ? XRSI_OS : useMACD ? MACDBuy : useCRSI ? RSI_BUY : RSI_OS) : falseif(CloseShort) strategy.close("SHORT")