Pine Script v5 · Strategy
EMA Cross V1 for eth 4H
A Pine Script v5 strategy built on RSI (price, 26), Crossunder (vrsi, 70) and EMA (price, 17). It has 2 order rules, 1 entry among them, and trades long only with the default settings. Exits wait for a signal; there is no stop loss. Each trade is one contract and pays no commission. 13 settings; defaults include Rsi Lenght 26, Rsi OVS line 30 and Rsi OVB line 70.
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 EMA Cross V1 for eth 4H repaint?
- No
- No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
- How did EMA Cross V1 for eth 4H do on BTCUSDT 1D with default settings?
- +1.80%
- From 26 Jan 2024 to 21 Oct 2026, over 3 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Does EMA Cross V1 for eth 4H 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: 3 before, 3 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 EMA Cross V1 for eth 4H use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does EMA Cross V1 for eth 4H run in Zeal Terminal?
- Yes
- It compiles in 13 ms and runs 1,000 bars in 32 ms, in the browser.
BTCUSDT · 1D · default settings
- Plot
- Plot
- Plot
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- +1.80%
- $18,047.40
- Buy and hold
- +102.5%
- same period
- Closed trades
- 3
- 1 won · 2 lost
- Profitable
- 33.3%
- of closed trades
- Profit factor
- 2.08
- gross profit ÷ gross loss
- Max drawdown
- 1.95%
- −$19,451.30
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 OVS line” 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 52, 54. 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 |
|---|---|---|---|
| Rsi Lenght | 26 | int · min 1 · max 50 | vrsi |
| Rsi OVS line | 30 | int · min 1 · max 40 | unused |
| Rsi OVB line | 70 | int · min 1 · max 100 | co cu |
| Rsi Medium line | 42 | int · min 1 · max 60 | co exitLong2 |
| EMA Fast | 17 | int · min 1 · max 50 | emaF |
| EMA Medium | 35 | int · min 1 · max 100 | emaM |
| EMA Slow | 142 | int · min 1 · max 200 | emaS |
| Start Year | 2011 | int · min 2011 · max 2025 | entry Buy line 51 |
| Start Month | 1 | int · min 1 · max 12 | entry Buy line 51 |
| Start Day | 1 | int · min 1 · max 31 | entry Buy line 51 |
| End Year | 2025 | int · min 2011 · max 2025 | entry Buy line 51 |
| End Month | 1 | int · min 1 · max 12 | entry Buy line 51 |
| End Day | 1 | int · min 1 · max 31 | entry Buy line 51 |
What it calculates
- RSIprice, Rsi Lenght (26)
vrsi · line 11 - Crossundervrsi, Rsi OVB line (70)
cu · line 13 - EMAprice, EMA Fast (17)
emaF · line 18 - EMAprice, EMA Medium (35)
emaM · line 19 - EMAprice, EMA Slow (142)
emaS · line 20 - CrossunderemaF, emaM
exitLong1 · line 47 - Crossundervrsi, Rsi Medium line (42)
exitLong2 · line 48
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 | longC1 and longC2 | On | 52 |
| Close Buy | exitLong1 or exitLong2 | On | 54 |
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 | +1.8% | +102.5% | 3 | 33% | 2.08 | 1.9% | 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% | 3 | 33% | 1.10 | 0.1% | 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% | 3 | 33% | 0.88 | 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% | 4 | 50% | 1.51 | 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.
The trades
By market direction
| At entry, last 90 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 0 | — | $0.00 |
| Sideways market | 3 | 33% | $18,047.40 |
| 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?
1.7%
The 95th percentile of the worst drawdown when the same 3 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 1.0% to 1.7%; the tick is what actually happened, 1.7%. Order luck alone moves it this much.
All 3 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 16 Jul 2024 64,724.10 | 5 Aug 2024 58,161.00 | 20 | −$6,563.06 |
| long | 24 Aug 2024 64,037.20 | 7 Sep 2024 53,963.00 | 14 | −$10,074.30 |
| long | 19 Sep 2024 61,760.00 | 9 Feb 2025 96,444.80 | 143 | $34,684.80 |
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 |
|---|---|---|---|---|---|
| EMA Cross V1 for eth 4H this page | — | v5 strategy | +1.8% | 3 | 1.9% |
| 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 | ||
| EMA SCALPEUR + RSi - SHORT by YukalMoon | rsi ema | v5 strategy | No trades on this market | ||
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 52, 54). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
- No v6-only features. v6 is not needed to run this script.
Same 3 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 52: when = longC1 and longC2 → if block
- Line 54: when = exitLong1 or exitLong2 → if block
⋯if time >=start and time <=end- strategy.entry("Buy", strategy.long , when = longC1 and longC2)+ if longC1 and longC2+ strategy.entry("Buy", strategy.long )// if(exitLong1 or exitLong2)-strategy.close("Buy" , when = exitLong1 or exitLong2)+if exitLong1 or exitLong2+ strategy.close("Buy" ) ⋯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: 3 before, 3 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.
⋯// © chadsadachai-//@version=5+//@version=6strategy("EMA Cross V1", overlay= true)⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 13 ms | Yes 1,000 bars in 32 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/// © chadsadachai//@version=5strategy("EMA Cross V1", overlay= true)//rsilength = input.int(title = "Rsi Lenght" , defval=26 , minval=1, maxval=50)overS = input.int(title = "Rsi OVS line" , defval=30 , minval=1, maxval=40)overB = input.int(title = "Rsi OVB line" , defval=70 , minval=1, maxval=100)mLine = input.int(title = "Rsi Medium line" , defval=42 , minval=1, maxval=60)price = closevrsi = ta.rsi(price, length)co = vrsi >= mLine and vrsi < overB cu = ta.crossunder(vrsi, overB)//emaF = input.int(title = "EMA Fast" , defval=17 , minval=1, maxval=50)M = input.int(title = "EMA Medium" , defval=35, minval=1, maxval=100)S = input.int(title = "EMA Slow" , defval=142, minval=1, maxval=200)emaF = ta.ema(price , F)emaM = ta.ema(price , M)emaS = ta.ema(price , S)//plotplot(emaF , color = color.green , linewidth=1)plot(emaM , color = color.yellow , linewidth=1)plot(emaS , color = color.red , linewidth=1)//Time Stampstart = timestamp(input.int(title = "Start Year" , defval=2011 , minval=2011, maxval=2025), input.int(title = "Start Month" , defval=1 , minval=1, maxval=12), input.int(title = "Start Day" , defval=1 , minval=1, maxval=31), 0, 0)end = timestamp(input.int(title = "End Year" , defval=2025 , minval=2011, maxval=2025), input.int(title = "End Month" , defval=1 , minval=1, maxval=12), input.int(title = "End Day" , defval=1 , minval=1, maxval=31), 0, 0)// years = input.int(title = "Year" , defval=2018 , minval=2011, maxval=2025)// months = input.int(title = "Month" , defval=1 , minval=1, maxval=12)// days = input.int(title = "Day" , defval=1 , minval=1, maxval=31)//longCondition Default// longCondition1 = EMA_Fast >= EMA_Slow and EMA_Fast >= EMA_Medium//ta.crossover(EMA_Fast, EMA_Slow) EMA_Fast > EMA_Slow and EMA_Medium > EMA_Slow// longCondition3 = price >= EMA_Medium and price > EMA_Slow// longCondition2 = vrsi >= overSold and vrsi <= overBought //longCondition & shortCondition ETHUSD// 1.price > emaF > emaM > emaS// 2.rsi overcross overSlongC1 = price > emaF and price > emaM and price > emaS // longC1 = ta.crossover(emaF, emaM)longC2 = if longC1 co// shortC1 = EMA_Fast < EMA_Medium //and EMA_Fast < EMA_Slow and EMA_Medium < EMA_Slow //and cu// shortC2 = overBought > vrsi //and vrsi < overBought //overSold < vrsi and vrsi < mediumLine// exitLong Condition// 1.price < emaF < emaM < emaS// 2.rsi overcross mediumLineexitLong1 = ta.crossunder(emaF, emaM) //or emaF < emaM//and price < emaM and price < emaFexitLong2 = ta.crossunder(vrsi,mLine)//exitLong3 = price < emaM//strategy.entryif time >=start and time <=end strategy.entry("Buy", strategy.long , when = longC1 and longC2)// if(exitLong1 or exitLong2)strategy.close("Buy" , when = exitLong1 or exitLong2) // exitShort1 = EMA_Fast > EMA_Medium// //exitShort2 = ta.crossover(vrsi , mediumLine) // exitShort2 = ta.crossunder (vrsi,mediumLine)// strategy.close("Short" , when = exitShort1 or exitShort2)// //shortCondition = cu// //if (shortCondition1 and shortCondition2)// //strategy.entry("My Short Entry Id", strategy.short)