Pine Script v4 · Strategy
MACD,RSI & EMA strategy with MA+PSAR by MAM
A Pine Script v4 strategy built on SAR (0.02, 0.02), EMA (close, 5) and RSI (close, 14). It has 2 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. 16 settings; defaults include EMA1 length 5, EMA2 length 20 and MACD Fast 12.
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 MACD,RSI & EMA strategy with MA+PSAR by MAM repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 11 of 11 trades.
- How did MACD,RSI & EMA strategy with MA+PSAR by MAM do on BTCUSDT 1D with default settings?
- −35.17%
- From 26 Jan 2024 to 21 Oct 2026, over 40 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Can MACD,RSI & EMA strategy with MA+PSAR by MAM be converted to Pine Script v5?
- Yes
- The upgrade takes 1 step, from v4; each was run before and after on the same candles with identical results, and the v5 script can be downloaded below.
- Does MACD,RSI & EMA strategy with MA+PSAR by MAM use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does MACD,RSI & EMA strategy with MA+PSAR by MAM run in Zeal Terminal?
- Yes
- It compiles in 13 ms and runs 1,000 bars in 53 ms, in the browser.
BTCUSDT · 1D · default settings
- SMA1
- SMA2
- SMA3
- SMA4
- Plot
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- −35.17%
- −$35,170.90
- Buy and hold
- +102.5%
- same period
- Closed trades
- 40
- 15 won · 25 lost
- Profitable
- 37.5%
- of closed trades
- Profit factor
- 0.77
- gross profit ÷ gross loss
- Max drawdown
- 65.96%
- −$68,864.10
One run with the author's default settings, $100,000 starting capital, commission as the script sets it. A short position was still open at the last bar. 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
3 settings have no label
In the settings dialog PSAR_start (line 31), PSAR_increment (line 32), PSAR_maximum (line 33) show an empty name. The labels on this page come from the variable names.
-
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 sma → ta.sma, sar → ta.sar, ema → ta.ema, rsi → ta.rsi.
v4 → v5
VerifiedSame 40 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 3: //@version=4 → //@version=5
- Line 19: sma → ta.sma
- Line 21: sma → ta.sma
- Line 23: sma → ta.sma
- Line 25: sma → ta.sma
- Line 34: sar → ta.sar
7 more edits
- Line 36: ema → ta.ema
- Line 37: ema → ta.ema
- Line 43: ema → ta.ema
- Line 43: ema → ta.ema
- Line 44: ema → ta.ema
- Line 45: rsi → ta.rsi
- Line 46: ema → ta.ema
⋯// © maizirul959-//@version=4+//@version=5strategy("MACD,RSI & EMA strategy with MA+PSAR by MAM", overlay=true)⋯SMA1 = if _sma_len1 != 0- sma(src, _sma_len1)+ ta.sma(src, _sma_len1)SMA2 = if _sma_len2 != 0- sma(src, _sma_len2)+ ta.sma(src, _sma_len2)SMA3 = if _sma_len3 != 0- sma(src, _sma_len3)+ ta.sma(src, _sma_len3)SMA4 = if _sma_len4 != 0- sma(src, _sma_len4)+ ta.sma(src, _sma_len4)//__________________________________________________________________________⋯PSAR_maximum = input(0.2)-psar = sar(PSAR_start, PSAR_increment, PSAR_maximum)+psar = ta.sar(PSAR_start, PSAR_increment, PSAR_maximum)//_________________________________________________________________________-_ema1 = ema(close, _ema_len1)+_ema1 = ta.ema(close, _ema_len1)-_ema2 = ema(close, _ema_len2)+_ema2 = ta.ema(close, _ema_len2)//_________________________________________________________________________⋯//_________________________________________________________________________-_macd = ema(close, _macd_fast) - ema(close, _macd_slow)+_macd = ta.ema(close, _macd_fast) - ta.ema(close, _macd_slow)-_macd_signal = ema(_macd, _macd_signal_len)+_macd_signal = ta.ema(_macd, _macd_signal_len)-_rsi = rsi(close, _rsi_len)+_rsi = ta.rsi(close, _rsi_len)-_rsi_signal = ema(_rsi, _rsi_signal_len)+_rsi_signal = ta.ema(_rsi, _rsi_signal_len)//PLOT SMA⋯Same 40 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 6: input() → input.int()
- Line 7: input() → input.int()
- Line 8: input() → input.int()
- Line 9: input() → input.int()
- Line 10: input() → input.int()
- Line 12: input() → input.int()
10 more edits
- Line 13: input() → input.int()
- Line 14: input() → input.int()
- Line 15: input() → input.int()
- Line 16: input() → input.int()
- Line 17: input() → input.source()
- Line 27: input() → input.int()
- Line 28: input() → input.int()
- Line 31: input() → input.float()
- Line 32: input() → input.float()
- Line 33: input() → input.float()
⋯//Input Data-_ema_len1 = input(5, title="EMA1 length")+_ema_len1 = input.int(5, title="EMA1 length")-_ema_len2 = input(20, title="EMA2 length")+_ema_len2 = input.int(20, title="EMA2 length")-_macd_fast = input(12, title="MACD Fast")+_macd_fast = input.int(12, title="MACD Fast")-_macd_slow = input(26, title="MACD Slow")+_macd_slow = input.int(26, title="MACD Slow")-_macd_signal_len = input(20, title="MACD Signal length")+_macd_signal_len = input.int(20, title="MACD Signal length")//MAM add SMA-_sma_len1 = input(5, title="SMA1 Length")+_sma_len1 = input.int(5, title="SMA1 Length")-_sma_len2 = input(10, title="SMA2 Length")+_sma_len2 = input.int(10, title="SMA2 Length")-_sma_len3 = input(50, title="SMA3 Length")+_sma_len3 = input.int(50, title="SMA3 Length")-_sma_len4 = input(200, title="SMA4 Length")+_sma_len4 = input.int(200, title="SMA4 Length")-lineWidth = input(1, minval=1, title="Line width")+lineWidth = input.int(1, minval=1, title="Line width")-src = input(close, title="Source")+src = input.source(close, title="Source")SMA1 = if _sma_len1 != 0⋯//__________________________________________________________________________-_rsi_len = input(14, title="RSI length")+_rsi_len = input.int(14, title="RSI length")-_rsi_signal_len = input(20, title="RSI signal length")+_rsi_signal_len = input.int(20, title="RSI signal length")//_________________________________________________________________________//MAM Add PSAR-PSAR_start = input(0.02)+PSAR_start = input.float(0.02)-PSAR_increment = input(0.02)+PSAR_increment = input.float(0.02)-PSAR_maximum = input(0.2)+PSAR_maximum = input.float(0.2)psar = ta.sar(PSAR_start, PSAR_increment, PSAR_maximum)⋯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: 40 before, 148 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.
⋯// © maizirul959-//@version=5+//@version=6strategy("MACD,RSI & EMA strategy with MA+PSAR by MAM", overlay=true)⋯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 |
|---|---|---|---|
| EMA1 length | 5 | int | _ema1 |
| EMA2 length | 20 | int | _ema2 |
| MACD Fast | 12 | int | _macd |
| MACD Slow | 26 | int | _macd |
| MACD Signal length | 20 | int | _macd_signal |
| SMA1 Length | 5 | int | SMA1 |
| SMA2 Length | 10 | int | SMA2 |
| SMA3 Length | 50 | int | SMA3 |
| SMA4 Length | 200 | int | SMA4 |
| Line width | 1 | int · min 1 | SMA1 SMA2 SMA3 SMA4 |
| Source | close | source | SMA1 SMA2 SMA3 SMA4 |
| RSI length | 14 | int | _rsi |
| RSI signal length | 20 | int | _rsi_signal |
| PSAR start (no label in the script) | 0.02 | float | psar |
| PSAR increment (no label in the script) | 0.02 | float | psar |
| PSAR maximum (no label in the script) | 0.2 | float | psar |
What it calculates
- SAR (
sar,ta.sarin v5)PSAR start (0.02), PSAR increment (0.02), PSAR maximum (0.2)psar · line 34 - EMA (
ema,ta.emain v5)close, EMA1 length (5)_ema1 · line 36 - EMA (
ema,ta.emain v5)close, EMA2 length (20)_ema2 · line 37 - EMA (
ema,ta.emain v5)close, MACD Fast (12)_macd · line 43 - EMA (
ema,ta.emain v5)_macd, MACD Signal length (20)_macd_signal · line 44 - RSI (
rsi,ta.rsiin v5)close, RSI length (14)_rsi · line 45 - EMA (
ema,ta.emain v5)_rsi, RSI signal length (20)_rsi_signal · line 46
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 Buy long | (longCondition) | On | 62 |
| Open Sell short | (shortCondition) | On | 65 |
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 | −35.2% | +102.5% | 40 | 38% | 0.77 | 66.0% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +8.7% | +5.5% | 47 | 30% | 1.23 | 13.7% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +0.0% | +9.8% | 38 | 34% | 1.00 | 3.1% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +0.3% | +8.4% | 43 | 35% | 1.21 | 0.7% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +0.1% | +16.7% | 40 | 45% | 1.33 | 0.1% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +0.0% | +21.5% | 43 | 33% | 1.08 | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +0.1% | +148.3% | 40 | 33% | 1.14 | 0.5% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +0.1% | +17.1% | 49 | 43% | 1.55 | 0.1% | 8 May 2026 – 21 Oct 2026 |
Backtests are simulations on historical data and are not investment advice.
Settings heatmap
Two settings that feed the entry signal, moved around their defaults. The best in-sample pair (EMA1 length 3, EMA2 length 24) made +13.8% before 26 Dec 2025 and +4.5% after it, worse than the defaults' +8.0% after. Tuning on the past did not carry forward. 25% of the 48 combinations made money in-sample and 90% out-of-sample.
| EMA2 length ↓ · EMA1 length → | 3 | 4 | 5 | 6 | 7 | 9 |
|---|---|---|---|---|---|---|
| 10 | −28% | −28% | −28% | −28% | −28% | −28% |
| 12 | −32% | −32% | −32% | −32% | −32% | −32% |
| 14 | −37% | −37% | −37% | −37% | −37% | −37% |
| 17 | −37% | −37% | −37% | −37% | −37% | −37% |
| 20 | −43% | −43% | −43% | −43% | −43% | −43% |
| 24 | +14% | +14% | +14% | +14% | +14% | +14% |
| 28 | +4% | +4% | +4% | +4% | +4% | +4% |
| 34 | −10% | −10% | −10% | −10% | −10% | −10% |
| EMA2 length ↓ · EMA1 length → | 3 | 4 | 5 | 6 | 7 | 9 |
|---|---|---|---|---|---|---|
| 10 | +8% | +8% | +8% | +8% | +8% | +10% |
| 12 | +8% | +8% | +8% | +8% | +8% | +10% |
| 14 | +8% | +8% | +8% | +8% | +8% | +6% |
| 17 | +8% | +8% | +8% | +8% | +8% | +6% |
| 20 | +8% | +8% | +8% | +8% | +8% | +6% |
| 24 | +4% | +5% | +5% | +5% | +5% | +0% |
| 28 | +4% | +5% | +5% | +5% | +5% | +0% |
| 34 | −4% | −4% | −4% | −4% | −4% | +10% |
Net P&L of trades opened in each period, as a share of starting capital. marks the defaults and the best in-sample cell. Hover a cell for its trade count. 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 | 10 | 40% | −$29,060.70 |
| Sideways market | 20 | 45% | $6,867.09 |
| Falling market | 10 | 20% | −$12,977.30 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
77.1%
The 95th percentile of the worst drawdown when the same 40 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 49.6% to 77.1%; the tick is what actually happened, 63.2%. Order luck alone moves it this much.
All 40 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| short | 20 Mar 2024 61,937.40 | 16 May 2024 66,206.50 | 57 | −$4,269.10 |
| long | 16 May 2024 66,206.50 | 12 Jun 2024 67,314.20 | 27 | $1,107.72 |
| short | 12 Jun 2024 67,314.20 | 15 Jul 2024 60,797.90 | 33 | $6,516.32 |
| long | 15 Jul 2024 60,797.90 | 3 Aug 2024 61,498.30 | 19 | $700.43 |
| short | 3 Aug 2024 61,498.30 | 22 Aug 2024 61,156.00 | 19 | $342.31 |
| long | 22 Aug 2024 61,156.00 | 2 Sep 2024 57,301.80 | 11 | −$3,854.26 |
| short | 2 Sep 2024 57,301.80 | 14 Sep 2024 60,498.00 | 12 | −$3,196.22 |
| long | 14 Sep 2024 60,498.00 | 4 Oct 2024 60,752.70 | 20 | $254.73 |
| short | 4 Oct 2024 60,752.70 | 15 Oct 2024 66,084.00 | 11 | −$5,331.28 |
| long | 15 Oct 2024 66,084.00 | 5 Nov 2024 67,850.00 | 21 | $1,766.01 |
| short | 5 Nov 2024 67,850.00 | 17 Jan 2025 99,987.30 | 73 | −$32,137.30 |
| long | 17 Jan 2025 99,987.30 | 2 Feb 2025 100,636.00 | 16 | $648.36 |
| short | 2 Feb 2025 100,636.00 | 25 Mar 2025 87,498.20 | 51 | $13,137.50 |
| long | 25 Mar 2025 87,498.20 | 8 Apr 2025 79,163.20 | 14 | −$8,334.92 |
| short | 8 Apr 2025 79,163.20 | 12 Apr 2025 83,423.80 | 4 | −$4,260.59 |
| long | 12 Apr 2025 83,423.80 | 31 May 2025 103,985.00 | 49 | $20,561.60 |
| short | 31 May 2025 103,985.00 | 30 Jun 2025 108,357.00 | 30 | −$4,371.46 |
| long | 30 Jun 2025 108,357.00 | 2 Jul 2025 105,681.00 | 2 | −$2,675.80 |
| short | 2 Jul 2025 105,681.00 | 3 Jul 2025 108,850.00 | 1 | −$3,168.46 |
| long | 3 Jul 2025 108,850.00 | 1 Aug 2025 115,764.00 | 29 | $6,914.48 |
| short | 1 Aug 2025 115,764.00 | 14 Aug 2025 123,306.00 | 13 | −$7,542.37 |
| long | 14 Aug 2025 123,306.00 | 16 Aug 2025 117,342.00 | 2 | −$5,964.40 |
| short | 16 Aug 2025 117,342.00 | 11 Sep 2025 113,960.00 | 26 | $3,382.04 |
| long | 11 Sep 2025 113,960.00 | 26 Sep 2025 108,994.00 | 15 | −$4,965.51 |
| short | 26 Sep 2025 108,994.00 | 2 Oct 2025 118,595.00 | 6 | −$9,600.50 |
| long | 2 Oct 2025 118,595.00 | 12 Oct 2025 110,644.00 | 10 | −$7,950.59 |
| short | 12 Oct 2025 110,644.00 | 28 Oct 2025 114,108.00 | 16 | −$3,463.25 |
| long | 28 Oct 2025 114,108.00 | 31 Oct 2025 108,323.00 | 3 | −$5,784.78 |
| short | 31 Oct 2025 108,323.00 | 3 Jan 2026 89,995.10 | 64 | $18,327.70 |
| long | 3 Jan 2026 89,995.10 | 22 Jan 2026 89,454.70 | 19 | −$540.41 |
| short | 22 Jan 2026 89,454.70 | 5 Mar 2026 72,666.80 | 42 | $16,788.00 |
| long | 5 Mar 2026 72,666.80 | 29 Mar 2026 66,377.00 | 24 | −$6,289.73 |
| short | 29 Mar 2026 66,377.00 | 7 Apr 2026 68,853.70 | 9 | −$2,476.62 |
| long | 7 Apr 2026 68,853.70 | 16 May 2026 79,113.20 | 39 | $10,259.50 |
| short | 16 May 2026 79,113.20 | 6 Jul 2026 63,650.00 | 51 | $15,463.20 |
| long | 6 Jul 2026 63,650.00 | 2 Aug 2026 62,823.70 | 27 | −$826.36 |
| short | 2 Aug 2026 62,823.70 | 7 Aug 2026 64,323.60 | 5 | −$1,499.96 |
| long | 7 Aug 2026 64,323.60 | 13 Aug 2026 63,480.00 | 6 | −$843.62 |
| short | 13 Aug 2026 63,480.00 | 24 Sep 2026 84,397.60 | 42 | −$20,917.60 |
| long | 24 Sep 2026 84,397.60 | 8 Oct 2026 83,321.80 | 14 | −$1,075.79 |
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 |
|---|---|---|---|---|---|
| MACD,RSI & EMA strategy with MA+PSAR by MAM this page | — | v4 strategy | −35.2% | 40 | 66.0% |
| PSAR + EMA-TEMA-RSI-OBV by UnknownUnicorn19826629 | ema sar rsi | v4 strategy | No trades on this market | ||
| RSI Cross [xaurr] by livetrend | rsi ema | v4 strategy | +24.4% | 53 | 35.3% |
| Bitpanda Coinrule Template by joshuajcoop01 | rsi ema | v5 strategy | −2.8% | 4 | 4.6% |
| RSI with Slow and Fast MA Crossing Strategy (by Coinrule) by Coinrule | rsi ema | v5 strategy | −2.8% | 4 | 4.6% |
| RSI of VWAP by mohanee | rsi ema | v4 strategy | No trades on this market | ||
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 13 ms | Yes 1,000 bars in 53 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/// © maizirul959//@version=4strategy("MACD,RSI & EMA strategy with MA+PSAR by MAM", overlay=true)//Input Data_ema_len1 = input(5, title="EMA1 length")_ema_len2 = input(20, title="EMA2 length")_macd_fast = input(12, title="MACD Fast")_macd_slow = input(26, title="MACD Slow")_macd_signal_len = input(20, title="MACD Signal length")//MAM add SMA_sma_len1 = input(5, title="SMA1 Length")_sma_len2 = input(10, title="SMA2 Length")_sma_len3 = input(50, title="SMA3 Length")_sma_len4 = input(200, title="SMA4 Length")lineWidth = input(1, minval=1, title="Line width")src = input(close, title="Source")SMA1 = if _sma_len1 != 0 sma(src, _sma_len1)SMA2 = if _sma_len2 != 0 sma(src, _sma_len2)SMA3 = if _sma_len3 != 0 sma(src, _sma_len3)SMA4 = if _sma_len4 != 0 sma(src, _sma_len4)//___________________________________________________________________________rsi_len = input(14, title="RSI length")_rsi_signal_len = input(20, title="RSI signal length")//_________________________________________________________________________//MAM Add PSARPSAR_start = input(0.02)PSAR_increment = input(0.02)PSAR_maximum = input(0.2)psar = sar(PSAR_start, PSAR_increment, PSAR_maximum)//__________________________________________________________________________ema1 = ema(close, _ema_len1)_ema2 = ema(close, _ema_len2)//_________________________________________________________________________//MAM add SMA//_sma1 = sma(close, _sma_len1)//_sma2 = sma(close, _sma_len2)//__________________________________________________________________________macd = ema(close, _macd_fast) - ema(close, _macd_slow)_macd_signal = ema(_macd, _macd_signal_len)_rsi = rsi(close, _rsi_len)_rsi_signal = ema(_rsi, _rsi_signal_len)//PLOT SMAplot(SMA1, color=#B71C1C, title="SMA1", linewidth=lineWidth)plot(SMA2, color=#FFFF00, title="SMA2", linewidth=lineWidth)plot(SMA3, color=#5b34ff, title="SMA3", linewidth=lineWidth)plot(SMA4, color=#d7d7d7, title="SMA4", linewidth=lineWidth)//PLOT PSAR//plot(psar, "ParabolicSAR", style=plot.style_cross, color=#3A6CA8)pc = close < psar ? color.red : color.greenplot(psar, style=plot.style_cross, color=pc)//plot(_rsi, color=color.yellow)//plot(_rsi_signal, color=color.green)//plot(_macd, color=color.blue)//plot(_macd_signal, color=color.red)longCondition = close > _ema1 and close > _ema2 and _macd > _macd_signal and _rsi > _rsi_signal and _rsi > 50 and _rsi < 70if (longCondition) strategy.entry("Buy",strategy.long)shortCondition = close < _ema1 and close <_ema2 and _macd < _macd_signal and _rsi < _rsi_signal if (shortCondition) strategy.entry("Sell",strategy.short) //bcol = longCondition ? color.green : shortCondition ? color.orange : na//bgcolor(bcol)