Pine Script v5 · Strategy
GENESIS
A Pine Script v5 strategy built on EMA (close, lenght1), Crossover (ema1, ema2) and Crossunder (ema1, ema2). 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 is one contract and pays no commission. It has no settings.
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 GENESIS repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 4 of 4 trades.
- How did GENESIS do on BTCUSDT 1D with default settings?
- +0.13%
- From 26 Jan 2024 to 21 Oct 2026, over 19 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Does GENESIS 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: 19 before, 15 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 GENESIS use a stop loss?
- Yes
- strategy.exit sets a stop on line 16, 18.
- Does GENESIS run in Zeal Terminal?
- Yes
- It compiles in 16 ms and runs 1,000 bars in 19 ms, in the browser.
BTCUSDT · 1D · default settings
- Señal para Long
- Señal para Short
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- +0.13%
- $1,317.21
- Buy and hold
- +102.5%
- same period
- Closed trades
- 19
- 7 won · 12 lost
- Profitable
- 36.8%
- of closed trades
- Profit factor
- 1.03
- gross profit ÷ gross loss
- Max drawdown
- 2.68%
- −$27,535.90
One run with the author's default settings, $1,000,000 starting capital, commission as the script sets it. A long 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 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 15, 17. 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.
The script declares no settings.
What it calculates
- EMAclose, lenght1
ema1 · line 7 - EMAclose, lenght2
ema2 · line 8 - Crossoverema1, ema2
long · line 9 - Crossoverema2, ema1
short · line 10 - Crossoverema1, ema2
LongSignal · line 11 - Crossunderema1, ema2
ShortSignal · line 12
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 | long | On | 15 |
| Exit Exit stop and limit | every bar | On | 16 |
| Open short short | short | On | 17 |
| Exit Exit stop and limit | every bar | On | 18 |
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 | +0.1% | +102.5% | 19 | 37% | 1.03 | 2.7% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +1.3% | +5.5% | 12 | 42% | 3.45 | 0.3% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +0.0% | +9.8% | 15 | 33% | 1.32 | 0.1% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +0.0% | +8.4% | 16 | 44% | 1.32 | 0.0% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | −0.0% | +16.7% | 23 | 43% | 0.42 | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +0.0% | +21.5% | 12 | 50% | 8.33 | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +0.0% | +148.3% | 11 | 64% | 2.11 | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | −0.0% | +17.1% | 25 | 24% | 0.96 | 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 | 4 | 25% | −$5,393.87 |
| Sideways market | 12 | 42% | $14,566.70 |
| Falling market | 3 | 33% | −$7,855.61 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
4.4%
The 95th percentile of the worst drawdown when the same 19 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 2.0% to 4.4%; the tick is what actually happened, 2.6%. Order luck alone moves it this much.
All 19 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| short | 4 May 2024 62,882.00 | 4 May 2024 62,881.90 | 0 | $0.10 |
| long | 5 May 2024 63,892.00 | 8 May 2024 62,312.10 | 3 | −$1,579.96 |
| short | 8 May 2024 62,312.10 | 8 May 2024 62,312.10 | 0 | −$0.02 |
| long | 18 May 2024 67,024.00 | 24 Jun 2024 63,210.00 | 37 | −$3,813.99 |
| short | 24 Jun 2024 63,210.00 | 24 Jun 2024 63,210.00 | 0 | −$0.02 |
| long | 23 Jul 2024 67,532.00 | 6 Aug 2024 54,018.80 | 14 | −$13,513.20 |
| short | 6 Aug 2024 54,018.80 | 6 Aug 2024 54,018.70 | 0 | $0.10 |
| long | 23 Sep 2024 63,578.80 | 18 Feb 2025 95,780.00 | 148 | $32,201.20 |
| short | 18 Feb 2025 95,780.00 | 18 Feb 2025 95,780.00 | 0 | −$0.02 |
| long | 25 Apr 2025 93,980.50 | 30 Aug 2025 108,377.00 | 127 | $14,396.90 |
| short | 30 Aug 2025 108,377.00 | 30 Aug 2025 108,377.00 | 0 | −$0.02 |
| long | 16 Sep 2025 115,350.00 | 26 Sep 2025 108,994.00 | 10 | −$6,355.22 |
| short | 26 Sep 2025 108,994.00 | 26 Sep 2025 108,994.00 | 0 | $0.10 |
| long | 2 Oct 2025 118,595.00 | 18 Oct 2025 106,432.00 | 16 | −$12,163.30 |
| short | 18 Oct 2025 106,432.00 | 18 Oct 2025 106,432.00 | 0 | $0.10 |
| long | 18 Jan 2026 95,147.80 | 21 Jan 2026 88,427.70 | 3 | −$6,720.11 |
| short | 21 Jan 2026 88,427.70 | 21 Jan 2026 88,427.60 | 0 | $0.10 |
| long | 16 Apr 2026 74,810.00 | 1 Jun 2026 73,674.40 | 46 | −$1,135.60 |
| short | 1 Jun 2026 73,674.40 | 1 Jun 2026 73,674.40 | 0 | −$0.02 |
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 |
|---|---|---|---|---|---|
| GENESIS this page | — | v5 strategy | +0.1% | 19 | 2.7% |
| 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.
- 2 strategy calls use the when = argument (line 15, 17). 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 19 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 15: when = long → if block
- Line 17: when = short → if block
⋯plotshape(ShortSignal , title="Señal para Short", color= color.red, location=location.abovebar, size=size.tiny, text="Short", textcolor=color.white)-strategy.entry("long", strategy.long, when = long)+if long+ strategy.entry("long", strategy.long)strategy.exit("Exit", "Long", profit = 10, loss = 2)-strategy.entry("short", strategy.short, when = short)+if short+ strategy.entry("short", strategy.short)strategy.exit("Exit", "short", profit = 10, loss = 2)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: 19 before, 15 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.
⋯// © genesisjgonzalezh-//@version=5+//@version=6strategy("GENESIS", overlay=true)⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 16 ms | Yes 1,000 bars in 19 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/// © genesisjgonzalezh//@version=5strategy("GENESIS", overlay=true)lenght1= (20)lenght2= (50)ema1= ta.ema(close, lenght1)ema2 = ta.ema(close, lenght2)long = ta.crossover(ema1,ema2)short = ta.crossover(ema2,ema1)LongSignal = ta.crossover (ema1,ema2)ShortSignal = ta.crossunder (ema1,ema2)plotshape(LongSignal , title="Señal para Long", color= color.green, location=location.belowbar, size=size.tiny, text="Long", textcolor=color.white)plotshape(ShortSignal , title="Señal para Short", color= color.red, location=location.abovebar, size=size.tiny, text="Short", textcolor=color.white)strategy.entry("long", strategy.long, when = long)strategy.exit("Exit", "Long", profit = 10, loss = 2)strategy.entry("short", strategy.short, when = short)strategy.exit("Exit", "short", profit = 10, loss = 2)