Pine Script v5 · Strategy
rt maax EMA cross strategy
A Pine Script v5 strategy built on EMA (close, 50), Crossover (fema, fastema) and Crossunder (fema, fastema). 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 100000 in cash and pays 0.27% commission. 7 settings; defaults include From Month 1, From Day 1 and From Year 2021.
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 rt maax EMA cross strategy repaint?
- No
- No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
- How did rt maax EMA cross strategy do on BTCUSDT 1D with default settings?
- −6.70%
- From 26 Jan 2024 to 21 Oct 2026, over 1 closed trade, against +102.5% for buy and hold. A backtest, not investment advice.
- Does rt maax EMA cross 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: 1 before, 1 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 rt maax EMA cross strategy use a stop loss?
- Yes
- strategy.exit sets a stop on line 27, 36.
- Does rt maax EMA cross strategy run in Zeal Terminal?
- Yes
- It compiles in 12 ms and runs 1,000 bars in 22 ms, in the browser.
BTCUSDT · 1D · default settings
- EMA
- EMA
- EMA
- Crossover
- Crossunder
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- −6.70%
- −$6,702.52
- Buy and hold
- +102.5%
- same period
- Closed trades
- 1
- 0 won · 1 lost
- Profitable
- 0.0%
- of closed trades
- Profit factor
- 0.00
- gross profit ÷ gross loss
- Max drawdown
- 14.51%
- −$14,507.50
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
7 settings do nothing
“From Month”, “From Day”, “From Year”, “Thru Month”, “Thru Day”, “Thru Year”, “Show Date Range” are declared but never read.
-
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 |
|---|---|---|---|
| From Month | 1 | int · min 1 · max 12 | unused |
| From Day | 1 | int · min 1 · max 31 | unused |
| From Year | 2021 | int · min 1970 | unused |
| Thru Month | 10 | int · min 1 · max 12 | unused |
| Thru Day | 25 | int · min 1 · max 31 | unused |
| Thru Year | 2112 | int · min 1970 | unused |
| Show Date Range | true | bool | unused |
What it calculates
- EMAclose, 50
fastema · line 6 - EMAclose, 20
fema · line 7 - EMAclose, 200
slowema · line 8 - Crossoverfema, fastema
longCondition1 · line 20 - Crossunderfema, fastema
shortCondition1 · line 29
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 Entry long | (longCondition1 and longcondition2 and longcondition3 ) | On | 26 |
| Exit exit stop and limit | (longCondition1 and longcondition2 and longcondition3 ) | On | 27 |
| Open Short Entry short | (shortCondition1 and shortcondition2 and shortcondition3 ) | On | 35 |
| Exit exit stop and limit | (shortCondition1 and shortcondition2 and shortcondition3 ) | On | 36 |
Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.
Does it repaint?
No
No repainting patterns in the source.
- ClearHigher-timeframe 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 | −6.7% | +102.5% | 1 | 0% | 0.00 | 14.5% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | −4.4% | +5.5% | 1 | 0% | 0.00 | 8.9% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −0.3% | +9.8% | 0 | 0% | 0.00 | 103.4% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | −13.1% | +8.4% | 1 | 0% | 0.00 | 16.7% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | −134.7% | +16.7% | 2 | 0% | 0.00 | 209.9% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | −9.8% | +21.5% | 1 | 0% | 0.00 | 21.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +0.1% | +148.3% | 1 | 100% | 1.53 | 41.1% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | −3.3% | +17.1% | 1 | 0% | 0.00 | 3.8% | 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 | 0 | — | $0.00 |
| Sideways market | 1 | 0% | −$6,432.52 |
| Falling market | 0 | — | $0.00 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
6.4%
The 95th percentile of the worst drawdown when the same 1 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 6.4% to 6.4%; the tick is what actually happened, 6.4%. Order luck alone moves it this much.
All 1 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 25 Apr 2025 93,980.50 | 21 Jan 2026 88,427.70 | 271 | −$6,432.52 |
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 |
|---|---|---|---|---|---|
| rt maax EMA cross strategy this page | — | v5 strategy | −6.7% | 1 | 14.5% |
| EMA Slope AyE by fajardoarelys | ema | v4 strategy | No trades on this market | ||
| ROoT by realisticDove62527 | ema | v5 strategy | −4.7% | 225 | 9.4% |
| sachin5986 by mohitesachin78 | ema | v4 strategy | +32.1% | 35 | 17.6% |
| sonu1997 by Sonu1997 | ema | v4 strategy | +960.7% | 2 | 1,103.8% |
| Moving Average Crossover by Muh4mm4d | ema | v4 strategy | +19,990.1% | 30 | 1,274.2% |
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.
- 1 setting uses the untyped input() (line 18). 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 1 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 18: input() → input.bool()
⋯// === INPUT SHOW PLOT ===-showDate = input(defval = true, title = "Show Date Range")+showDate = input.bool(defval = true, title = "Show Date Range")// === FUNCTION EXAMPLE ===⋯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: 1 before, 1 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.
⋯// © rt-maax-//@version=5+//@version=6strategy(title = "rt maax EMA cross strategy", shorttitle = "rt maax ema ", overlay = true, precision = 8, max_bars_back = 200, pyramiding = 0, initial_capital = 100000, ⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 12 ms | Yes 1,000 bars in 22 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/// © rt-maax//@version=5strategy(title = "rt maax EMA cross strategy", shorttitle = "rt maax ema ", overlay = true, precision = 8, max_bars_back = 200, pyramiding = 0, initial_capital = 100000, currency = currency.USD, default_qty_type = strategy.cash, default_qty_value = 100000, commission_type = "percent", commission_value = 0.27)fastema = ta.ema (close , 50)fema=ta.ema(close,20)slowema= ta.ema(close,200)price = close// === INPUT BACKTEST RANGE ===fromMonth = input.int(defval = 1, title = "From Month", minval = 1, maxval = 12)fromDay = input.int(defval = 1, title = "From Day", minval = 1, maxval = 31)fromYear = input.int(defval = 2021, title = "From Year", minval = 1970)thruMonth = input.int(defval = 10, title = "Thru Month", minval = 1, maxval = 12)thruDay = input.int(defval = 25, title = "Thru Day", minval = 1, maxval = 31)thruYear = input.int(defval = 2112, title = "Thru Year", minval = 1970)// === INPUT SHOW PLOT ===showDate = input(defval = true, title = "Show Date Range")// === FUNCTION EXAMPLE ===longCondition1= ta.crossover (fema , fastema) longcondition2= fema> slowemalongcondition3=fastema>slowemaif (longCondition1 and longcondition2 and longcondition3 ) stoploss=low*0.97 takeprofit=high*1.12 strategy.entry("Long Entry", strategy.long) strategy.exit ("exit","long",stop=stoploss,limit=takeprofit) shortCondition1 = ta.crossunder (fema , fastema )shortcondition2= fastema< slowemashortcondition3= fema< slowemaif (shortCondition1 and shortcondition2 and shortcondition3 ) stoploss=low*0.97 takeprofit=high*1.5 strategy.entry("Short Entry", strategy.short) strategy.exit("exit","short",stop=stoploss,limit=takeprofit)