Pine Script v5 · Strategy
SPX Scalping Strategy
A Pine Script v5 strategy built on SMA (close, len1), Crossover (close, out1) and Crossunder (close, out1). It has 4 order rules, 2 entries among them, and trades long and short with the default settings. Exits wait for a signal; there is no stop loss. Each trade is one contract and pays no commission. 2 settings; defaults include SMA Source #1 close.
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 SPX Scalping Strategy repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 32 of 32 trades.
- How did SPX Scalping Strategy do on BTCUSDT 1D with default settings?
- +1.52%
- From 26 Jan 2024 to 21 Oct 2026, over 109 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Does SPX Scalping Strategy run in Pine Script v6?
- No
- The v6 version runs in Zeal Terminal's engine, but its results differ from the v5 version: Trades differ: 109 before, 58 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download.
- Does SPX Scalping Strategy use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does SPX Scalping Strategy run in Zeal Terminal?
- Yes
- It compiles in 27 ms and runs 1,000 bars in 46 ms, in the browser.
BTCUSDT · 1D · default settings
- SMA #1
- Shape
- Shape
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- +1.52%
- $15,187.70
- Buy and hold
- +102.5%
- same period
- Closed trades
- 109
- 35 won · 74 lost
- Profitable
- 32.1%
- of closed trades
- Profit factor
- 1.12
- gross profit ÷ gross loss
- Max drawdown
- 4.97%
- −$50,398.40
One run with the author's default settings, $1,000,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
1 setting does nothing
“RSI” is declared but never read.
-
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 66, 67. The upgraded version below moves each call inside an if block.
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 |
|---|---|---|---|
| SMA Source #1 | close | source | out1 |
| RSI | true | bool | unused |
What it calculates
- SMASMA Source #1 (close), len1
out1 · line 9 - Crossoverclose, out1
data_over · line 11 - Crossunderclose, out1
data_under · line 13 - EMAclose, sma
sh · line 23 - EMAclose, lma
lon · line 24 - Lowest / HighestMac, np
MacNorm · line 31 - WMAMacNorm2, tsp
Trigger · line 38 - RMA / Changemath.max(ta.change(src), 0), len
up · line 48 - RMA / Change-math.min(ta.change(src), 0), len
down · line 49 - SMArsi, srs
mr · line 51
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.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open LONG long | (buySignal) | On | 62 |
| Open SHORT short | (shortSignal) | On | 64 |
| Close LONG | sellSignalta.cross(close, out1) or ta.cross(Trigger, MacNorm2) or ta.cross(rsi, mr) | On | 66 |
| Close SHORT | sellSignalta.cross(close, out1) or ta.cross(Trigger, MacNorm2) or ta.cross(rsi, mr) | On | 67 |
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, and the live replay matched history.
- ClearHigher-timeframe dataThe script requests no other symbol or timeframe.
- 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
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 | +1.5% | +102.5% | 109 | 32% | 1.12 | 5.0% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +1.5% | +5.5% | 103 | 33% | 1.47 | 0.9% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −0.0% | +9.8% | 118 | 32% | 0.96 | 0.2% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +0.0% | +8.4% | 124 | 25% | 1.04 | 0.1% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +0.0% | +16.7% | 114 | 30% | 1.07 | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | −0.0% | +21.5% | 120 | 27% | 0.96 | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | −0.0% | +148.3% | 119 | 35% | 0.94 | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +0.0% | +17.1% | 116 | 32% | 1.26 | 0.0% | 8 May 2026 – 21 Oct 2026 |
Backtests are simulations on historical data and are not investment advice.
The trades
By market direction
| At entry, last 90 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 35 | 37% | −$8,990.73 |
| Sideways market | 45 | 38% | $25,820.70 |
| Falling market | 29 | 17% | −$1,642.23 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
5.2%
The 95th percentile of the worst drawdown when the same 109 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 2.2% to 5.2%; the tick is what actually happened, 4.9%. Order luck alone moves it this much.
All 109 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| short | 3 Apr 2024 65,464.00 | 7 Apr 2024 68,896.00 | 4 | −$3,432.01 |
| short | 13 Apr 2024 67,116.50 | 21 Apr 2024 64,940.60 | 8 | $2,175.94 |
| short | 28 Apr 2024 63,462.00 | 4 May 2024 62,882.00 | 6 | $579.97 |
| long | 6 May 2024 64,012.00 | 7 May 2024 63,165.20 | 1 | −$846.82 |
| long | 14 May 2024 62,940.10 | 15 May 2024 61,577.50 | 1 | −$1,362.60 |
| long | 16 May 2024 66,206.50 | 27 May 2024 68,507.70 | 11 | $2,301.16 |
| long | 28 May 2024 69,436.40 | 29 May 2024 68,398.40 | 1 | −$1,038.03 |
| long | 6 Jun 2024 71,108.00 | 9 Jun 2024 69,310.50 | 3 | −$1,797.54 |
| short | 12 Jun 2024 67,314.20 | 1 Jul 2024 62,772.00 | 19 | $4,542.22 |
| short | 5 Jul 2024 57,050.00 | 10 Jul 2024 58,050.00 | 5 | −$999.98 |
| long | 14 Jul 2024 59,204.00 | 25 Jul 2024 65,376.00 | 11 | $6,172.00 |
| long | 27 Jul 2024 67,908.00 | 30 Jul 2024 66,784.70 | 3 | −$1,123.32 |
| short | 3 Aug 2024 61,498.30 | 9 Aug 2024 61,686.00 | 6 | −$187.66 |
| short | 12 Aug 2024 58,712.60 | 13 Aug 2024 59,346.60 | 1 | −$634.05 |
| long | 14 Aug 2024 60,587.20 | 15 Aug 2024 58,683.40 | 1 | −$1,903.77 |
| long | 22 Aug 2024 61,156.00 | 28 Aug 2024 59,415.00 | 6 | −$1,741.03 |
| short | 29 Aug 2024 59,034.90 | 10 Sep 2024 57,042.00 | 12 | $1,992.89 |
| long | 13 Sep 2024 58,132.30 | 1 Oct 2024 63,327.60 | 18 | $5,195.29 |
| short | 2 Oct 2024 60,804.90 | 7 Oct 2024 62,819.90 | 5 | −$2,014.99 |
| short | 8 Oct 2024 62,224.00 | 12 Oct 2024 62,540.00 | 4 | −$315.98 |
| long | 14 Oct 2024 62,870.00 | 24 Oct 2024 66,668.60 | 10 | $3,798.63 |
| short | 26 Oct 2024 66,698.30 | 27 Oct 2024 67,092.80 | 1 | −$394.44 |
| long | 30 Oct 2024 72,736.40 | 2 Nov 2024 69,496.00 | 3 | −$3,240.41 |
| short | 3 Nov 2024 69,374.70 | 7 Nov 2024 75,572.00 | 4 | −$6,197.25 |
| long | 7 Nov 2024 75,572.00 | 18 Nov 2024 89,856.00 | 11 | $14,284.00 |
| long | 22 Nov 2024 98,317.10 | 24 Nov 2024 97,672.40 | 2 | −$644.72 |
| short | 26 Nov 2024 93,010.00 | 28 Nov 2024 95,863.10 | 2 | −$2,853.10 |
| short | 3 Dec 2024 95,840.60 | 4 Dec 2024 95,849.70 | 1 | −$9.08 |
| short | 10 Dec 2024 97,276.50 | 12 Dec 2024 101,125.00 | 2 | −$3,848.52 |
| long | 17 Dec 2024 106,059.00 | 19 Dec 2024 100,204.00 | 2 | −$5,854.64 |
| short | 19 Dec 2024 100,204.00 | 26 Dec 2024 99,429.60 | 7 | $774.40 |
| short | 27 Dec 2024 95,791.60 | 3 Jan 2025 96,984.80 | 7 | −$1,193.19 |
| long | 7 Jan 2025 102,236.00 | 8 Jan 2025 96,954.60 | 1 | −$5,281.00 |
| short | 10 Jan 2025 92,552.50 | 15 Jan 2025 96,560.90 | 5 | −$4,008.36 |
| long | 16 Jan 2025 100,497.00 | 27 Jan 2025 102,620.00 | 11 | $2,122.66 |
| short | 29 Jan 2025 101,336.00 | 30 Jan 2025 103,733.00 | 1 | −$2,397.73 |
| short | 1 Feb 2025 102,430.00 | 13 Feb 2025 97,870.00 | 12 | $4,559.56 |
| short | 14 Feb 2025 96,608.10 | 15 Feb 2025 97,500.50 | 1 | −$892.34 |
| short | 19 Feb 2025 95,671.70 | 20 Feb 2025 96,644.40 | 1 | −$972.63 |
| long | 21 Feb 2025 98,305.00 | 22 Feb 2025 96,182.00 | 1 | −$2,123.02 |
| short | 25 Feb 2025 91,552.90 | 3 Mar 2025 94,270.00 | 6 | −$2,717.11 |
| long | 3 Mar 2025 94,270.00 | 4 Mar 2025 86,221.20 | 1 | −$8,048.83 |
| short | 10 Mar 2025 80,734.50 | 16 Mar 2025 84,338.40 | 6 | −$3,603.96 |
| long | 16 Mar 2025 84,338.40 | 17 Mar 2025 82,574.50 | 1 | −$1,763.92 |
| long | 18 Mar 2025 84,010.00 | 19 Mar 2025 82,715.00 | 1 | −$1,294.99 |
| long | 20 Mar 2025 86,845.90 | 29 Mar 2025 84,424.40 | 9 | −$2,421.55 |
| short | 31 Mar 2025 82,390.00 | 2 Apr 2025 85,158.40 | 2 | −$2,768.35 |
| short | 7 Apr 2025 78,430.00 | 10 Apr 2025 82,615.20 | 3 | −$4,185.22 |
| long | 12 Apr 2025 83,423.80 | 30 Apr 2025 94,256.80 | 18 | $10,833.00 |
| long | 2 May 2025 96,489.90 | 4 May 2025 95,856.40 | 2 | −$633.48 |
| long | 9 May 2025 103,262.00 | 15 May 2025 103,508.00 | 6 | $246.22 |
| long | 22 May 2025 109,644.00 | 25 May 2025 107,762.00 | 3 | −$1,882.09 |
| short | 29 May 2025 107,782.00 | 8 Jun 2025 105,552.00 | 10 | $2,229.63 |
| short | 14 Jun 2025 106,067.00 | 24 Jun 2025 105,334.00 | 10 | $732.65 |
| long | 30 Jun 2025 108,357.00 | 1 Jul 2025 107,147.00 | 1 | −$1,210.42 |
| long | 3 Jul 2025 108,850.00 | 5 Jul 2025 107,984.00 | 2 | −$865.34 |
| long | 7 Jul 2025 109,204.00 | 8 Jul 2025 108,263.00 | 1 | −$940.91 |
| long | 9 Jul 2025 108,923.00 | 20 Jul 2025 117,840.00 | 11 | $8,917.02 |
| short | 29 Jul 2025 118,062.00 | 8 Aug 2025 117,472.00 | 10 | $590.30 |
| long | 11 Aug 2025 119,294.00 | 12 Aug 2025 118,686.00 | 1 | −$608.27 |
| long | 13 Aug 2025 120,134.00 | 15 Aug 2025 118,295.00 | 2 | −$1,839.00 |
| short | 16 Aug 2025 117,342.00 | 23 Aug 2025 116,936.00 | 7 | $406.04 |
| short | 24 Aug 2025 115,438.00 | 3 Sep 2025 111,240.00 | 10 | $4,198.05 |
| long | 11 Sep 2025 113,960.00 | 20 Sep 2025 115,632.00 | 9 | $1,672.39 |
| short | 23 Sep 2025 112,651.00 | 30 Sep 2025 114,312.00 | 7 | −$1,660.98 |
| long | 1 Oct 2025 114,049.00 | 11 Oct 2025 112,774.00 | 10 | −$1,274.45 |
| short | 11 Oct 2025 112,774.00 | 24 Oct 2025 110,078.00 | 13 | $2,696.30 |
| long | 27 Oct 2025 114,559.00 | 29 Oct 2025 112,898.00 | 2 | −$1,660.97 |
| short | 4 Nov 2025 106,583.00 | 11 Nov 2025 106,011.00 | 7 | $571.92 |
| short | 14 Nov 2025 99,692.00 | 27 Nov 2025 90,484.00 | 13 | $9,208.02 |
| long | 28 Nov 2025 91,333.90 | 2 Dec 2025 86,286.00 | 4 | −$5,047.93 |
| long | 3 Dec 2025 91,277.90 | 6 Dec 2025 89,330.00 | 3 | −$1,947.84 |
| long | 9 Dec 2025 90,634.40 | 13 Dec 2025 90,268.40 | 4 | −$365.92 |
| short | 16 Dec 2025 86,432.10 | 17 Dec 2025 87,863.40 | 1 | −$1,431.35 |
| short | 18 Dec 2025 86,243.20 | 20 Dec 2025 88,136.90 | 2 | −$1,893.72 |
| long | 22 Dec 2025 88,658.90 | 24 Dec 2025 87,486.00 | 2 | −$1,172.87 |
| long | 25 Dec 2025 87,669.40 | 26 Dec 2025 87,225.30 | 1 | −$444.17 |
| long | 28 Dec 2025 87,877.00 | 30 Dec 2025 87,237.10 | 2 | −$639.87 |
| long | 31 Dec 2025 88,485.50 | 1 Jan 2026 87,648.20 | 1 | −$837.29 |
| long | 2 Jan 2026 88,839.10 | 9 Jan 2026 91,100.00 | 7 | $2,260.95 |
| long | 14 Jan 2026 95,414.00 | 19 Jan 2026 93,673.10 | 5 | −$1,740.85 |
| short | 21 Jan 2026 88,427.70 | 29 Jan 2026 89,300.00 | 8 | −$872.34 |
| short | 30 Jan 2026 84,650.20 | 10 Feb 2026 70,138.00 | 11 | $14,512.20 |
| short | 11 Feb 2026 68,841.30 | 14 Feb 2026 68,854.00 | 3 | −$12.69 |
| long | 26 Feb 2026 67,988.00 | 28 Feb 2026 65,872.10 | 2 | −$2,115.95 |
| long | 1 Mar 2026 66,973.30 | 2 Mar 2026 65,776.50 | 1 | −$1,196.78 |
| long | 3 Mar 2026 68,830.10 | 7 Mar 2026 68,114.00 | 4 | −$716.04 |
| long | 10 Mar 2026 68,432.20 | 19 Mar 2026 71,246.60 | 9 | $2,814.39 |
| short | 28 Mar 2026 66,407.30 | 1 Apr 2026 68,284.50 | 4 | −$1,877.21 |
| short | 3 Apr 2026 66,902.00 | 5 Apr 2026 67,300.40 | 2 | −$398.43 |
| long | 7 Apr 2026 68,853.70 | 20 Apr 2026 73,801.80 | 13 | $4,948.14 |
| long | 23 Apr 2026 78,178.20 | 26 Apr 2026 77,625.00 | 3 | −$553.22 |
| long | 27 Apr 2026 78,657.60 | 28 Apr 2026 77,371.30 | 1 | −$1,286.23 |
| short | 30 Apr 2026 75,780.00 | 1 May 2026 76,346.60 | 1 | −$566.58 |
| long | 6 May 2026 80,905.50 | 13 May 2026 80,504.50 | 7 | −$401.06 |
| short | 14 May 2026 79,313.60 | 15 May 2026 81,090.00 | 1 | −$1,776.39 |
| short | 16 May 2026 79,113.20 | 26 May 2026 77,322.00 | 10 | $1,791.19 |
| short | 27 May 2026 75,930.00 | 12 Jun 2026 63,626.00 | 16 | $12,304.00 |
| short | 26 Jun 2026 59,794.60 | 2 Jul 2026 60,024.00 | 6 | −$229.36 |
| long | 3 Jul 2026 61,560.00 | 14 Jul 2026 62,334.50 | 11 | $774.52 |
| long | 15 Jul 2026 65,044.00 | 24 Jul 2026 65,099.00 | 9 | $54.99 |
| short | 1 Aug 2026 62,887.90 | 3 Aug 2026 63,570.00 | 2 | −$682.13 |
| long | 8 Aug 2026 64,923.20 | 11 Aug 2026 63,970.00 | 3 | −$953.19 |
| short | 12 Aug 2026 63,600.00 | 18 Aug 2026 64,532.10 | 6 | −$932.10 |
| long | 19 Aug 2026 64,725.40 | 29 Aug 2026 77,845.90 | 10 | $13,120.50 |
| short | 10 Sep 2026 78,306.40 | 19 Sep 2026 80,883.90 | 9 | −$2,577.43 |
| long | 20 Sep 2026 81,250.00 | 29 Sep 2026 83,500.00 | 9 | $2,250.02 |
| short | 29 Sep 2026 83,500.00 | 2 Oct 2026 84,880.10 | 3 | −$1,380.04 |
| short | 8 Oct 2026 83,321.80 | 21 Oct 2026 83,028.10 | 13 | $293.67 |
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 |
|---|---|---|---|---|---|
| SPX Scalping Strategy this page | — | v5 strategy | +1.5% | 109 | 5.0% |
| MACD Willy Strategy by PtGambler | rma sma ema highest lowest wma | v5 strategy | No trades on this market | ||
| VuManChu Cipher B + Divergences Strategy by nattichai001 | ema cross lowest highest sma rma wma | v4 strategy | +76.6% | 175 | 18.4% |
| Bagheri IG Ether by Bagheri_IG | ema highest lowest rma sma | v4 strategy | +0.0% | 3 | 0.0% |
| Bagheri IG Ether v2 by Bagheri_IG | ema highest lowest rma sma | v4 strategy | −0.0% | 2 | 0.0% |
| Swing Multi Moving Averages Crypto and Stocks Strategy by exlux99 | ema wma highest lowest sma | v5 strategy | +60.2% | 22 | 13.1% |
Upgrade and export
Written in Pine Script v5. The clean-v5 step types the settings and moves when = into if blocks, which v6 requires; it is run before and after like any upgrade.
- 2 strategy calls use the when = argument (line 66, 67). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
- 2 settings use the untyped input() (line 8, 44). It still compiles in v6; input.int, input.float or input.source state the type.
- No v6-only features. v6 is not needed to run this script.
Same 109 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 8: input() → input.source()
- Line 44: input() → input.bool()
- Line 66: when = sellSignal → if block
- Line 67: when = sellSignal → if block
⋯len1 = 10-src1 = input(close, title="SMA Source #1")+src1 = input.source(close, title="SMA Source #1")out1 = ta.sma(src1, len1)⋯//RSI / SMA RSI-swr=input(true,title="RSI")+swr=input.bool(true,title="RSI")src = close⋯// Submit exit orders-strategy.close("LONG", when=sellSignal)+if sellSignal+ strategy.close("LONG")-strategy.close("SHORT", when=sellSignal)+if sellSignal+ strategy.close("SHORT")Does it run in Pine Script v6?
No
The v6 version runs in Zeal Terminal's engine, but its results differ from the v5 version: Trades differ: 109 before, 58 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.
⋯// © connor2279-//@version=5+//@version=6strategy(title="SPX Strategy", shorttitle="SPXS", overlay=true)⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 27 ms | Yes 1,000 bars in 46 ms | Not measured |
| PineTS | Not tested | Not tested | 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.
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/// USE HEIEN ASHI, 1 min, SPX 500 USD OANDA// © connor2279//@version=5strategy(title="SPX Strategy", shorttitle="SPXS", overlay=true)//SMAlen1 = 10src1 = input(close, title="SMA Source #1")out1 = ta.sma(src1, len1)plot(out1, title="SMA #1", color=close >= out1 ? color.lime : color.red, linewidth=2)data_over = ta.crossover(close, out1)dataO = close >= out1data_under = ta.crossunder(close, out1)dataU = close < out1bgcolor(color=ta.crossover(close, out1) ? color.new(color.lime, 90) : na)bgcolor(color=ta.crossunder(close, out1) ? color.new(color.red, 90) : na) //Norm MacDsma = 12lma = 21tsp = 10np = 50 sh = ta.ema(close,sma) lon= ta.ema(close,lma) ratio = math.min(sh,lon)/math.max(sh,lon)Mac = ratio - 1if(sh>lon) Mac := 2-ratio - 1else Mac := ratio - 1MacNorm = ((Mac-ta.lowest(Mac, np)) /(ta.highest(Mac, np)-ta.lowest(Mac, np)+.000001)*2)- 1MacNorm2 = MacNormif(np<2) MacNorm2 := Macelse MacNorm2 := MacNorm Trigger = ta.wma(MacNorm2, tsp)trigger_above = Trigger >= MacNormtrigger_under = Trigger < MacNormplotshape(ta.crossover(Trigger, MacNorm2), style=shape.triangledown, color=color.red)plotshape(ta.crossunder(Trigger, MacNorm2), style=shape.triangledown, color=color.lime)//RSI / SMA RSIswr=input(true,title="RSI")src = closelen = 14srs = 50up = ta.rma(math.max(ta.change(src), 0), len)down = ta.rma(-math.min(ta.change(src), 0), len)rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))mr = ta.sma(rsi,srs)rsi_above = rsi >= mrrsi_under = rsi < mr//AllbuySignal = rsi_above and trigger_under and dataOshortSignal = rsi_under and trigger_above and dataUbgcolor(color=buySignal ? color.new(color.lime,97) : na) bgcolor(color=shortSignal ? color.new(color.red, 97) : na) sellSignal = ta.cross(close, out1) or ta.cross(Trigger, MacNorm2) or ta.cross(rsi, mr)if (buySignal) strategy.entry("LONG", strategy.long, 1)if (shortSignal) strategy.entry("SHORT", strategy.short, 1)// Submit exit ordersstrategy.close("LONG", when=sellSignal)strategy.close("SHORT", when=sellSignal)