Pine Script v4 · Strategy
Galileo Galilei
A Pine Script v4 strategy built on EMA (open, 11). It has 3 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 commits 100000 in cash and pays no commission. 4 settings; defaults include Length 11 and Source open.
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 Galileo Galilei repaint?
- No
- No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
- How did Galileo Galilei do on BTCUSDT 1D with default settings?
- +16.93%
- From 26 Jan 2024 to 21 Oct 2026, over 61 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Can Galileo Galilei 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 Galileo Galilei use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does Galileo Galilei run in Zeal Terminal?
- Yes
- It compiles in 9 ms and runs 1,000 bars in 27 ms, in the browser.
BTCUSDT · 1D · default settings
- EMA
- Shape
- Shape
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- +16.93%
- $16,925.50
- Buy and hold
- +102.5%
- same period
- Closed trades
- 61
- 17 won · 44 lost
- Profitable
- 27.9%
- of closed trades
- Profit factor
- 1.16
- gross profit ÷ gross loss
- Max drawdown
- 42.25%
- −$52,810.30
One run with the author's default settings, $100,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 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
2 settings have no label
In the settings dialog startDate (line 14), finishDate (line 15) 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.
-
Note
Uses an argument v6 removed
when = on line 23, 27. The upgraded version below moves each call inside an if block.
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 ema → ta.ema, cross → ta.cross.
- 2 strategy calls use the when = argument (line 23, 27). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
v4 → v5
VerifiedSame 61 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 1: //@version=4 → //@version=5
- Line 7: ema → ta.ema
- Line 14: input(type = input.time) → input.time()
- Line 15: input(type = input.time) → input.time()
- Line 18: cross → ta.cross
- Line 19: cross → ta.cross
-//@version=4+//@version=5// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/⋯src = input(open, title="Source")-out = ema(src, len)+out = ta.ema(src, len)plot(out, title="EMA", color=color.yellow)⋯/////////// BACKTESTING start//////////-startDate = input(timestamp("2020-01-01"), type = input.time)+startDate = input.time(timestamp("2020-01-01"))-finishDate = input(timestamp("2025-01-01"), type = input.time)+finishDate = input.time(timestamp("2025-01-01"))time_cond = time >= startDate and time <= finishDate/////////// BACKTESTING end//////////-bearish = cross(close, out) == 1 and close[1] > close+bearish = ta.cross(close, out) == 1 and close[1] > close-bullish = cross(close, out) == 1 and close[1] < close+bullish = ta.cross(close, out) == 1 and close[1] < closeplotshape(bearish, color=color.white, style=shape.arrowdown, text="BEAR", location=location.abovebar)⋯Same 61 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 5: input() → input.int()
- Line 6: input() → input.source()
- Line 23: when = time_cond → if block
- Line 27: when = time_cond → if block
⋯strategy(title="Galileo Galilei", shorttitle="Galileo Galilei", overlay=true, initial_capital=100000, default_qty_type=strategy.cash, default_qty_value=100000)-len = input(11, minval=1, title="Length")+len = input.int(11, minval=1, title="Length")-src = input(open, title="Source")+src = input.source(open, title="Source")out = ta.ema(src, len)⋯if bullish- strategy.entry("BUY", strategy.long, when=time_cond)+ if time_cond+ strategy.entry("BUY", strategy.long) //strategy.close_all(when=bearish)⋯if bearish- strategy.entry("SELL", strategy.short, when=time_cond)+ if time_cond+ strategy.entry("SELL", strategy.short) //sell = if bearish⋯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: 61 before, 2 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.
-//@version=5+//@version=6// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/⋯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 |
|---|---|---|---|
| Length | 11 | int · min 1 | out |
| Source | open | source | out |
| Start Date (no label in the script) | timestamp("2020-01-01") | time | time_cond |
| Finish Date (no label in the script) | timestamp("2025-01-01") | time | time_cond |
What it calculates
- EMA (
ema,ta.emain v5)Source (open), Length (11)out · line 7
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 | time_condtime >= startDate and time <= finishDate | On | 23 |
| Open SELL short | time_condtime >= startDate and time <= finishDate | On | 27 |
| Close | not time_cond | On | 33 |
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 | +16.9% | +102.5% | 61 | 28% | 1.16 | 42.2% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | 0.0% | +5.5% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +12.4% | +9.8% | 43 | 40% | 1.13 | 41.8% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | 0.0% | +8.4% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +67.0% | +16.7% | 55 | 31% | 1.44 | 47.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 | +16.2% | +148.3% | 59 | 31% | 1.16 | 25.5% | 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 | 31 | 23% | $6,588.47 |
| Sideways market | 27 | 33% | $11,802.60 |
| Falling market | 3 | 33% | −$1,465.57 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
43.2%
The 95th percentile of the worst drawdown when the same 61 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 21.6% to 43.2%; the tick is what actually happened, 39.1%. Order luck alone moves it this much.
All 61 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| short | 24 Feb 2024 50,744.20 | 25 Feb 2024 51,568.20 | 1 | −$1,623.95 |
| long | 25 Feb 2024 51,568.20 | 17 Mar 2024 65,300.60 | 21 | $26,629.60 |
| short | 17 Mar 2024 65,300.60 | 18 Mar 2024 68,393.50 | 1 | −$4,736.29 |
| long | 18 Mar 2024 68,393.50 | 19 Mar 2024 67,610.00 | 1 | −$1,145.53 |
| short | 19 Mar 2024 67,610.00 | 21 Mar 2024 67,840.50 | 2 | −$340.94 |
| long | 21 Mar 2024 67,840.50 | 22 Mar 2024 65,501.30 | 1 | −$3,448.13 |
| short | 22 Mar 2024 65,501.30 | 25 Mar 2024 67,210.00 | 3 | −$2,608.68 |
| long | 25 Mar 2024 67,210.00 | 3 Apr 2024 65,464.00 | 9 | −$2,597.84 |
| short | 3 Apr 2024 65,464.00 | 5 Apr 2024 68,487.80 | 2 | −$4,619.04 |
| long | 5 Apr 2024 68,487.80 | 6 Apr 2024 67,820.60 | 1 | −$974.14 |
| short | 6 Apr 2024 67,820.60 | 7 Apr 2024 68,896.00 | 1 | −$1,585.61 |
| long | 7 Apr 2024 68,896.00 | 13 Apr 2024 67,116.50 | 6 | −$2,582.85 |
| short | 13 Apr 2024 67,116.50 | 23 Apr 2024 66,819.30 | 10 | $442.81 |
| long | 23 Apr 2024 66,819.30 | 25 Apr 2024 64,289.60 | 2 | −$3,785.94 |
| short | 25 Apr 2024 64,289.60 | 4 May 2024 62,882.00 | 9 | $2,189.42 |
| long | 4 May 2024 62,882.00 | 8 May 2024 62,312.10 | 4 | −$906.36 |
| short | 8 May 2024 62,312.10 | 10 May 2024 63,074.00 | 2 | −$1,222.76 |
| long | 10 May 2024 63,074.00 | 11 May 2024 60,800.00 | 1 | −$3,605.30 |
| short | 11 May 2024 60,800.00 | 14 May 2024 62,940.10 | 3 | −$3,519.90 |
| long | 14 May 2024 62,940.10 | 15 May 2024 61,577.50 | 1 | −$2,164.92 |
| short | 15 May 2024 61,577.50 | 16 May 2024 66,206.50 | 1 | −$7,517.39 |
| long | 16 May 2024 66,206.50 | 30 May 2024 67,652.40 | 14 | $2,183.92 |
| short | 30 May 2024 67,652.40 | 31 May 2024 68,352.20 | 1 | −$1,034.35 |
| long | 31 May 2024 68,352.20 | 1 Jun 2024 67,540.00 | 1 | −$1,188.20 |
| short | 1 Jun 2024 67,540.00 | 4 Jun 2024 68,809.90 | 3 | −$1,880.19 |
| long | 4 Jun 2024 68,809.90 | 12 Jun 2024 67,314.20 | 8 | −$2,173.61 |
| short | 12 Jun 2024 67,314.20 | 1 Jul 2024 62,772.00 | 19 | $6,747.78 |
| long | 1 Jul 2024 62,772.00 | 3 Jul 2024 62,135.50 | 2 | −$1,014.07 |
| short | 3 Jul 2024 62,135.50 | 14 Jul 2024 59,204.00 | 11 | $4,717.84 |
| long | 14 Jul 2024 59,204.00 | 31 Jul 2024 66,188.00 | 17 | $11,796.50 |
| short | 31 Jul 2024 66,188.00 | 9 Aug 2024 61,686.00 | 9 | $6,801.84 |
| long | 9 Aug 2024 61,686.00 | 12 Aug 2024 58,712.60 | 3 | −$4,820.24 |
| short | 12 Aug 2024 58,712.60 | 14 Aug 2024 60,587.20 | 2 | −$3,192.79 |
| long | 14 Aug 2024 60,587.20 | 15 Aug 2024 58,683.40 | 1 | −$3,142.20 |
| short | 15 Aug 2024 58,683.40 | 18 Aug 2024 59,492.00 | 3 | −$1,377.90 |
| long | 18 Aug 2024 59,492.00 | 19 Aug 2024 58,427.30 | 1 | −$1,789.55 |
| short | 19 Aug 2024 58,427.30 | 20 Aug 2024 59,438.50 | 1 | −$1,730.61 |
| long | 20 Aug 2024 59,438.50 | 21 Aug 2024 59,013.80 | 1 | −$714.52 |
| short | 21 Aug 2024 59,013.80 | 22 Aug 2024 61,156.00 | 1 | −$3,630.05 |
| long | 22 Aug 2024 61,156.00 | 28 Aug 2024 59,415.00 | 6 | −$2,846.87 |
| short | 28 Aug 2024 59,415.00 | 10 Sep 2024 57,042.00 | 13 | $3,993.92 |
| long | 10 Sep 2024 57,042.00 | 17 Sep 2024 58,214.00 | 7 | $2,054.59 |
| short | 17 Sep 2024 58,214.00 | 18 Sep 2024 60,314.00 | 1 | −$3,607.38 |
| long | 18 Sep 2024 60,314.00 | 1 Oct 2024 63,327.60 | 13 | $4,996.54 |
| short | 1 Oct 2024 63,327.60 | 7 Oct 2024 62,819.90 | 6 | $801.69 |
| long | 7 Oct 2024 62,819.90 | 8 Oct 2024 62,224.00 | 1 | −$948.59 |
| short | 8 Oct 2024 62,224.00 | 12 Oct 2024 62,540.00 | 4 | −$507.81 |
| long | 12 Oct 2024 62,540.00 | 24 Oct 2024 66,668.60 | 12 | $6,601.63 |
| short | 24 Oct 2024 66,668.60 | 25 Oct 2024 68,198.30 | 1 | −$2,294.36 |
| long | 25 Oct 2024 68,198.30 | 26 Oct 2024 66,698.30 | 1 | −$2,199.40 |
| short | 26 Oct 2024 66,698.30 | 27 Oct 2024 67,092.80 | 1 | −$591.38 |
| long | 27 Oct 2024 67,092.80 | 4 Nov 2024 68,776.00 | 8 | $2,508.81 |
| short | 4 Nov 2024 68,776.00 | 6 Nov 2024 69,372.00 | 2 | −$866.61 |
| long | 6 Nov 2024 69,372.00 | 26 Nov 2024 93,010.00 | 20 | $34,074.30 |
| short | 26 Nov 2024 93,010.00 | 28 Nov 2024 95,863.10 | 2 | −$3,067.52 |
| long | 28 Nov 2024 95,863.10 | 10 Dec 2024 97,276.50 | 12 | $1,474.36 |
| short | 10 Dec 2024 97,276.50 | 12 Dec 2024 101,125.00 | 2 | −$3,956.27 |
| long | 12 Dec 2024 101,125.00 | 19 Dec 2024 100,204.00 | 7 | −$910.74 |
| short | 19 Dec 2024 100,204.00 | 25 Dec 2024 98,663.60 | 6 | $1,537.29 |
| long | 25 Dec 2024 98,663.60 | 27 Dec 2024 95,791.60 | 2 | −$2,910.88 |
| short | 27 Dec 2024 95,791.60 | 3 Jan 2025 96,984.80 | 7 | −$1,245.61 |
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 |
|---|---|---|---|---|---|
| Galileo Galilei this page | — | v4 strategy | +16.9% | 61 | 42.2% |
| STR-EMA Oscilator [Azzrael] by Azzrael | ema cross | v5 strategy | +2.3% | 6 | 30.6% |
| Double EMA CROSS by EmreErturk_ | ema cross | v4 strategy | +5.1% | 9 | 34.5% |
| EMA Stoch Strategy For ProfitView by treigen | ema cross | v5 strategy | −69.8% | 5 | 80.6% |
| 5 Minute EMA Cross Strategy by jordanfray | ema cross | v5 strategy | +3.4% | 9 | 7.5% |
| Moving Average Crossover Strategy by Decam9 | ema cross | v5 strategy | +0.0% | 75 | 4.3% |
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 9 ms | Yes 1,000 bars in 27 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.
//@version=4// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © armigoldmanstrategy(title="Galileo Galilei", shorttitle="Galileo Galilei", overlay=true, initial_capital=100000, default_qty_type=strategy.cash, default_qty_value=100000)len = input(11, minval=1, title="Length")src = input(open, title="Source")out = ema(src, len)plot(out, title="EMA", color=color.yellow)//last8h = highest(close, 8)//lastl8 = lowest(close, 8)//plot(last8h, color=red, linewidth=2)//plot(lastl8, color=green, linewidth=2)/////////// BACKTESTING start//////////startDate = input(timestamp("2020-01-01"), type = input.time)finishDate = input(timestamp("2025-01-01"), type = input.time)time_cond = time >= startDate and time <= finishDate/////////// BACKTESTING end//////////bearish = cross(close, out) == 1 and close[1] > closebullish = cross(close, out) == 1 and close[1] < closeplotshape(bearish, color=color.white, style=shape.arrowdown, text="BEAR", location=location.abovebar)plotshape(bullish, color=color.white, style=shape.arrowup, text="BULL", location=location.belowbar)if bullish strategy.entry("BUY", strategy.long, when=time_cond) //strategy.close_all(when=bearish) // strategy.exit("exit", "Long", profit =, loss = 35)if bearish strategy.entry("SELL", strategy.short, when=time_cond) //sell = if bearish //strategy.close_all(when=bullish) // strategy.exit("exit", "Long", profit = bullish, loss = 100)profit = strategy.netprofitif not time_cond strategy.close_all()//plotshape(true, style=shape.triangleup, location=location.abovebar)