Pine Script v5 · Strategy
TradePro's 2 EMA + Stoch RSI + ATR Strategy
A Pine Script v5 strategy built on EMA (close, 50), RSI (src, 14) and SMA or Stoch (3). It has 4 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 no commission. 23 settings; defaults include Start Year 2011, Start Month 1 and Start Day 1.
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 TradePro's 2 EMA + Stoch RSI + ATR Strategy repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 7 of 7 trades.
- How did TradePro's 2 EMA + Stoch RSI + ATR Strategy do on BTCUSDT 1D with default settings?
- −2.70%
- From 26 Jan 2024 to 21 Oct 2026, over 18 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Does TradePro's 2 EMA + Stoch RSI + ATR 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: 18 before, 9 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 TradePro's 2 EMA + Stoch RSI + ATR Strategy use a stop loss?
- Yes
- strategy.exit sets a stop on line 136, 137.
- Does TradePro's 2 EMA + Stoch RSI + ATR Strategy run in Zeal Terminal?
- Yes
- It compiles in 55 ms and runs 1,000 bars in 122 ms, in the browser.
BTCUSDT · 1D · default settings
- ema1
- ema2
- ATR Short Stop Loss
- ATR Long Stop Loss
- Entry Price
- L PT
- S PT
- L SL
- S SL
- L BE PT
- S BE PT
- L Entry Trigger
- Stoch Cross Up
- Higher low
- S Entry Trigger
- Stoch Cross down
- Net profit
- −2.70%
- −$270.11
- Buy and hold
- +102.5%
- same period
- Closed trades
- 18
- 6 won · 10 lost
- Profitable
- 33.3%
- of closed trades
- Profit factor
- 0.94
- gross profit ÷ gross loss
- Max drawdown
- 21.97%
- −$2,196.73
One run with the author's default settings, $10,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 commission
The backtest assumes free trading. Results on any real exchange will be lower.
-
Check
Every trade uses all the equity
default_qty_value is 100% of equity.
-
Note
1 setting has no label
In the settings dialog be_RR (line 74) shows 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.
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 |
|---|---|---|---|
| Backtesting window | |||
| Start Year | 2011 | int | timestart |
| Start Month | 1 | int · min 1 · max 12 | timestart |
| Start Day | 1 | int · min 1 · max 31 | timestart |
| Finish Year | 2050 | int | timefinish |
| Finish Month | 12 | int · min 1 · max 12 | timefinish |
| Finish Day | 31 | int · min 1 · max 31 | timefinish |
| EMA | |||
| EMA Length 1 | 50 | int | ema1 |
| EMA Length 2 | 200 | int | ema2 |
| Stochastic RSI | |||
| K | 3 | int · min 1 | k |
| D | 3 | int · min 1 | d |
| RSI Length | 14 | int · min 1 | rsi1 |
| Stochastic Length | 14 | int · min 1 | k |
| ATR Stoploss Finder | |||
| Length | 14 | int · min 1 | a up down line 57 line 60 line 63 line 65 |
| Smoothing | EMA | string · options ['RMA', 'SMA', 'EMA', 'WMA'] | line 56 line 59 line 62 |
| Multiplier | 0.7 | float · step 0.1 | a up down |
| Source for upper band | high | source | up |
| Source for lower band | low | source | down |
| Show ATR Bands | true | bool | ATR Short Stop Loss ATR Long Stop Loss |
| Long ATR SL | color.purple | color | ATR Long Stop Loss |
| Short ATR SL | color.purple | color | ATR Short Stop Loss |
| Profit Target | |||
| Reward to Risk ratio (X times SL) | 2.0 | float · step 0.1 | L_PT S_PT |
| Move SL to breakeven when RR hit | true | bool | L_SL S_SL |
| Be RR (no label in the script) | 1.0 | float | L_be_PT S_be_PT |
What it calculates
- EMAclose, EMA Length 1 (50)
ema1 · line 21 - EMAclose, EMA Length 2 (200)
ema2 · line 22 - RSIsrc, RSI Length (14)
rsi1 · line 33 - SMA / Stochta.stoch(rsi1, rsi1, rsi1, lengthStoch), K (3)
k · line 34 - SMAk, D (3)
d · line 35 - Crossunderk, d
stoch_crossdown · line 38 - Crossoverk, d
stoch_crossup · line 39 - Pivothighk, 1, 1
P_hi · line 40 - Pivotlowk, 1, 1
P_lo · line 41 - ValuewhenP_hi, k, 1
previous_high · line 42 - ValuewhenP_lo, k, 1
previous_low · line 43 - ValuewhenP_hi, k, 0
recent_high · line 44 - ValuewhenP_lo, k, 0
recent_low · line 45 - TRtrue
a · line 66 - TRtrue
up · line 67 - TRtrue
down · line 68
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 80 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 | L_entry1 | On | 133 |
| Open Short short | S_entry1 | On | 135 |
| Exit Exit Long stop and limit | every bar | On | 136 |
| Exit Exit Short stop and limit | every bar | On | 137 |
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 | −2.7% | +102.5% | 18 | 33% | 0.94 | 22.0% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +13.6% | +5.5% | 18 | 39% | 2.28 | 4.8% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −38.5% | +9.8% | 17 | 18% | 0.43 | 40.5% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +3.9% | +8.4% | 14 | 21% | 1.37 | 7.3% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | −13.0% | +16.7% | 19 | 26% | 0.78 | 36.5% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | −10.7% | +21.5% | 15 | 20% | 0.59 | 13.6% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | −32.7% | +148.3% | 20 | 15% | 0.43 | 34.6% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +3.8% | +17.1% | 24 | 25% | 1.23 | 8.3% | 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 (D 5, Length 12) made +5.0% before 26 Dec 2025 and +1.3% after it, against −0.0% for the defaults. 50% of the 32 combinations made money in-sample and 28% out-of-sample.
| Length ↓ · D → | 2 | 3 | 4 | 5 |
|---|---|---|---|---|
| 7 | −23% | −2% | +2% | +5% |
| 8 | −22% | −2% | +2% | +5% |
| 10 | −22% | −2% | +2% | +5% |
| 12 | −22% | −2% | +2% | +5% |
| 14 | −22% | −3% | +2% | +5% |
| 17 | −22% | −3% | +1% | +5% |
| 20 | −22% | −3% | +1% | +5% |
| 24 | −22% | −4% | +1% | +5% |
| Length ↓ · D → | 2 | 3 | 4 | 5 |
|---|---|---|---|---|
| 7 | −4% | −0% | −1% | +1% |
| 8 | −4% | −0% | −1% | +1% |
| 10 | −4% | −0% | −1% | +1% |
| 12 | −4% | −0% | −1% | +1% |
| 14 | −4% | −0% | −1% | +2% |
| 17 | −4% | −0% | −1% | +2% |
| 20 | −4% | −0% | −1% | +2% |
| 24 | −2% | +2% | +2% | −3% |
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 | 4 | 75% | $2,058.26 |
| Sideways market | 8 | 25% | −$780.83 |
| Falling market | 6 | 17% | −$1,547.54 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
30.7%
The 95th percentile of the worst drawdown when the same 18 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 14.5% to 30.7%; the tick is what actually happened, 21.0%. Order luck alone moves it this much.
All 18 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| short | 6 Sep 2024 56,180.00 | 13 Sep 2024 60,023.70 | 7 | −$684.18 |
| short | 10 Oct 2024 60,636.00 | 14 Oct 2024 63,856.40 | 4 | −$494.77 |
| long | 13 Jan 2025 94,545.10 | 13 Jan 2025 91,456.00 | 0 | −$288.21 |
| long | 20 Feb 2025 96,644.40 | 24 Feb 2025 93,095.40 | 4 | −$313.34 |
| long | 1 Mar 2025 84,349.90 | 4 Mar 2025 84,349.90 | 3 | $0.00 |
| long | 6 Apr 2025 83,538.00 | 6 Apr 2025 80,250.90 | 0 | −$323.43 |
| long | 18 Apr 2025 84,947.90 | 22 Apr 2025 92,161.80 | 4 | $670.54 |
| long | 24 Jun 2025 105,334.00 | 14 Jul 2025 121,909.00 | 20 | $1,348.06 |
| long | 23 Aug 2025 116,936.00 | 25 Aug 2025 109,412.00 | 2 | −$637.91 |
| long | 29 Sep 2025 112,164.00 | 3 Oct 2025 121,328.00 | 4 | $757.93 |
| long | 3 Nov 2025 110,541.00 | 3 Nov 2025 107,219.00 | 0 | −$301.58 |
| short | 17 Jan 2026 95,550.90 | 20 Jan 2026 91,525.70 | 3 | $410.02 |
| short | 27 Mar 2026 68,820.30 | 10 Apr 2026 73,369.70 | 14 | −$670.51 |
| short | 13 Apr 2026 70,741.60 | 13 Apr 2026 74,774.00 | 0 | −$539.97 |
| short | 26 Apr 2026 77,625.00 | 27 Apr 2026 79,373.30 | 1 | −$201.19 |
| short | 13 May 2026 80,504.50 | 23 May 2026 75,286.20 | 10 | $565.97 |
| short | 24 Jul 2026 65,099.00 | 7 Aug 2026 65,099.00 | 14 | $0.00 |
| short | 7 Sep 2026 80,341.80 | 10 Sep 2026 76,604.90 | 3 | $432.45 |
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 |
|---|---|---|---|---|---|
| TradePro's 2 EMA + Stoch RSI + ATR Strategy this page | — | v5 strategy | −2.7% | 18 | 22.0% |
| X48 - Strategy - MA Type Cross + TPSL - Future&Spot - V.2 by X4815162342 | ema rsi sma pivothigh pivotlow valuewhen | v5 strategy | does not run in Zeal Terminal | ||
| RSI Divergence X Ichimoku Cloud X 200EMA by tradethrills | ema rsi pivotlow pivothigh | v4 strategy | −196,793.0% | 7 | 1,854.6% |
| Alert(), alertcondition() or strategy alerts- by Peter_O | sma pivothigh pivotlow valuewhen | v4 strategy | +7,640,000.0% | 191 | 919.9% |
| Quantitative Trend Strategy- Uptrend long by CheatCode1 | sma pivothigh pivotlow valuewhen | v5 strategy | +5.9% | 28 | 32.8% |
| Moving Stop-Loss mechanism + alerts to MT4-MT5 by Peter_O | sma pivothigh pivotlow valuewhen | v5 strategy | −9,857,600.0% | 191 | 4,436.8% |
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.
- 4 settings use the untyped input() (line 6, 9, 50, 51). 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 18 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 6: input() → input.int()
- Line 9: input() → input.int()
- Line 50: input() → input.source()
- Line 51: input() → input.source()
⋯// ********************************** Trade Period / Strategy Setting **************************************-startY = input(title='Start Year', defval=2011, group = "Backtesting window")+startY = input.int(title='Start Year', defval=2011, group = "Backtesting window")startM = input.int(title='Start Month', defval=1, minval=1, maxval=12, group = "Backtesting window")startD = input.int(title='Start Day', defval=1, minval=1, maxval=31, group = "Backtesting window")-finishY = input(title='Finish Year', defval=2050, group = "Backtesting window")+finishY = input.int(title='Finish Year', defval=2050, group = "Backtesting window")finishM = input.int(title='Finish Month', defval=12, minval=1, maxval=12, group = "Backtesting window")⋯m = input.float(0.7, 'Multiplier', step = 0.1, group = group_atr)-src1 = input(high, "Source for upper band", group = group_atr)+src1 = input.source(high, "Source for upper band", group = group_atr)-src2 = input(low, "Source for lower band", group = group_atr)+src2 = input.source(low, "Source for lower band", group = group_atr)showatr = input.bool(true, 'Show ATR Bands', group = group_atr)⋯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: 18 before, 9 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.
⋯// © PtGambler-//@version=5+//@version=6strategy("2 EMA + Stoch RSI + ATR [Pt]", shorttitle = "2EMA+Stoch+ATR", overlay=true, initial_capital = 10000, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, calc_on_order_fills = false, max_bars_back = 500)⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 55 ms | Yes 1,000 bars in 122 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/// © PtGambler//@version=5strategy("2 EMA + Stoch RSI + ATR [Pt]", shorttitle = "2EMA+Stoch+ATR", overlay=true, initial_capital = 10000, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, calc_on_order_fills = false, max_bars_back = 500)// ********************************** Trade Period / Strategy Setting **************************************startY = input(title='Start Year', defval=2011, group = "Backtesting window")startM = input.int(title='Start Month', defval=1, minval=1, maxval=12, group = "Backtesting window")startD = input.int(title='Start Day', defval=1, minval=1, maxval=31, group = "Backtesting window")finishY = input(title='Finish Year', defval=2050, group = "Backtesting window")finishM = input.int(title='Finish Month', defval=12, minval=1, maxval=12, group = "Backtesting window")finishD = input.int(title='Finish Day', defval=31, minval=1, maxval=31, group = "Backtesting window")timestart = timestamp(startY, startM, startD, 00, 00)timefinish = timestamp(finishY, finishM, finishD, 23, 59)// ******************************************************************************************group_ema = "EMA"group_stoch = "Stochastic RSI"group_atr = "ATR Stoploss Finder"// ----------------------------------------- 2 EMA -------------------------------------ema1_len = input.int(50, "EMA Length 1", group = group_ema)ema2_len = input.int(200, "EMA Length 2", group = group_ema)ema1 = ta.ema(close, ema1_len)ema2 = ta.ema(close, ema2_len)plot(ema1, "ema1", color.white, linewidth = 2)plot(ema2, "ema2", color.orange, linewidth = 2)ema_bull = ema1 > ema2ema_bear = ema1 < ema2// -------------------------------------- Stochastic RSI -----------------------------smoothK = input.int(3, "K", minval=1, group = group_stoch)smoothD = input.int(3, "D", minval=1, group = group_stoch)lengthRSI = input.int(14, "RSI Length", minval=1, group = group_stoch)lengthStoch = input.int(14, "Stochastic Length", minval=1, group = group_stoch)src = closersi1 = ta.rsi(src, lengthRSI)k = ta.sma(ta.stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)d = ta.sma(k, smoothD)var trigger_stoch_OB = k > 80var trigger_stoch_OS = k < 20stoch_crossdown = ta.crossunder(k, d)stoch_crossup = ta.crossover(k, d)P_hi = ta.pivothigh(k,1,1)P_lo = ta.pivotlow(k,1,1)previous_high = ta.valuewhen(P_hi, k, 1)previous_low = ta.valuewhen(P_lo, k, 1)recent_high = ta.valuewhen(P_hi, k, 0)recent_low = ta.valuewhen(P_lo, k, 0)// --------------------------------------- ATR stop loss finder ------------------------length = input.int(title='Length', defval=14, minval=1, group = group_atr)smoothing = input.string(title='Smoothing', defval='EMA', options=['RMA', 'SMA', 'EMA', 'WMA'], group = group_atr)m = input.float(0.7, 'Multiplier', step = 0.1, group = group_atr)src1 = input(high, "Source for upper band", group = group_atr)src2 = input(low, "Source for lower band", group = group_atr)showatr = input.bool(true, 'Show ATR Bands', group = group_atr)collong = input.color(color.purple, 'Long ATR SL', inline='1', group = group_atr)colshort = input.color(color.purple, 'Short ATR SL', inline='2', group = group_atr)ma_function(source, length) => if smoothing == 'RMA' ta.rma(source, length) else if smoothing == 'SMA' ta.sma(source, length) else if smoothing == 'EMA' ta.ema(source, length) else ta.wma(source, length)a = ma_function(ta.tr(true), length) * mup = ma_function(ta.tr(true), length) * m + src1down = src2 - ma_function(ta.tr(true), length) * mp1 = plot(showatr ? up : na, title='ATR Short Stop Loss', color=colshort)p2 = plot(showatr ? down : na, title='ATR Long Stop Loss', color=collong)// ******************************* Profit Target / Stop Loss *********************************************RR = input.float(2.0, "Reward to Risk ratio (X times SL)", step = 0.1, group = "Profit Target")breakeven = input.bool(true, "Move SL to breakeven when RR hit", group = "Profit Target", inline = 'breakenven')be_RR = input.float(1.0, "", inline = 'breakeven', group = "Profit Target")var L_PT = 0.0var S_PT = 0.0var L_SL = 0.0var S_SL = 0.0var L_be_PT = 0.0var S_be_PT = 0.0BSLE = ta.barssince(strategy.opentrades.entry_bar_index(0) == bar_index)entry_price = strategy.position_size != 0 ? strategy.opentrades.entry_price(0) : naif strategy.position_size > 0 //and BSLE == 1 L_PT := L_PT[1] L_SL := (breakeven and high >= L_be_PT) ? entry_price : L_SL[1] S_PT := close - (up - close)*RR S_SL := up L_be_PT := L_be_PT[1] S_be_PT := close - (up - close)*be_RRelse if strategy.position_size < 0 //and BSLE == 1 S_PT := S_PT[1] S_SL := (breakeven and low <= S_be_PT) ? entry_price : S_SL[1] L_PT := close + (close-down)*RR L_SL := down S_be_PT := S_be_PT[1] L_be_PT := close + (close-down)*be_RRelse if strategy.position_size != 0 L_PT := L_PT[1] S_PT := S_PT[1]else L_PT := close + (close-down)*RR L_SL := down S_PT := close - (up - close)*RR S_SL := up L_be_PT := close + (close-down)*be_RR S_be_PT := close - (up - close)*be_RRentry_line = plot(entry_price, "Entry Price", color.white, linewidth = 1, style = plot.style_linebr)L_PT_line = plot(strategy.position_size > 0 and BSLE > 0 ? L_PT : na, "L PT", color.green, linewidth = 2, style = plot.style_linebr)S_PT_line = plot(strategy.position_size < 0 and BSLE > 0 ? S_PT : na, "S PT", color.green, linewidth = 2, style = plot.style_linebr)L_SL_line = plot(strategy.position_size > 0 and BSLE > 0 ? L_SL : na, "L SL", color.red, linewidth = 2, style = plot.style_linebr)S_SL_line = plot(strategy.position_size < 0 and BSLE > 0 ? S_SL : na, "S SL", color.red, linewidth = 2, style = plot.style_linebr)L_be_PT_line = plot(strategy.position_size > 0 and BSLE > 0 ? L_be_PT : na, "L BE PT", color.blue, linewidth = 2, style = plot.style_linebr)S_be_PT_line = plot(strategy.position_size < 0 and BSLE > 0 ? S_be_PT : na, "S BE PT", color.blue, linewidth = 2, style = plot.style_linebr)fill(L_PT_line, entry_line, color = color.new(color.green,90))fill(S_PT_line, entry_line, color = color.new(color.green,90))fill(L_SL_line, entry_line, color = color.new(color.red,90))fill(S_SL_line, entry_line, color = color.new(color.red,90))// ---------------------------------- strategy setup ------------------------------------------------------var L_entry_trigger1 = falsevar S_entry_trigger1 = falseL_entry_trigger1 := ema_bull and close < ema1 and k < 20 and strategy.position_size == 0S_entry_trigger1 := ema_bear and close > ema1 and k > 80 and strategy.position_size == 0L_entry1 = L_entry_trigger1[1] and stoch_crossup and recent_low > previous_lowS_entry1 = S_entry_trigger1[1] and stoch_crossdown and recent_high < previous_high//debuggingplot(L_entry_trigger1[1]?1:0, "L Entry Trigger")plot(stoch_crossup?1:0, "Stoch Cross Up")plot(recent_low > previous_low?1:0, "Higher low")plot(S_entry_trigger1[1]?1:0, "S Entry Trigger")plot(stoch_crossdown?1:0, "Stoch Cross down")plot(recent_high < previous_high?1:0, "Lower high")if L_entry1 strategy.entry("Long", strategy.long)if S_entry1 strategy.entry("Short", strategy.short)strategy.exit("Exit Long", "Long", limit = L_PT, stop = L_SL, comment_profit = "Exit Long, PT hit", comment_loss = "Exit Long, SL hit")strategy.exit("Exit Short", "Short", limit = S_PT, stop = S_SL, comment_profit = "Exit Short, PT hit", comment_loss = "Exit Short, SL hit")//resetting triggersL_entry_trigger1 := L_entry_trigger1[1] ? L_entry1 or ema_bear or S_entry1 ? false : true : L_entry_trigger1S_entry_trigger1 := S_entry_trigger1[1] ? S_entry1 or ema_bull or L_entry1 ? false : true : S_entry_trigger1//Trigger zonesbgcolor(L_entry_trigger1 ? color.new(color.green ,90) : na)bgcolor(S_entry_trigger1 ? color.new(color.red,90) : na)